X

Google shows interest in ASM.js, Mozilla's plan for fast Web apps

A Chrome programmer seeks support for a new Mozilla technology to bridge the C and JavaScript languages -- even though Google has competing ideas.

Stephen Shankland Former Principal Writer
Stephen Shankland worked at CNET from 1998 to 2024 and wrote about processors, digital photography, AI, quantum computing, computer science, materials science, supercomputers, drones, browsers, 3D printing, USB, and new computing technology in general. He has a soft spot in his heart for standards groups and I/O interfaces. His first big scoop was about radioactive cat poop.
Expertise Processors | Semiconductors | Web browsers | Quantum computing | Supercomputers | AI | 3D printing | Drones | Computer science | Physics | Programming | Materials science | USB | UWB | Android | Digital photography | Science Credentials
  • Shankland covered the tech industry for more than 25 years and was a science writer for five years before that. He has deep expertise in microprocessors, digital photography, computer hardware and software, internet standards, web technology, and more.
Stephen Shankland
3 min read
Some low-level benchmarks show ASM.js software outperforming ordinary JavaScript in both Firefox and Chrome, and coming close to the speed of native software.
Some low-level benchmarks show ASM.js software outperforming ordinary JavaScript in both Firefox and Chrome, and coming close to the speed of native software. Alon Zakai/Mozilla

At least some at Google want to embrace a Mozilla-backed project to speed up Web apps written with JavaScript -- even though it competes directly with Google's own Native Client and Dart programming technology.

Mozilla has been working for months on a technology called ASM.js, which it hopes will boost JavaScript performance, especially in combination with a related Mozilla-spawned technology called Emscripten. JavaScript powers Web apps such as Google Docs, and ASM.js is a special "extremely restricted" subset of the programming language that's designed to make it easier for developers to bring existing software written in the C programming language to the Web.

Yesterday, Mozilla held a coming-out party for ASM.js, announcing a cooperation with Epic to bring its Unreal game engine to ASM.js. The same day, Google effectively announced a plan to support it within Chrome's V8 engine that processes JavaScript.

"Optimizations should be added to V8 to generate good code for the ASM.js subset of JavaScript," Chrome programmer Kenneth Russell said in a Chrome feature-tracking item for ASM.js. "The implementation cost should be small compared to the potential upside -- the ability to run significant existing code bases with close to the speed of C inside the JavaScript engine."

Securing support from other browser makers is crucial to the success of a programming technology. Without that support, programmers can only target a single browser, which undermines the advantages of universality that the Web can offer.

Google didn't respond to a request for comment about its position on the matter.

Browser makers often ally to bring a new technology to market and to help coax Web programmers to use it. What's particularly notable about Google's support is that the company already has other competing projects well under way.

Emscripten logo

The C language is often used for programs like streaming-media codecs and video game physics engines, but today's browsers can't use modules written in C unless it's packaged as a browser plug-in. And increasingly, plug-ins are frowned upon because they're inconvenient to install and maintain, a security risk, and sometimes a problem for processor and battery usage.

Thus, Web developers are striking out in new directions such as ASM.js to find better ways to let browsers handle C software.

For Google, it's Native Client (NaCl) and its sibling Portable Native Client (PNaCl). This software runs a restricted set of C instructions, compiled from the original source code using special tools, and runs it in a special protected sandboxed area. C developers must adapt their software for Native Client's restrictions, but Google argues that in many cases the change is very easy, and indeed some games on the Chrome Web Store use Native Client.

Another project, less directly competitive, is a Google programming language called Dart. With it, Google hopes for a better alternative to JavaScript.

Neither NaCl nor Dart, though, has much support outside Google. No other browser makers have shown any enthusiasm for either technology, and in some cases they've been downright hostile, as in the case of Mozilla opposing NaCl and Microsoft bad-mouthing Dart. Adding new programming foundations to the Web is a very big deal, since significant developer adoption means that all browsers forever must support that foundation alongside others. And as a technical matter, supporting multiple programming foundations running simultaneously is fraught with technical complexities.

Google hopes that with NaCl, it can get browser-executed software downloaded over the Net to run with performance that's within a few percentage points of native code. Mozilla's Emscripten and ASM.js projects promise nothing close to that -- but also don't require a profound rewrite of the Web programming stack.

"It's early to say, but our preliminary benchmarks of C programs compiled to ASM.js are usually within a factor of 2 slowdown over native compilation with clang," the ASM.js FAQ says.

A compiler's job is to change software written by humans in a high-level programming language into the lower-level software a computer can understand. In the case of Emscripten, it compiles C only to ASM.js JavaScript, and the browser itself handles conversion of that software into the truly native instructions for a processor to execute. By using ASM.js, though, Mozilla expects to have much higher performance than with the ordinary, broader set of JavaScript instructions.