Emscripten

Monkey Archive Forums/Digital Discussion/Emscripten

impixi(Posted 2012) [#1]
Anyone have any experience/comments with/about Emscripten?

https://github.com/kripken/emscripten/wiki


Emscripten is an LLVM to JavaScript compiler. It takes LLVM bitcode (which can be generated from C/C++ using Clang, or any other language that can be converted into LLVM bitcode) and compiles that into JavaScript, which can be run on the web (or anywhere else JavaScript can run).

Using Emscripten, you can

* Compile C and C++ code into JavaScript and run that on the web
* Run code in languages like Python as well, by compiling CPython from C to JavaScript and interpreting code in that on the web




impixi(Posted 2013) [#2]
Apparently Mozilla's Asm.js technology leverages Emscripten. Here's an article about it: Surprise! Mozilla can produce near-native performance on the Web

For Monkey to take advantage of it you'd have to create a c or c++ target that utilizes a Clang->LLVM->Emscripten tool chain. A big task, probably not worth it, but it's interesting to read about the latest browser performance innovations.


AdamRedwoods(Posted 2013) [#3]
true. another point is that asm.js does not replace JS, and I think you can intertwine the two, so there doesn't need to be an entire rewrite if Monkey chooses to go asm.js native.


impixi(Posted 2013) [#4]
Asm.js is actually a very limited subset of Javascript. Theoretically someone could create a direct Monkey->Asm.js translation target, but that would require even more work than via the toolchain route mentioned above.


AdamRedwoods(Posted 2013) [#5]
but c++->clang->LLVM->Emscriptem leaves more than a few places for error.
i suspect the c++ target would require a mod to be used within JS? this i don't know.