My personal notes for WebAssembly

A talk by Cody Owens I attended at DeveloperWeek 2019

WebAssembly is supported on all major browsers as of November 2017. Node 8+ also supports WebAssembly.

This enabled new kinds of real-time work in the browser.

You'll pay a performance penalty if you switch back and forth between WebAssembly and JavaScript a lot.

WebAssembly also elegantly handles crashes and errors. It treats them like a standard console error.

How It Works

Under the hood, WebAssembly memory is just a JavaScript ArrayBuffer. This means you can poke around with the memory directly from JavaScript. This also helps isolate application memory, because the process can't exit the array buffer.

There is no file system with WebAssembly. However, there's a tool called Emscripten, which is a virtual Unit-like file system API.

You can use WASM inside of web workers to offload CPU-intensive tasks to prevent blocking the UI. For now, Emscripten will do this automatically for you.

Porting Existing Libraries

What's most exciting is you can take existing libraries from other languages and compile them to work in the browser. This allows you to incorporate libraries from other languages without much effort.