
LLVM.js: LLVM Itself Compiled to JavaScript via Emscripten - cleverjake
http://badassjs.com/post/39573969361/llvm-js-llvm-itself-compiled-to-javascript-via
======
MatthewPhillips
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.

~~~
azakai
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.

~~~
MatthewPhillips
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!

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

------
cmircea
Atwood's Law strikes again!

~~~
tlrobinson
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/>)

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

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

~~~
iso-8859-1
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.

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

~~~
iso-8859-1
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.

