3 ms·
No lol. Javascript is not a good language to compile to. People compile to JavaScript only because it's the only language to run in browsers. Most compilers, a
by kccqzy 8y ago
No lol. Javascript is not a good language to compile to. People compile to JavaScript only because it's the only language to run in browsers.
Most compilers, after type checking and semantic analyses, basically generate a control flow graph with basic blocks. Javascript doesn't have goto so it doesn't allow you to express those low-level things natively, which is why emscripten has to include a relooper component to turn them back into loops and conditionals.
If you want a good language to compile to, look at LLVM. It's a language designed to be compiled to, and it's mind-blowingly easy to compile to than either C or JavaScript.