This first appeared on my Medium blog
As detailed in this LinkedIn post, 2022 is going to be my year of diving into the world of WebAssembly and Rust. With an overwhelming amount of people opting for blog content over other media, here’s the first one in, what I hope will be, a series of posts covering the aforementioned topics.
Although this has been covered in various formats across the internet, I believe any content about a new technology or tool should start with the motivations behind its inception. To understand why there was a requirement for WebAssembly, let’s take a not-so-quick stroll down memory lane.
The world wide web, as we know it today, started off as a single page project on a NeXT computer at CERN. You can still view it here. The page was a simple static page written in HTML and contained links to the project and a few other technical details. The motivation behind this project was to enable information sharing between academics via a document exchange network.
However, the concerns with speed were not only limited to the convoluted process to get there. For more challenging applications where performance is a critical factor, the lack of consistency/predictability in the levels of performance was a significant obstacle.
Quoting Mozilla docs,
Building upon the experience from asm.js, all major browsers worked towards designing a new format for the Web with one of the end goals being speed and efficiency.
WebAssembly, abbreviated Wasm, was designed to be a portable compilation target for programming languages, enabling deployment on the web for client and server applications.
So what exactly is WebAssembly? It is a binary instruction format for stack based machines. Here’s a partial snippet of how a simple “Hello world” program looks like in Wasm.
Contrast that with how a typical WebAssembly flow looks like.
There’s not only a marked difference in the amount of time being spent on account of it being closer to the machine code, but there is also an elimination of certain steps altogether. This obviously leads to better performances in comparison for most cases but not all, since WebAssembly is still in its nascent stages (the MVP was completed in 2017).
So that’s it for this post! Here’s a list of resources that helped me along the way while learning,
- The Mozilla Hacks blog
- This free course by The Linux Foundation on edX
- The sessionstack blog
- CERN webpage
- MDN Web Docs