Asm.js JavaScript subset picks up the pace against C/C++

Mozilla-backed Asm.js narrows the performance gap with C/C++, cutting the speed advantage in half

Asm.js, a Mozilla-driven subset of JavaScript geared toward improving Web application performance and extending the Web to C and C++ applications, is catching up to native C/C++code, Mozilla said.

With Asm.js, developers get a JavaScript subset that can be used as a low-level, efficient target language for compilers. While native C/C++ code still outperforms Asm.js, the performance gap keeps narrowing, Mozilla said in a just-released blog. Asm.js was three times slower than C/C++in February and two times slower around June, but the gap has narrowed to 1.5 times or better. Mozilla has implemented Asm.js in its Emscripten compiler and SpiderMonkey JavaScript engine.

Mozilla attributes performance improvements to float32 optimizations, which offer benefits like fewer CPU cycles since they need less precision, but the company is not yet recommending building with float32 optimizations. "Emscripten disables float32 opts by default, and they are not recommended yet because they rely on Math.fround support in JS engines. Math.fround is part of ES6 (ECMAscript), the upcoming version of JavaScript and is supported in Firefox and Safari but not in other browsers yet," said Alon Zakai, a research team member at Mozilla. "Emscripten doesn't want to do something that is faster in one browser but slower in another since it cares about running well in all browsers, so for now it is off by default."

The Asm.js sublanguage describes a safe virtual machine for "memory-unsafe" languages like C or C++. The Asm.js specification document stipulates that a candidate draft is being developed for a version 1.0 of the specification. SpiderMonkey serves an implementation of the draft. JavaScript is partnered with HTML5 and Cascading Style Sheets as part of Web development. But a recent survey of Appcelerator developer tools users found interest in HTML5 slipping.

This story, "Asm.js JavaScript subset picks up the pace against C/C++," was originally published at InfoWorld.com. 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 InfoWorld.com on Twitter.

Copyright © 2013 IDG Communications, Inc.

InfoWorld Technology of the Year Awards 2023. Now open for entries!