Microsoft Supports asm.js
Written by Ian Elliot   
Thursday, 19 February 2015

Asm.js is probably the most important JavaScript technology of the moment. It allows JavaScript to be used as a high level assembler language within the browser, providing near native speed - and now Microsoft has joined Mozilla in supporting it.

asmjslogo

 

Asm.js isn't a new language; it is just a subset of JavaScript that has been selected to allow optimizing compilers, and JavaScript engines in general, to run it much faster than the complex and dynamic full JavaScript. For example, it has managed to find ways of including primitive types like 32 bit integer into JavaScript which allows such variables to be represented as four byte integers rather than floating point values that just happen to be integer. If you run asm.js on a non-asm.js optimized engine then you don't get the advantage because the supposed 32 bit integer values are still stored as floating point. 

That is the key to asm.js is not in the language but in the JavaScript engine which takes advantage of the simplicity of the language to optimize the run time. 

Currently most asm.js is generated by compiling C/C++ programs. As asm.js gets more support additional tools are certain to emerge making it possible to write in more than just C/C++.

Until yesterday Mozilla was the only major browser maker supporting asm.js - Microsoft, Google and Apple preferred to ignore the idea. Now Microsoft has announced that its Chakra JavaScript engine will support asm.js.

The blog post announing this points out that adding asm.js support was in the top ten most requested features on IE Suggestion Box on UserVoice. 

As the blog post from the Chakra team says:

Amongst other similar initiatives, asm.js as a technology has two key characteristics that we like: 

    • First and obvious is the boost to JavaScript execution speed, which we’ve already talked about. We believe that asm.js and the work we do to enable asm.js has the potential to provide speed benefits to many more scenarios over a period of time.

    • Second but more importantly is the fact that asm.js is a pure subset of JavaScript and guarantees interoperability across platforms and browsers. This means that engines that support asm.js light up the new features, while engines that don’t will simply run with degraded performance. Since the beginning of Chakra, our team’s focus has always been to prioritize this approach to new functionality.

Yes, it really is a win-win situation. You add asm.js support and some JavaScript runs a lot faster, but you still get 100% backwards compatibility. 

Now the real question is why don't Apple and Google see things this way?

The answer to this is fairly clear. Apple presumably doesn't really want web apps to run as fast as native apps because this would compromise its app store revenues. Google has a system that allows native code to run sandboxed in the browser. This also has a degree of platform independence via an intermediate language and JIT compiler. However, Chrome is the only browser that supports it.

Now that both Microsoft and Mozilla support asm.js, Google might shift its position. After all it isn't going to do Chrome any good to be left out of "runs on IE and Firefox" and adding asm.js support doesn't mean that it has to drop its native interface.

Of course, if Chrome can be made to run asm.js fast enough as a byproduct of optimizing JavaScript in general, it doesn't actually have to explicitly climb onto the asm.js bandwagon. Currently Chrome does observe the use asm directive, but what this means is difficult to say.

 

asmjslogo

Banner


WasmCon 2023 Sessions Now Online
01/03/2024

The recorded session of the premier conference for technical developers and users interested in exploring the potential of WebAssembly are now online.



Google Releases Gemma Open Models
28/02/2024

Google has released a set of lightweight open models that have been built from the same research and technology used to create Google's recent Gemini models.


More News

 

raspberry pi books

 

Comments




or email your comment to: comments@i-programmer.info

 

Last Updated ( Tuesday, 24 February 2015 )