I like this a lot. It's similar to lljs [1] in allowing small amounts of asm.js to be generated, using a familiar syntax (C). That's an important use case and indeed Emscripten doesn't really support it.<p>Two comments on this bit:<p>> Wait, what's wrong with Emscripten? [..] It's perfect if you've got a great big POSIX C + SDL codebase that you want to run in its own self-contained environment in a browser, but it's not very helpful for writing idiomatic Javascript code that just needs to drop into optimised asm.js occasionally for some heavy lifting.<p>First, I think this correctly describes some important use cases. But more generally, I think the main use cases I see in this space are<p>1. Complete C or C++ programs, like a 3D game engine. Emscripten mainly focuses on this.<p>2. A C or C++ library that people want to use from JS, like Box2D or Bullet. Emscripten focuses on this quite a bit as well. You can disable filesystem support and other unnecessary features for such pure computational code, and then for a library the size of Box2D or Bullet, Emscripten's runtime isn't a significant code size issue. And it provides tools to make C++ objects look like JS objects, so using such libraries is convenient (see ammo.js and box2d.js for examples).<p>3. Small amounts of C that are to be "embedded" in JS. lljs and Bonsai-c focus on this.<p>A second comment: The third use case here is easy to get wrong. There is often a cost to calling from JS to asm.js and back. Writing a little asm.js function that adds two numbers and calling that in a loop will generally not be efficient, both because such functions are often optimized to asm.js-like speed anyhow, and because of the JS<->asm.js overhead. To make it worth it, the asm.js needs to do a more serious amount of work. Just mentioning this because it seems like a common pitfall.<p>[1] <a href="http://lljs.org/" rel="nofollow">http://lljs.org/</a>
As someone who has worked extensively with emscripten, and asm.js, something like this is great and needed.<p>Very promising, however it could easily become a crappy version of emscripten by adding e.g. C++ support or full C standard library support.
> It's perfect if you've got a great big POSIX C + SDL codebase that you want to run in its own self-contained environment in a browser, but it's not very helpful for writing idiomatic Javascript code that just needs to drop into optimised asm.js occasionally for some heavy lifting.<p>That's not really true -- it's pretty easy to call into an Emscripten module from javascript. You have to do some data marshalling, but that's true of any dynamic language -> c binding.
Really great, like it. I'd also love to see the examples get more complex as the engine gets more capable. I mean the engine is pretty cool already: <a href="https://github.com/gasman/bonsai-c/blob/master/examples/add.c" rel="nofollow">https://github.com/gasman/bonsai-c/blob/master/examples/add....</a> - but it doesn't give any impression about what it currently is capable of. (e.g. in the README it tells about the lack of string support, et al.)<p>Will follow the progress of this project!