WebAssembly: Web from a new perspective
Google, Microsoft, Apple and Mozilla are holding their hands together to build a new bytecode execution environment to the web, named "WebAssembly" or "wasm" in short. These companies have their own browsers, javascript runtime, and they spent much time on improving their performance to deliver a clutter free browsing experience to the customers. However, the performance of the javascript engines are undeniably good, still the world is not satisfied with it. For example, WebGL is a good interface to build high end games and graphics that runs in your browser, but the complicated physics simulation and game logic are not satisfied with the performance of javascript. The worst case is the open-source nature of javascript prevents the corporate tech giants to port their world to the web. One can minify javascript, replace all signatures to arbitrary values, that makes them less readable. But that doesn't makes it to give high performance, because computers are more efficient to interpret bytecodes, than human-readable scripts.

Web before WebAssembly

However, attempts are made to improve the performance beyond the javascript engine. Best one of them is asm.js. It is an extraordinarily optimizable, low-level subset of JavaScript. The main source of performance fall in javascript is the weak typing that may tend to change the datatype during computations, because the datatype of a variable is assigned based on the value returned from the assignment, expression or from a function. asm.js avoids these weak typed variables, it uses typed arrays that improves performance. It also restricts the variables from changing data types, which ensures type safety and memory safety. The reason why apps made in C and C++ outperforms the same implemented in javascript is, C and C++ are strong typed languages, so the runtime doesn't need to check the data types. Secondly, they are compiled to native code, which runs faster than anything.

The approach before the WebAssembly environment concept is compile-to-javascript, because javascript is the only language that the web browsers understand, and it is widely accepted in all kind of browsers, seamlessly. The best example of javascript compiler is Emscripten. Emscripten is an LLVM-based project that compiles C and C++ into highly-optimizable JavaScript in asm.js format. This approach will manage the performance greater than the hand written javascript code, but it is still less than the native performance.


Preliminary tests shows that WebAssembly bytecode is around 20 times faster, and file size is 20 - 30 percent smaller than JavaScript code. Currently no browsers are supported for this WebAssembly bytecodes. By the time when WebAssembly is a web standard, we can expect more responsive and high end games, commercial or closed source applications takes over the web, powerful graphics/video editors, realtime graphical effects and so on. And WebAssembly will be expected to give smoother browser experience in mobile phones, and better battery life too.

The reason why Mozilla wants this feature as a Web standard is they want to provide native support to their Firefox OS platform. Currently it is lacking native code support so there's no scope for high performance apps and games in Firefox OS. Google also introduced native code support in their ChromeOS as NaCl, but it is not a web standard and Google doesn't even tried to standardise it. If WebAssembly is nicely tied up with JavaScript, it will be very helpful to NodeJS and IO.JS to improve their serving performance.

Read more on ArsTechnica