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.
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:
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.
More InformationBringing asm.js to the Chakra JavaScript engine in Windows 10 Related ArticlesMozilla Enhances Browser-Based Gaming WebKit JavaScript Goes Faster Thanks To LLVM Firefox Runs JavaScript Games At Native Speed Java, ASM.js Or Native - Which Is Faster?
To be informed about new articles on I Programmer, install the I Programmer Toolbar, subscribe to the RSS feed, follow us on, Twitter, Facebook, Google+ or Linkedin, or sign up for our weekly newsletter.
Comments
or email your comment to: comments@i-programmer.info |
|||
Last Updated ( Tuesday, 24 February 2015 ) |