Web Assembly – The dawn of a new era


WebAssembly or wasm is an experimental efficient low-level programming language for in-browser client-side scripting, which is currently in development. Its initial aim is to support compilation from C/C++, though other source languages are also intended to be supported. The project is jointly developed by Google, Microsoft, Mozilla, and a few others. The name WebAssembly was coined last year which led to the formation of the Web Assembly community group to help it evolve as a web standard. Browser makers like Mozilla, Google, and Microsoft have come up with own versions of the experimental previews.

What is Web Assembly?

WebAssembly is:

  • An improvement to JavaScript: Implement your performance critical stuff in Web Assembly and import it like a standard JavaScript module.
  • A browser improvement: Browsers will understand the binary format, which means we’ll be able to compile binary bundles that compress smaller than the text JavaScript we use today. Smaller payloads mean faster delivery. Depending on compile-time optimization opportunities, WebAssembly bundles may run faster than JavaScript, too!
  • A Compile Target: A way for other languages to get first-class binary support across the entire web platform stack.

Web Assembly previews in Chrome, Edge and Firefox

- Advertisement -

The three browser makers Google, Microsoft, and Mozilla have come up with their very own iterations of the WebAssembly language. As far as Microsoft is concerned, they’ve come with an experimental implementation in an internal build of Microsoft Edge browser. “Our implementation is able to reuse much of the existing asm.js infrastructure. The WebAssembly code goes through the same pipeline as the asm.js code would after it has been parsed,” said the program manager for the Chakra javascript engine, Limin Zhu.

Google has used Chromium open-source browser and the V8 Javascript engine to provide experimental support for the cross-browser language. According to a blog post by Seth Thompson, Google’s V8 implementation has been designed to reuse much of the existing javascript virtual machine infrastructure.

“A specialized WebAssembly decoder validates modules by checking types, local variable indices, function references, return values, and control flow structure in a single pass,” wrote Thompson. The decoder produces a TurboFan graph which is processed by various optimization passes and finally turned into machine code by the same backend which generates machine code for optimized JavaScript and asm.js.

Mozilla, the minds behind the newly coded Servo browser, eyes an addition of this new binary format in their browser developer tools. “Fortunately, the JavaScript, Developer Tools and Firebug teams worked together to move tools over to a new, abstract, unit-testable Debugger API which we’ll be implementing for WebAssembly code,” writes Luke Wagner who is a research engineer and hacks on WebAssembly and asm.js in Mozilla’s JavaScript engine.

A working demo is available on Github which you can only use if you’re using a Chrome Canary, Firefox Nightly, or a preview build of Microsoft Edge.

- Advertisement -