Mozilla's asm.js uses JavaScript to improve Web performance

C and C++ apps get Web boost from a JavaScript subset that allows Web browsers to better perform optimization

With its asm.js project, Mozilla is promoting a subset of JavaScript intended to improve Web application performance and extend C and C++ applications to the Web.

Asm.js can be used as a low-level, efficient target language for compilers, according to the asm.js specification. Mozilla's goal has been to provide a high-performance target for applications written in low-level languages like C/C++, said Luke Wagner, a software engineer at Mozilla. By itself, asm.js does not make existing handwritten JavaScript faster, he said. "However, Web developers are very creative, and we expect them do a lot more with asm.js than just generation from C/C++." The Emscripten tool can compile C and C++ applications to asm.js, thus making them run faster.

"The key [to as.js] is a simple formal definition of the high-performance 'sweet spot,'" Wagner said. "This enables asm.js-generators like Emscripten, Mandreel, LLJS, and others to get a hard confirmation that they hit the spot. It also allows the browser's JavaScript engine to more easily and predictably perform aggressive optimization." Existing JavaScript engines can optimize this subset of JavaScript; asm.js proponents have already seen Firefox and Chrome achieve large speed-ups in a short time, said Wagner.

While asm.js has been cited for its usefulness in game development, enterprise applications also can benefit from it, JavaScript blogger Axel Rauschmayer said at the O'Reilly Fluent conference in San Francisco this week. He cites two main advantages of asm.js. "Advantage number 1, you get to compile existing C and C++ code -- and there's a lot of that code out there. You can compile it and run it very fast on the Web," Rauschmayer said. "The second advantage is that it's a neat compilation target for languages that are not JavaScript. You can more easily compile some languages so that they'll run on the Web platform and they'll run very fast."

Proponents of asm.js have planned additional Web APIs for compiling to asm.js in background threads and to store results of compilation offline. This would improve startup in future application loads.

This story, "Mozilla's asm.js uses JavaScript to improve Web performance," was originally published at Get the first word on what the important tech news really means with the InfoWorld Tech Watch blog. For the latest developments in business technology news, follow on Twitter.


Copyright © 2013 IDG Communications, Inc.