TheSharperDev

Posts about C# and F#

A Brief Overview of WebAssembly

What is WebAssembly?

WebAssembly (abbreviated Wasm) is a binary instruction format for a stack-based virtual machine. Wasm is designed as a portable compilation target for programming languages, enabling deployment on the web for client and server applications. ~ https://webassembly.org/

There you go, post over.

Jk.

JavaScript History

For a long time, JavaScript was the web lingua franca. Every browser supported it. If you wanted to do something interact in a website, you use JavaScript.

(I’m ignoring flash, Java Applets and Microsoft Silverlight for, reasons)

Over the past 15 years, that has led to an increasing number of languages targeting JavaScript. CoffeeScript, TypeScript, Dart, F#/Fable, Elm, PureScript…

Basically, we don’t like JavaScript enough to program in it, but we want it to run everyone so we’ll compile down to it.

The thing is, JavaScript has it’s flaws, so wasn’t really an ideal compilation target. Yes it worked, but there was room for improvement.

That’s where WebAssembly steps in.

WebAssembly

WebAssembly aims to be a faster, easier to verify and safer alternative compilation target. There is thought and attention given to it’s architecting and implementation.

Having this performant and unified technology opens up massive new opportunities for how we interact with technology.

AutoCad, software that’s over 35 years old, can now run in your browser at near native performance due to WebAssembly.

Any programming language compiling to WebAssembly (C, Rust, Go, JavaScript, etc) can now interact in fast and supported ways.

Could programming languages now target WebAssembly directly instead of the CPU + Operating System pairs we currently do? And everything still runs fast?

The WebAssembly Promise

That’s the promise of WebAssembly.

One tech to rule them all, one tech to find them,
one tech to bring them all, and in the browser bind them.

I’m currently exploring a programming language that only targets WebAssembly. It’s very experimental, but if I target web assembly could I run it anywhere now? Without having to worry about LLVM, cross platform, etc.