Live data from Hacker News

Compiling LLJS to asm.js

jlongster.com

1–10 of 35 posts

Re: Compiling LLJS to asm.js

#2
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.

Re: Compiling LLJS to asm.js

#3
post #2

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.

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

Re: Compiling LLJS to asm.js

#4
post #2

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.

That'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

See the BananaBread demo: https://developer.mozilla.org/en-US/demos/detail/bananabread

Re: Compiling LLJS to asm.js

#5
post #2

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.

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

That's LLVM -> JS. Has anyone built Clang using emscripten (that would be the C -> LLVM piece)?

Re: Compiling LLJS to asm.js

#6
post #2

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.

That'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 See the BananaBread demo: https://developer.mozilla.org/en-US/demos/detail/bananabread

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

Re: Compiling LLJS to asm.js

#7
post #6

Earlier quoted context omitted.

That'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 See the BananaBread demo: https://developer.mozilla.org/en-US/demos/detail/bananabread

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

Oh, 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

Re: Compiling LLJS to asm.js

#8
post #5

Earlier quoted context omitted.

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

That's LLVM -> JS. Has anyone built Clang using emscripten (that would be the C -> LLVM piece)?

The C++ LLVM library is hard to compile to js. Didn't succeed last time[1].

[1] https://github.com/kripken/emscripten/issues/579

Re: Compiling LLJS to asm.js

#9
post #2

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.

That'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 See the BananaBread demo: https://developer.mozilla.org/en-US/demos/detail/bananabread

I think what the parent was asking was could libraries be written in C (for example jQuery) where performance is critical.

Re: Compiling LLJS to asm.js

#10
Whats the use for LLJS ? I dont really get it. So its not meant to be used in web development but for things like games or complete VMs. But isnt it much simpler for those cases to compile existing C codebases with emscripten instead of rewriting everything in LLJS ? Even if you start today with writing a new game engine, wouldnt it make more sense to use C++ and be able to target any platform there is instead of just the browser?
Post reply on HN