WebAssembly may go live in browsers this year

The portable code format promises to bring native speed to Web apps

WebAssembly may go live in browsers this year
Stephen Sauer

The WebAssembly project to improve the Web's performance now has experimental implementations in place for major browsers. Developers also are advancing the design of the binary format that serves as the technology's linchpin.

In fact, WebAssembly could be ready this year on several browsers.

First detailed last June, WebAssembly features a portable code format to run safely in browsers at native speeds. "It's designed to be efficient for browsers to download, decode, and compile, and it runs fast by taking advantage of common, widely available hardware capabilities," said Luke Wagner, a programmer at Mozilla. He has served as a co-chairman in the World Wide Web Consortium community group overseeing WebAssembly. Google, Mozilla, Microsoft, and Apple all have participated in the development process.

"There are experimental WebAssembly implementations for Firefox, Edge, Safari, and Chrome," said Wagner. "In the coming months, we expect to see enough progress and convergence to release demos of large, realistic applications that will run on the prerelease channels of multiple browsers."

"A user can compile a program of a high-level language to WebAssembly and run it in a browser," said B. Abhijith Chatra, a senior software engineer at Microsoft and a co-chairman of the community group. "As a first step, in the minimal viable product, the goal is to ensure that a C/C++ program can be compiled to WebAssembly and run within the browser."

While awaiting native browser support, WebAssembly developers are building tools to translate it to the asm.js subset of JavaScript, making it possible to use WebAssembly even in browsers that do not yet support it, Wagner said.

WebAssembly will feature a memory-safe, sandboxed execution environment. It would access browser functionality through the same Web APIs accessible from JavaScript.

The project's developers envision using WebAssembly for porting large applications to the Web and for implementing performance-sensitive kernels of Web frameworks or computationally intensive tasks like computer vision or media processing. They also want it to enable other programming languages to compile efficiently to the Web.

JavaScript developer and author Eric Elliott sees WebAssembly helping with development of video, audio, and games for the Web. "That kind of thing is clearly pretty hard to do with JavaScript right now mostly because of the payloads involved," he noted. A lot of source code is required -- payloads on the order of 20MB for a small game can be required, but WebAssembly has the potential to eliminate this problem, Elliott said.

Currently, JavaScript requires downloads of compressed text that have to be uncompressed inside the browser, then parsed into an abstract syntax tree (AST), which helps the computer understand the text and what it means semantically, Elliott said. "WebAssembly bypasses all that because it actually is a binary AST format by default," he said. "It gets compiled to binary AST from languages like C or C++.... It's really going to help the performance of the Web."

Developers are already compiling to JavaScript with other languages and using asm.js as the bridge, Elliott noted.

Despite those efforts, WebAssembly remains very much a work in progress. Developers need to experiment with browser implementations and provide feedback before the specification is finished, Wagner said. Also, the community group has to finish the spec and deal with a "steadily shrinking" set of questions, he said. In addition, the conformance test suite must be expanded to cover the entire specification.

Copyright © 2016 IDG Communications, Inc.