4 ms·
LLVM.js: LLVM Itself Compiled to JavaScript via Emscripten
- cmircea 14y agoAtwood's Law strikes again!
- tlrobinson 14y agoEmscripten lets you compile basically anything to JavaScript (including itself, apparently), so Atwood's Law is really equivalent to saying JavaScript is Turing complete. See also: jslinux (http://bellard.org/jslinux/ http://bellard.org/jslinux/)
- timcameronryan 14y agoMakes me excited for a forthcoming Emscripten => Brainfuck compiler.
- MatthewPhillips 14y agoI think I know where they are going with this; PNaCl compiles Native Client code to LLVM bitcode, which now will be able to be compiled to JavaScript in the browser.
- azakai 14y agoI am not aware of any concrete plans to do anything like that. It is true that PNaCl generates LLVM bitcode, but so does clang, which is what Emscripten uses. PNaCl has its own set of new APIs, none of which are supported by anything but PNaCl (and in particular not Emscripten); Emscripten does support the typical libraries a cross-platform app uses, like SDL, glut, egl, xlib. So it would be a lot of work to get Emscripten to do anything with PNaCl binaries given the different APIs. Furthermore, converting PNaCl binaries to JS in the browser would add a lot of overhead compared to compiling to JS ahead of time and just sending the user the JS to directly run. So if you want to run a C++ app in JS, you should just compile it to JS directly using Emscripten, PNaCl doesn't fit there in any way that I can see.
- MatthewPhillips 14y agoI was thinking of this being useful in the way that the PDF.js and Shumway projects are. But if you say the APIs are not there, I believe ya!
- zem 14y agoPDF.js and Shumway both look like very promising projects. thanks for the pointers.
- jethroalias97 14y agox86 also has been compiled to javascript (http://bellard.org/jslinux/ http://bellard.org/jslinux/) QEMU style.
- iso-8859-1 14y agopeople usually use the word "emulator" for this. I do not believe jslinux actually outputs anything. So to call it a compiler would be misleading, IMHO.
- arcatek 14y agoDoes it means that C++ compilers which use LLVM can finally be compiled to Javascript ? If so, it's a great news !
- iso-8859-1 14y agoNo, cause they use LLVM parts that were not yet successfully compiled to JS. This is just an LLVM assembler and bitcode-to-JS translator. Obviously, a JavaScript C compiler would have been a much more impressive demo, and that would have been demoed instead.
- azakai 14y agoIn principle yes, someone could compile clang into JavaScript exactly like in this project other LLVM tools were. It's just a matter of whether someone thinks it's worth doing and takes the time.