Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
LLVM.js: LLVM Itself Compiled to JavaScript via Emscripten (badassjs.com)
140 points by cleverjake on Jan 3, 2013 | hide | past | favorite | 12 comments



I 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.


I 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.


I 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!


PDF.js and Shumway both look like very promising projects. thanks for the pointers.


Atwood's Law strikes again!


Emscripten 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/)


Makes me excited for a forthcoming Emscripten => Brainfuck compiler.


Does it means that C++ compilers which use LLVM can finally be compiled to Javascript ? If so, it's a great news !


No, 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.


In 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.


x86 also has been compiled to javascript (http://bellard.org/jslinux/) QEMU style.


people 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.




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: