Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
MotleyCoder
Reel Rookie

Running C/C++/Rust on Roku (It works)

We have been working on a way for Roku devices to run C, C++, Rust, and other languages. Our goal is to bring the wealth of libraries written in these languages to the Roku platform and empower the developer to code in their language of choice.

We are looking for pilot customers that would be willing to trial run our product. The ideal customer has knowledge of compilers and build systems such as rustc/clang and cargo/CMake. If you are interested, please send a private message including your contact details and company name.

As a proof of concept, the following zip contains a “compiled to BrightScript” version of the C library duktape (https://duktape.org/) which is an implementation of JavaScript entirely in C. When loading the channel, you will see a keyboard where you can enter JavaScript and the result will be evaluated on the fly and printed above. The keyboard feeds directly to stdin, and the label above displays stdout. As such, the C/C++ source of the program is included and you may compile it and see the same results. The zip can be side-loaded, or you may add the channel:

https://my.roku.com/account/add/JavaScriptDemo

roku_js_demo.zip

JavaScriptDemo.jpg

We can compile standard C/C++ programs that rely on libc and libc++ (C longjmp and C++ exceptions disabled), as well as Rust using an experimental platform. You can even call functions defined in BrightScript and vice versa using externs. The generated code has been tested against thousands of unit tests such as floating point behavior, signed and unsigned operations, control flow, indirect calls, memory loads and stores, etc.

More work is being done to expand the capabilities of this platform such as completing the file-system implementation, exposing POSIX sockets using roStreamSocket/roDataGramSocket, supporting longjmp and exceptions, and even researching potential POSIX thread implementations using Tasks.

We are excited to unveil this technology and look forward to what you will create with it.

 

 

0 Kudos
10 REPLIES 10
Beor
Reel Rookie

Re: Running C/C++/Rust on Roku (It works)

Wooww, excellent, hopefully progress will be made to develop more advanced apps with another language .. I wonder if you can run a WebView

0 Kudos
MotleyCoder
Reel Rookie

Re: Running C/C++/Rust on Roku (It works)

@Beor Thanks! That's actually what started the project was a lack of browser and WebView for apps. We'll be posting another demo here shortly of a very popular game that's been ported to Roku, stay tuned!

Beor
Reel Rookie

Re: Running C/C++/Rust on Roku (It works)

@MotleyCoder 

Perfect, good job if you need help let me know I do not know much c ++ but in what I can contribute I will do it, it would be nice if everyone participates in the Roku community.

It is unfair that in the middle of 2020 Roku does not support Javascript, many opportunities are lost and learning a new language like BrightScript does not make much sense and it is a waste of time to learn this language for a device. Hopefully the community will press for Javascript to be supported and that is free and there is not much lobby

0 Kudos
Komag
Roku Guru

Re: Running C/C++/Rust on Roku (It works)

That's cool, I'm looking forward to seeing what you can come up with.

0 Kudos
kaman
Reel Rookie

Re: Running C/C++/Rust on Roku (It works)

If running C/C++ on Roku works, does it mean we could make KODI running on Roku?

Is there any reason why Roku do NOT officially support KODI?

0 Kudos

Re: Running C/C++/Rust on Roku (It works)

I think there's latent potential if, in addition to duktape, this leverages cpp-inherit (https://github.com/jam1garner/cpp-inherit) a crate written by a friend of mine which supplies a macro for inheriting Rust structures from C++ classes.

0 Kudos
nickfujita
Newbie

Re: Running C/C++/Rust on Roku (It works)

@MotleyCoder Thanks for your great work on this! I'm also very interested in the WebView capabilities, and was wondering if you possibly had any updates on this?


Would be great to allow the community to create web apps specifically for roku, with a bridge to the roku specific apis.

0 Kudos
crushor
Reel Rookie

Re: Running C/C++/Rust on Roku (It works)

Unfortunately,it seems that the C++ code in demo doesn't execute really . The output is from test.min.x.brs which are blurred, so I can't find out what the magic is .

I want to transplant  some library written in C++ to Roku , so it is very important for me to confirm that whether C++ code can run on Roku or not.

0 Kudos
MotleyCoder
Reel Rookie

Re: Running C/C++/Rust on Roku (It works)

If you'd like to see the magic, visit https://github.com/MotleyCoderDev/wasm2brs

For an article on how it works: https://motley-coder.com/2020/12/20/webassembly-on-roku/

Let me know if you have any questions, happy to help 🙂

0 Kudos
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.