Firefox Nightly Now Includes OdinMonkey, Brings JavaScript Closer To Running At Native Speeds

Browsers today are able to execute JavaScript code significantly faster than just a few years ago, but even as our web apps now look more like desktop apps, JavaScript performance is still a far cry from what you can expect from a native program written in something like C or C++. To bridge this gap, Mozilla launched the asm.js project a while back and today, this code has landed in Firefox Nightly. OdinMonkey, Firefox’s name for its asm.js optimization module, allows developers to write their code in C or C++, compile it to JavaScript using Emscripten and run it at a speed that is within 2x of native performance.

Unless the project hits any roadblocks, Mozilla expects OdinMonkey to ship with the stable version of Firefox 22 in June.

Asm.js is a strict subset of JavaScript that “can be used as a low-level, efficient target language for compilers.” As the asm.ja specs note, this sub-language “effectively describes a safe virtual machine for memory-unsafe languages like C or C++.” Because it is just a subset of JavaScript, this also means that the code would still run in any other browser, too – it would “just run slower in the other browsers than in Firefox,” as a Mozilla spokesperson told me earlier today.

odinmonkey_asmjs_benchmarks

Image credit: Mozilla researcher Alon Zakai (@kripken)

You can find all the gory technical details about how this works here and in this earlier post by Axel Rauschmayer. Mozilla will also focus on this during its sessions at the Game Developer Conference in San Francisco next week.

From a users perspective, this means that you could soon see significantly better and complex games in your browser (and most game developers work with C or C++ anyway, so this is a natural fit for them) as well as generally faster web apps, assuming developers start adapting asm.js.

If you want to see what a difference OdinMonkey can make, try the BananaBench benchmark or this Emscripten-compiled falling boxes demo on Firefox Nightly. In my own tests, BananaBench ran about 3x faster using the Nightly.

For now, Mozilla has only enabled this feature on desktop Windows and Linux, but the organization says it will arrive for desktop OSX and the mobile version of Firefox on ARM soon.

In case you are wondering where the name OdinMonkey came from, Mozilla’s Luke Wagner says this death metal song was the inspiration (I sadly can’t understand a word these fine gentlemen are screaming, so we’ll just have to take his word for it):