Skip to main content

Web Assembly in Action

· 3 min read
Bryan Flood

Its crazy to think that an idea can go from a mock book cover to an international standard.

With the introduction of WebAssembly we have truly game changing technology on our hands.

WASM is a cross platform IR/assembly language that higher level languages can target.

It was announced in 2015 and was first supported by all browsers as a minimum viable product in 2017.

Since then the tooling and support around it has improved drastically.

It's biggest selling point is that it allows legacy code to be easily ported to run on the web.

Many companies have started experimenting with the technology to create new and improved web applications.

Some of the Uses#

  • AutoCAD which has a 35 year old code base was able to be ported to the web using WASM

  • Tensorflow JS was created before WASM and had to be a complete rewrite to work on the web. A WASM back end has just been added which should allow for code sharing and major performance improvements

  • The Uno platform allows you to use a single C# and XAML code base to build apps for iOS, Android, Windows and the Web

  • The Windows Calculator App is a great example of UNO in action

  • One lone developer managed to port DOOM 3 using the technology in his spare time here DOOM 3 running in browser

  • QT, Unreal and Unity now support WASM

My experience#

WASM has provided more free reign in how I develop applications.

Two of my favourite languages Rust and C++ have some of the best support allowing me to use them on any platform.

Although no where near performant as native code you still get some of the benefits like threading support through web workers and SIMD which helps it perform better than JS.

Cross Platform Image Processing#

I'm currently working on an application that allows you to interactively work with and get insights from images from any device.

I'm using OpenCV as a static WASM library that I build daily using the following docker image OpenCV Static WASM Library Docker.

As part of my build system I can compile my code to both WASM and whatever native platform I'm using (Linux, macOS, Windows).

Without WASM this application would not be feasible.

Challenges#

A recent study showed that "56%, the majority of all WebAssembly usage in the Alexa Top 1 million is for malicious purposes".

So go out and try and change this.