3 ms·
The author seems to assume asm.js/WebAssembly are only for games and not useful for anything else: "It’s so limited and specialistic that beyond porting games t
by AshleysBrain 11y ago
The author seems to assume asm.js/WebAssembly are only for games and not useful for anything else: "It’s so limited and specialistic that beyond porting games to run inside a browser using WebGL and LibSDL, it’s hard to think of suitable use-cases."
This is not the case at all - there are loads of use cases outside of games, and some of them have more straightforward dependencies (e.g. no graphics or networking). Take a look at Alon Zakai's github [1] where there are some examples of various libraries compiled to the web which include physics engines (ammo.js, box2d, cannon.js), database engines (SQLite), programming language VMs (lua, j2me), parsers (xml.js) and more (LLVM, clang, zlib, GMP, image/audio/video decoders...)
In some cases these are more-or-less drop-in replacements. For example I've pretty straightforwardly dropped in asm.js compilations of Box2D and zlib and gotten massive performance improvements over the handwritten versions with minor effort. In the Box2D case, it was so good we integrated the result in to a commercial product (Construct 2). I think it's also a compelling idea to be able to support new image and audio formats on the web at native-like speeds without requiring browser support, e.g. compiled WebP or Ogg Vorbis decoders.
I think the author has simply not done enough research around uses of compiling to the web to recognise its immense value.
[1] https://github.com/kripken?tab=repositories https://github.com/kripken?tab=repositories
- vanderZwan 11y ago> programming language VMs (lua, j2me) Since these are garbage collected languages, wouldn't it make more sense compile to plain JavaScript, treating that as VM-bytecode, and avoid doing things that slows down JavaScript VMs?
- azakai 11y agoNot necessarily, since their GC semantics might differ from JavaScript. For example, if they have finalizers, then compiling into JS isn't an option. Other semantic differences might also make this hard or impossible. Compare pyjamas to pypy.js, for example - the former compiles to JS, but has known differences from proper Python semantics (long bignums), while the latter is a straight port of a Python VM, so the semantics are identical.
- mchahn 11y agoI did a contract project that consisted of porting a C app to asm.js/emscripten. Various C bugs gave results that had to be repeated precisely in javascript. Several other contractors attempted to replicate the behavior using JS rewrites and failed. One said it was impossible (grin).