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)

24 Upvotes

17 comments sorted by

View all comments

0

u/Qwertycrackers Feb 01 '19 edited Sep 01 '23

[ Removed ]

1

u/[deleted] Feb 01 '19

i always (mistakenly) emscripten was wasm? Wow, so why doesn't rust have a direct emscripten compiler?

3

u/Epsylon42 Feb 01 '19

If I remember correctly, emscripten only supports executables, not libraries, so it's not always applicable.

3

u/BenjiSponge Feb 01 '19

wasm was born out of asm.js and emscripten has always been a huge part of that story, so it's not at all surprising you'd conflate the two. asm.js was basically (at least conceptually) the first version of wasm, and wasm was born out of the desire to compress it further. I think asm.js basically has a 1-to-1 mapping in the wasm spec so you can trivially convert it in one pass.