Live data from Hacker News

Compiling LLJS to asm.js

jlongster.com

11–20 of 35 posts

Re: Compiling LLJS to asm.js

#11
post #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 jus…

The main use for something like LLJS is to allow you to target asm.js with new code that you write. It's true that it's probably not the best idea to completely rewrite a 3d engine in it (right now), but it gives you a quick way to rewrite core parts of an intensive app (like a 3d game) for high performance. There are "inner loops" that could benefit from a small amount of LLJS.

As the post says, it's a proof of concept and a way to open up asm.js to people who want to tinker with it without compiling C code with emscripten.

Re: Compiling LLJS to asm.js

#12
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)?

I've built parts of LLVM itself,

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.

Re: Compiling LLJS to asm.js

#13
post #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 jus…

For a big codebase, yes, compiling C/C++ using emscripten or such is a good idea. But if you want to write a tiny part of a normal JS application in something faster, lljs is convenient. Sort of like you would write inline assembly in C perhaps.

Re: Compiling LLJS to asm.js

#14
post #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 jus…

The main use for something like LLJS is to allow you to target asm.js with new code that you write. It's true that it's probably not the best idea to completely rewrite a 3d engine in it (right now), but it gives you a quick way to rewrite core parts of an intensive app (like a 3d game) for high performance. There are "inner loops" that could benefit from a small amount of LLJS. As the post says, it's a proof of conc…

I see, so the main benefit vs compiling c to asm.js is that the development process is easier because you dont need to manually compile. Sounds interesting to use as a scripting language inside a c based game engine. So the core of the engine would be directly compiled to asm.js while the game logic scripting could be done in LLJS to be able to live-test your game.

Re: Compiling LLJS to asm.js

#15
LLJS, asm.js, & Emscripten are really moving Javascript forward at incredible speed. I wonder if these projects will affect the future of the JS spec (ECMAScript Harmony + above). It's an exciting time to be a web programmer.

Re: Compiling LLJS to asm.js

#16
post #14

Earlier quoted context omitted.

The main use for something like LLJS is to allow you to target asm.js with new code that you write. It's true that it's probably not the best idea to completely rewrite a 3d engine in it (right now), but it gives you a quick way to rewrite core parts of an intensive app (like a 3d game) for high performance. There are "inner loops" that could benefit from a small amount of LLJS. As the post says, it's a proof of conc…

I see, so the main benefit vs compiling c to asm.js is that the development process is easier because you dont need to manually compile. Sounds interesting to use as a scripting language inside a c based game engine. So the core of the engine would be directly compiled to asm.js while the game logic scripting could be done in LLJS to be able to live-test your game.

That's certainly a possibility! It would be neat to see powerful debugging tools develop, after the language stabilizes. I also like the idea of somehow linking it with emscripten-compiled code so that it can be used as a sort of scripting language.

I'd like to explore the possibility of porting some of the C toolchain to the browser too, though. It's possible that it could be quite successful, and in that case LLJS would target people who just want to write small parts of there app for asm.js.

Re: Compiling LLJS to asm.js

#17
post #14

Earlier quoted context omitted.

I see, so the main benefit vs compiling c to asm.js is that the development process is easier because you dont need to manually compile. Sounds interesting to use as a scripting language inside a c based game engine. So the core of the engine would be directly compiled to asm.js while the game logic scripting could be done in LLJS to be able to live-test your game.

That's certainly a possibility! It would be neat to see powerful debugging tools develop, after the language stabilizes. I also like the idea of somehow linking it with emscripten-compiled code so that it can be used as a sort of scripting language. I'd like to explore the possibility of porting some of the C toolchain to the browser too, though. It's possible that it could be quite successful, and in that case LLJS…

sounds really exciting, keep up the great work!

Re: Compiling LLJS to asm.js

#19

Yesterday I rewrote a tiny Javascript demo in asm.js and also saw an order-of-magnitude speedup. (I thought at first it didn't help at all, apparently because the framerate was limited by setInterval().) Code at http://wry.me/hacking/canvas_asm.html

Doesn't appear to be doing anything for me,

    noasm 285
    asm 13
    asm 13
    noasm 269 
That's all that appears in the console. Network and everything looks fine, no 404 or other errors.

Re: Compiling LLJS to asm.js

#20

Yesterday I rewrote a tiny Javascript demo in asm.js and also saw an order-of-magnitude speedup. (I thought at first it didn't help at all, apparently because the framerate was limited by setInterval().) Code at http://wry.me/hacking/canvas_asm.html

Doesn't appear to be doing anything for me, noasm 285 asm 13 asm 13 noasm 269 That's all that appears in the console. Network and everything looks fine, no 404 or other errors.

Yes, I disabled display so that wouldn't get into the benchmark. The numbers are times in milliseconds.
Post reply on HN