19 Oct 2018
web assembly

WebAssembly

Since the dawn of time, native applications have always delivered a larger-than-life performance compared to web applications. Any web application could never enable or scale to the full functionality of the device expected from apps like games, multi-media intensive apps, high data processing apps, etc. JavaScript wasn’t designed to be fast for very large applications.

WebAssembly (or Wasm) is a binary instruction format for a stack-based virtual machine.” Wasm is a portable platform to compile high-level languages like C & C++ to be deployed on the web. The code will execute at speeds previously achieved by assembly programs. Web assembly doesn’t replace the way the web works; JavaScript will not be replaced, but rather an improvement to it.

Wasm is aimed to be efficient & fast. Web assembly includes a stack machine that encodes the code in load-time efficient binary format. This allows it to achieve native speeds. Web assembly is a sandboxed environment that guarantees safety of your device. It also will not allow cross-origin that makes the device vulnerable.

Wasm is built as a binary format. It’s very compact to download and also very efficient to compile & execute. Wasm enables speed in 2 areas; first in app start-up speed (2x or more) and secondly in throughput (compiled code runs faster). With Web assembly, we can now have real 64-bit integer data type, more control over memory management & smooth performance throughout the application.

With Wasm, developers across spectrums can bring their native C or C++ applications to the web & reach efficient performance capabilities of the device. This in-turn means no downloads, malwares, etc. as there is no need for installation on the device.

Implementing Wasm in our web project is a sequence of simple tasks:

  • Write source code in your preferred high-level language (C, C++, Rust)
  • Compile it into WebAssembly (will output a .wasm file)
  • Include this .wasm in your web project
  • Write Async JavaScript code in your web project to compile & execute the .wasm

Wasm is a revolutionary technology. It’s community keeps improving and adding new features at alarming speeds. Wasm is not the only technology of such nature; but it is the one backed by W3C and major company like Microsoft, Google, Apple, etc. Only time will tell what is in store for the future.

Sonal Naik

Post Comments

* marked fields are mandatory.