Compiling Rust to JS?

A lot of languages seem to have compilers for JS: List of languages that compile to JS · jashkenas/coffeescript Wiki · GitHub

Rust is not amongst them.

Is it not worth the hassle because of WebAssembly?

Or is it just that no one had the time to code it yet?

1 Like

It depends what you mean by compiling to "JS". Rust has an asm.js target too, so it's technically JavaScript. But asm.js back-end is not as reliable and fast as the WASM one.

TypeScript, CoffeeScript, and partially Dart can be compiled to code that looks like JavaScript source code, with the same higher-level constructs. But this is because semantics of these languages is very similar to JavaScript's, and these languages have intentionally chosen to avoid behaving in ways that are impossible to express in JS.

Rust does lots of things that high-level JavaScript code can't do, or does differently. Even simplest things like addition of two numbers has different semantics, so you can't translate Rust's a+b to a+b in JS.


This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.