I’ve been following Emscripten for a while now. It was pretty solid months ago, and it keeps getting better. Now that asm.js is beginning to show pretty impressive results and Chrome is apparently considering to implement optimisations for it, things are looking pretty good for native code in the browser these days.
So, why would anyone want native code in the browser? Legacy code, you might think, but that’s not really it. Games is the biggest reason.
C++ is the single most important language in (professional) game development, and before that it was C. Before that various assembler dialects. See the pattern? Many game developers, especially indies, use engines where they can work in higher-level languages, but you still need to run these on everything that calls itself a gaming device. And they’re of course almost all written in C or C++. So there’s really no way around native code execution if you want games on your platform, that’s why every notable mobile platform has added them, sometimes reluctantly.
There are numerous reasons why most of the game industry is still using C++. One is that it’s pretty much the only language you can use on every single platform that runs games, from desktop to handheld consoles. Another is that, as opposed to desktop applications, games usually have the exact same user interface across platforms. So rewriting it in the platform’s native frameworks, as is a popular approach to mobile apps these days, does not make much sense. You usually want one code base that runs everywhere. C and C++ are the only reasonable options for that right now. And even though many atrocities have been committed with C++, you can actually write nice code in it – look to the likes of Stroustrup and Carmack for that.
So, why is asm.js a big deal?
Because the browser is suddenly a feasible platform for game developers, most of which previously ignored it. It’s not a huge investment anymore, you can still ship the same code base to desktop, mobile and consoles. You can even feasibly have a web-based demo and then deliver the full game as a native application, or make an MMORPG free to play with a limited browser client, and have people pay money for the gorgeous native client. We’ll probably see all the big third party engines compile to asm.js in no time, Unreal Engine having already taken the lead. Browsers will either support WebGL or lose users. I’m betting my money on the former. This is very likely the dawn of the browser as a proper gaming platform.