Ask HN: How much faster can asm.js (realistically) get?

10 points by bnjohnny ↗ HN
asm.js is really impressive. Engineering within limitations yet still producing something that runs http://beta.unity3d.com/jonas/AngryBots/

(Try in Firefox 29+ for best results)

https://hacks.mozilla.org/2014/05/asm-js-performance-improvements-in-the-latest-version-of-firefox-make-games-fly/

4 comments

[ 3.1 ms ] story [ 15.5 ms ] thread
Is it possible that asm.js, since it's compiled dynamically on the client (giving access to more information potentially leading to better optimizations) can eventually out perform c/c++?
You can do "profile-guided optimizations" in C++ as well. It's easier to exploit CPU capabilities (e.g. AVX) if you run the compiler on the client side, but once again compilers can do the same.

The latency requirements prevent some of the more aggressive and time consuming optimizations from being attempted.

Those of us who have been around for a while will remember hearing that claim made about the JVM back in the late 1990s, back when HotSpot came onto the scene.

Obviously, those claims did not hold true in practice.

HotSpot has had some very talented people work on it. And Java bytecode is much more suited to such optimization than asm.js is, too. If it wasn't accomplished there, then it's doubtful it'll be done elsewhere.

So maybe it's theoretically possible, but we just haven't seen it happen in practice. There's little to suggest that it ever will happen, too.

Sometimes, I wonder why we spend billions trying optimized a javascript code that will anyway run slower than a naive C/C++ app solving the same problem. Part of the answer is that you just need one url, a browser to access an app: Much simpler than downloading and installing a software.

From my point of view, in a near future, browsers will execute a language that will be statically typed, not garbage collected, with support of multi-threading (I mean real threads with shared memory, not webworkers), and mapping to SIMD units (AVX, SSE, NEON, ...). That day, there won't be any reason anymore for web apps to be slower than native apps. Plus, they will be a lot more power efficient than the javascript vm.