There has been a lot of talk about WebAssembly lately. But what is it really?
In this article we will have a look at the technology and the benefits it brings for developers.
What is WebAssembly?
WebAssembly (or Wasm, for short) is set of open web standards that define a portable binary format for a stack-based execution environment (a Virtual Machine, or VM). It is analogous to the Java Bytecode, or CIL/MSIL of .NET.
Still being worked on, for another iteration of the standard, is support for threading and garabage collection (GC). That is expected to be finalized in the near future.
There is a system interface, called WASI that serves as a interface for the host platform.
All modern web browsers support WebAssembly. When targeting older browsers, like for example Internet Explorer, it can be easily polyfilled using ASM.js.
The simplest and most clearest reason for targeting WebAssembly involves some existing C/C++ code that you want to leverage in your web app.
To compile that code you would use Emscripten. The project provides a LLVM backend for WebAssembly that also will generate the necessary glue code.
There are many other languages and platforms targeting WebAssembly. Rust is one of them that directly targets WebAssembly.
Microsoft is developing a client-side web component framework, called Blazor, written in C#. It is running on Mono, on WebAssembly, in the browser.
You will find an extensive list of use cases here.
Not only for the Web
The WebAssembly ecosystem is being developed in the open. This shows how much effort and investment is going into it as a platform.
What about NodeJS?
WebAssembly will greatly benefit those projects that have a dependency on native addons. Avoiding all of the hassle having to target each platform and architecture (Linux, MacOS, Windows etc), the C/C++ code will simply be compiled into WebAssembly instead.
WebAssembly is a new open and standardized way for other languages to target not just Web but many platforms.
It will be interesting to see what the future will bring to this new platform.