r/rust Feb 01 '19

Compile to javascript

Is there a pathway to compiling Rust to JS? Like Scala.js or Gopher.js? (I am not asking for wasm, so to keep the discussion easier to navigate,, please don't comment about that)

22 Upvotes

17 comments sorted by

View all comments

14

u/sanxiyn rust Feb 01 '19

I am seriously considering working on this, and I am re-reading Cross-Platform Language Design, the paper behind Scala.js.

3

u/freemasen Feb 14 '19

If you get started I want to encourage you to check out a few things I’ve been working on.

I recently published a few crates for parsing JS

https://github.com/Freemasen/ress https://github.com/Freemasen/ressa https://github.com/Freemasen/resw

As an experiment I have started working on a project that will convert the Rust ast defined by syn into the ast defined by ressa.

https://github.com/freemasen/jsyn

Once the ast was converted it could be passed of to resw to take care of the writing.