WebAssembly: The 4th Official Language of the Web

Insights on a new, powerful tool

By Shaun Walker, Technical Director and Enterprise Guildmaster, Cognizant Softvision

It can be argued that the web and browser ecosystem is the most powerful and universal technology platform available today. And the number of web technologies to choose from these days is enormous.

Regardless of the modern languages and frameworks you choose, the end result is always the same… they all boil down to a combination of three essential ingredients: HTML, CSS and JavaScript. These are the three basic building blocks a web browser relies upon to generate the diverse range of awe-inspiring websites and web applications we see today. This has been true since the 1990’s and continues to be true today.

That being said, the demands of modern web experiences, particularly the requirements for performance and scalability, are pushing these technologies to their limits. So it should be no surprise that software developers have been searching for a holy grail, a new, cross-platform technology that offers near-native speed, is highly secure, requires zero configuration, and can be easily integrated into a wide variety of development platforms.

Technological innovations of this magnitude do not happen overnight. They take time to evolve and require a number of iterations to reach a state of industry acceptance and maturity that will lead to mass adoption. WebAssembly has emerged as the new kid on the block, offering superior performance, security, and portability. With such a powerful set of capabilities it makes complete sense why WebAssembly is now being positioned as the 4th official language of the web.

WebAssembly — The Background

Back in the mid-90’s, when we were in the early stages of the web, the Internet was still in its infancy and dial-up speeds were the norm. As a result, applications had to be architected to limit their dependency on the network and focus the workload on devices such as desktops and laptops. This required the creation of client-side applications, resulting in the emergence of new client-side technologies such as Javascript, Macromedia Flash, Sun Java applets, VBScript, and Microsoft ActiveX, all of which could be used to build applications which ran in the web browser. These were very popular and fairly impressive technologies for their time, and successfully satisfied the needs of stakeholders for more than a decade.

Jumping ahead to the 2000s, Flex was introduced as a successor of sorts to Flash, Adobe acquired Macromedia, and Microsoft introduced Silverlight. These technologies provided robust capabilities for developing client-side applications and were widely marketed as Rich Internet Application development platforms. However in 2010, Steve Jobs published his now infamous open letter “Thoughts on Flash.” The letter criticized the Flash platform and outlined reasons why the technology would not be allowed on Apple’s iOS hardware products, with security identified as the main area of concern. This letter proved to be a pivotal turning point in the industry and was the death knell for all client-side technologies which relied on browser-based plug-ins. The only client-side technology which survived was JavaScript, due to the fact it was natively integrated with all major browsers.

However JavaScript was never designed to satisfy the needs of every client-side application. Applications such as video games place much higher demands on client-side capabilities and performance, requiring different technology solutions. In 2010, Emscripten was founded and allowed developers to compile C/C++ code to Javascript which could run across all browsers. Google followed up with Native Client (NaCl) in 2011, a sandboxing technology for running native code in a browser, independent of the user operating system. In 2013, Mozilla rolled out asm.js, a strict subset of JavaScript that could be used as a low-level, efficient target language for compilers such as emscripten and LLVM. These technologies played a part in laying the groundwork for what would eventually evolve into WebAssembly.

WebAssembly — The Beginning

Mozilla continued its development of asm.js, and also continued to explore other techniques with the goal of achieving native speed in the browser. What they eventually came up with was a completely new runtime that lived alongside the JavaScript virtual machine in the browser. WebAssembly was born and it was first previewed in Firefox 22 in 2015. WebAssembly had several advantages over asm.js as it could be directly translated to native instructions, was more compact, and was not constrained by the limitations of the JavaScript language.

These advantages were quickly recognized by the broader technology industry. It wasn’t long before Microsoft, Google, and Apple all realized the potential for this technology and collaborated with Mozilla on a standard format. By November 2017, WebAssembly was being shipped in every major modern browser. This is noteworthy because WebAssembly is the first language since JavaScript that is able to run natively in a web browser (without plug-ins).

WebAssembly — Today

In 2019, Mozilla announced the WebAssembly System Interface (WASI) with the goal of standardizing how WebAssembly code interacts with operating systems outside of a browser context. Because WebAssembly is cross-platform, compiled binaries are able to run both inside and outside browsers, across different devices and operating systems, at near-native speeds.

Also in 2019, the ByteCode Alliance was formed by Mozilla, Microsoft, Google, Intel, and Fastly. It is a nonprofit organization dedicated to the ongoing development of WebAssembly and WASI. And in December 2019, the World Wide Web Consortium (W3C) announced that V1 of the WebAssembly Core Specification had become an official web standard.

WebAssembly — A Definition

So what exactly is WebAssembly? Well in technical terms, it’s “a binary instruction format for a stack-based virtual machine.” Since that includes a lot of technical jargon, let’s break it down by each section:

1. Binary instructions — binary encodings of the types of operations which can be executed by a virtual machine

2. Stack based — binary instructions manipulate values on a stack (push/pop)

3. Virtual Machine — a processor whose purpose is to compile code to real architectures, with portability in mind

And while these concepts are somewhat primitive and simple, it’s the application of them in WebAssembly that makes it new and exciting. Plus, there is extensive industry adoption already so you can write your source code in almost any language ( ie. .NET, Python, Perl, Go, Java, Rust, Ruby, etc… ) and then compile it to WebAssembly which will run natively within the browser.

WebAssembly — The Benefits

There are many benefits offered by WebAssembly but the four most popular are its portability, openness, security, and support for multiple languages (polyglotism). And we definitely cannot overemphasize the benefit of its near-native performance. Essentially, WebAssembly is a precompiled form of Javascript which the browser can interpret directly without requiring any parsing or compilation. This results in a very significant performance boost for your web applications.

Conclusion

WebAssembly is a technology that everyone should be watching with great interest. Some people are even going out on a limb and predicting that it will replace JavaScript in the future. I think it is much more likely that WebAssembly will become an essential but complementary tool for all forms of software development including web, mobile, and desktop.

In comparison to other technologies, WebAssembly is still relatively new. It still has plenty of room to grow, and continues to gain momentum and adoption. It is not unreasonable to imagine that five years from now, WebAssembly-based frameworks will be just as common as React, Angular, and Vue are today. And if this prediction comes true, WebAssembly will certainly be worthy of the title of “4th official language of the web.”

Shaun Walker shared his insights on WebAssembly at Programmers’ Week 2021, Cognizant Softvision’s week-long event for developers and software engineers from around the world. Watch his presentation here.

Get more insights from our engineering and design experts on our website!

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store