Support For Asm.js Growing?
Written by Ian Elliot   
Wednesday, 24 September 2014

Asm.js is a subset of JavaScript designed to be the assembly language of the web and now it seems that support for this technology is growing beyond Mozilla.




JavaScript is the defacto standard language of the web on the client side and its use on the server is growing due to Node.js. However, many don't like the language and there is a large existing code base that isn't easy to convert to handcrafted JavaScript. The alternative is to use compilers that target JavaScript, like emscripten, to convert code in other languages to JavaScript. This works well, but JavaScript is such a sophisticated language that it is difficult to create optimizing compilers that can produce compiled JavaScript that runs close to native code speeds. 

One solution is to abandon JavaScript and allow native code apps to run under the control of the browser. This is the solution offered by Google's Chrome NaCl API and related technologies. The other solution, championed by Mozilla, is asm.js - a subset of JavaScript that is restricted enough to allow JIT optimizing compilers to run it at close to native code speeds.

You may doubt that the asm.js approach could deliver the performance gains needed, but benchmarks and demos seem to demonstrate that it can. It cannot match tuned native code but for a wide range of graphics and other demanding applications it does run code fast enough to be practical. 

The key advantage of asm.js is that it is a true subset of JavaScript. If a browser doesn't support asm.js then the code is run as if it was standard JavaScript. If a browser does support asm.js then the optimizing JS engine is switched on and it makes use of the hints included as comments to improve the performance. 

In practice asm.js would most likely be produced by a compiler that converts another language usually C or C++ to asm.js but it could be hand written if required and, as the technology develops, new features are easy enough to add without having to modify standard JavaScript.

At the moment the only browser that supports asm.js in a big way is Firefox but both Chrome and Opera run asm.js code faster than standard JavaScript. As asm.js runs on any browser that supports JavaScript there isn't a lot of point in saying that a browser supports asm.js. What matters is how much faster asm.js runs, i.e. does the browser optimize asm.js? 

Even though Chrome and Opera don't officially support asm.js, they do both run asm.js code faster than standard JavaScript simply because the standard JavaScript optimizations they use work more effectively on asm.js. 

For asm.js to become a success and the accepted way of running code fast in the browser it really needs support from both Chrome, IE and Opera. Support by Safari would be nice but this doesn't seem likely until the big three JavaScript engines have it and Apple is forced to consider the situation.

Google's attitude to asm.js has to be influenced by its own NaCl approach to getting faster code, but there is no technical reason it can't support both. In the latest experimental compiler TurboFan, which was made public a few days ago, it has been pointed out that there is a new constant:

DEFINE_BOOL(turbo_asm, false,
         "enable TurboFan for asm.js code")

is this support for special asm.js optimizations? It certainly looks that way, but more digging is needed to find out.

The next crack in the dam is from Microsoft. A few days ago it updated its road map for IE. The majority of "in development" features are *related to ES6 or HTML5  APIs and perfectly reasonable.

One new item in the "Under Consideration" is:



Of course being "Under Consideration" doesn't mean that it will move to "in development" but it is a step in the right direction. There is also the argument that the Microsoft team might have listed it to indicate that they are aware of it or to indicate that they aren't actually against it. The point is that to "support" asm.js they simply have to include one asm.js optimization - which isn't a huge hurdle to get over!

At the moment, things are looking good for asm.js and who knows it might get the support of the big three browsers - Firefox, IE and Chrome - and then Safari would probably follow some time in the distant future. It helps to realize that browsers are not technology driven, but marketing driven.




Amazon Updates Q Family And Previews App Studio

Amazon made multiple announcements at its AWS Summit in New York, including a preview of AWS App Studio, the addition of Q Developer to SageMaker Studio, and an Amazon Q Apps API.

htmx 2 Released - The Next Big Thing?

htmx seems to have crept up on us programmers - perhaps because we are programmers. Is this the next big thing and is it a JavaScript killer?

More News


kotlin book



or email your comment to:


Last Updated ( Wednesday, 24 September 2014 )