There have been critical moments in web history that fundamentally changed how applications are built. Starting with the birth of the World Wide Web in the early ’90s, the Netscape Navigator browser, and the assembly language of the web: JavaScript. In the early 2000s, the next set of critical components, XMLHttpRequest and AJAX started taking off. For the last 15-plus years , HTML, CSS, JavaScript, and AJAX have been the cornerstones of web applications. While none of these technologies will be going away tomorrow, a new, emerging technology, WebAssembly, will soon become a new cornerstone for building modern web applications.
So what is WebAssembly?
WebAssembly (WASM) is a W3C standard (W3C WebAssembly Working Group), which will let code from many languages (C/C++, Rust, .Net C#, etc.) be run at near-native speed in a web browser, server, or other container that supports the WASM runtime. The magic behind WebAssembly is the compiling of language-specific code (e.g., C#) into a WebAssembly module. The resulting WebAssembly module can then be loaded and executed in a browser. All modern web browsers include the ability to download and execute WebAssembly byte code. Today, browsers rely on a JavaScript interop layer to allow code written in WebAssembly to interact with UI (DOM) or other standard web APIs (e.g., Local Storage). As the WebAssembly standard continues to evolve, this requirement may change. Either way, WebAssembly has been designed to coexist with JavaScript, and developers can expect to utilize both moving forward.
Why do we need WebAssembly?
Good question. The #1 answer is speed. WebAssembly has been designed from the ground up for speed. Compared to text-based JavaScript files, the binary WASM generated from the WebAssembly compiler are smaller to download, decode, and execute. At runtime, WebAssembly offers better performance than JavaScript because it is statically typed—versus the dynamic nature of JavaScript—and memory is managed manually instead of relying on the browser’s JavaScript garbage collector. Portability is another critical component of WebAssembly. A compiled WASM file can be hosted in any browser, server, mobile or IoT device that supports a WebAssembly Virtual Machine (VM). From a developer perspective, there’s one more selling point: the ability to use your favorite language (C/C++, C#, Rust, etc.) to build web applications. This opens a whole new world by allowing developers to utilize a single language for both client (browser) and server; it also allows developers to build high-performance libraries that can be used across many platforms. In fact, one of the earlier adopters of WebAssembly are game engines like Unity that need to support a multitude of devices.
What do you need to start using WebAssembly today?
Even though WebAssembly is a new emerging technology, several vendors such as Microsoft and Mozilla have already built production ready WebAssembly compilers and frameworks:
Microsoft’s new Blazor Framework is a compelling technology that goes beyond just a compiler for C# to WebAssembly. Blazor allows ASP.NET developers to use the popular ASP.NET Razor syntax and Microsoft Visual Studio 2019 to build rich interactive web applications similar to what developers can build in Angular or React. As a developer, I am excited about the prospects for WebAssembly and Microsoft Blazor framework to become a keystone of web development over the next few years. So, pick your favorite language, download its WebAssembly compiler, and start riding the wave for the future of web development. Lastly, if your organization has any questions around WebAssembly or any other coding language, please don’t hesitate to reach out to us. We’d love to help you out.