3 ms·
Has anyone built the entire stack in javascript (C to JS compiler in JS + standard library) so that you could write JS applications in C and compile and run in
by niggler 14y ago
Has anyone built the entire stack in javascript (C to JS compiler in JS + standard library) so that you could write JS applications in C and compile and run in the browser?
EDIT: to clarify, the ideal solution would be an editor (like codemirror or ace) with a compile+run button that would compile the code down to JS and run it.
- jevinskie 14y agohttps://github.com/kripken/emscripten/wiki https://github.com/kripken/emscripten/wiki
- niggler 14y agoThat's LLVM -> JS. Has anyone built Clang using emscripten (that would be the C -> LLVM piece)?
- arcatek 14y agoThe C++ LLVM library is hard to compile to js. Didn't succeed last time[1]. [1] https://github.com/kripken/emscripten/issues/579 https://github.com/kripken/emscripten/issues/579
- azakai 14y agoI've built parts of LLVM itself, http://kripken.github.com/llvm.js/demo.html http://kripken.github.com/llvm.js/demo.html Which translates LLVM IR into LLVM bitcode, and then emscripten can translate to JS, all in the browser. No reason clang couldn't be compiled too, I imagine someone someday will do it when there's a need.
- jlongster 14y agoThat's exactly what emscripten does, and is very mature and being used to port massive 3d games to the web. https://github.com/kripken/emscripten https://github.com/kripken/emscripten See the BananaBread demo: https://developer.mozilla.org/en-US/demos/detail/bananabread https://developer.mozilla.org/en-US/demos/detail/bananabread
- niggler 14y agoYou have to use the command-line `emcc` tool to do this. I'm asking if that tool can be eliminated from the workflow. The ideal solution would be an editor (like codemirror or ace) with a compile+run button that would compile the code down to JS and run it.
- jlongster 14y agoOh, I see. No, not yet, I think the C compilers are complex enough to be difficult to compile with emscripten. I have no evidence for that, but I know they are incredibly complex. The shorter path is something like LLVM, but we could see something like a compiler all in js that can take a large subset of C and compile it. EDIT: see azakai's comment below which provides much better insight into this
- ihsw 14y agoI think what the parent was asking was could libraries be written in C (for example jQuery) where performance is critical.