What is WebAssembly?

and why is it important?

A Pragmatic WebAssembly FAQ

WebAssembly is intuitive to grasp but difficult to assess, even for experienced technologists. This FAQ breaks down one question — “What is WebAssembly” — into its immediate followups to help you understand if it’s a technology you should be following.

This is not a technical FAQ, but scroll to the bottom for more technical links.

What is WebAssembly?

WebAssembly is an open standard for cross-platform executables. At a high level, it’s similar in spirit to Java bytecode. The difference is that WebAssembly was a browser-first initiative. As browsers implemented the MVP, WebAssembly became the only other executable format to run standard on web pages since JavaScript was released in 1995.

Why is WebAssembly important?

While WebAssembly was created by web experts and adding an additional execution environment to web browsers is monumental, its implications reach far beyond the browser.

The web is a distinctly hostile environment. Any web feature must accommodate unique security and privacy concerns, must not impact performance on a wide range of resource-limited clients, and must be backwards compatible with every site built over the last twenty-five years. This adversity affects how ideas evolve and forces considerations that could be ignored otherwise.

The web’s unique problems were not insurmountable. Companies offered solutions since the days of Java applets, all the way to Adobe Flash and Microsoft ActiveX. The crux is that these were proprietary. They only existed as opt-in plugins. The web is built on open standards and to become part of a web browser, a committee must agree on a single technology and its implementation.

What you get when you need to please everyone is a minuscule implementation that does the bare minimum. While unintuitive, this is why WebAssembly is important. The bare minimum is a foundation of 25 years of web security, performance, and distributed application lessons. The WebAssembly MVP is difficult-to-use but it has a rock solid foundation. What little it does now, it does well and can only improve.

If I don’t target the web, should I care about WebAssembly?

WebAssembly has a large fan base among systems programmers and is gaining traction in every community, not just web developers. Despite the potential, WebAssembly does come with risks. The developer experience is poor and developer tooling is sparse and fragmented. Developers who can compile and execute WebAssembly at all are uncommon and architects who understand how WebAssembly fits in to a bigger picture are even more rare. Companies like Fastly, Figma, and CloudFlare are taking advantage of WebAssembly but have had their share of headaches along the way. WebAssembly is squarely in the Early Adopter or even the Innovator phase of the adoption curve.

Adoption curve

If you generally wait until a technology has proven itself before using it, take comfort that you will benefit from WebAssembly via your tooling before you need to work with it directly. Similarly, if you are evaluating services and vendors, their stance on WebAssembly is a good indicator of how much they are investing in the future.

My engineers tell me WebAssembly is not ready, what’s the deal?

We’ve seen most of the confusion stem from two specific topics: WASI and WebAssembly’s data types. The former commonly manifests as comments like “WebAssembly can’t do anything yet” and the latter as “WebAssembly is only for math-heavy computation.”

The WebAssembly System Interface, or WASI, is a project to define a consistent, cross-platform interface to operating system functionality. WebAssembly can only compute by default. It can’t read files, make network requests, or “do anything yet.” WASI gives WebAssembly native-like functionality. WASI is a work in progress but even without WASI, a host environment can still expose arbitrary native functionality to WebAssembly modules. WASI is a community standard. It is not a gating factor to real-world WebAssembly usage.

The other point of contention stems from web development teams who most often work with languages like JavaScript, Ruby, and Java. Web development frequently involves manipulating and concatenating strings, and WebAssembly only has four numeric data types. You can’t natively store strings at all. Everything from printing “Hello world” to parsing HTML or JSON looks either impossible or impractical. Modern tooling has addressed this and tools like waPC and wasm-bindgen erase the complexity of dealing with complex data types.

Will WebAssembly replace JavaScript?

The short answer is: no. The long answer is: JavaScript has already been replaced.

Browser JavaScript will always exist and continue to improve. The web platform can’t remove features without great consideration and JavaScript is too ubiquitous to consider. WebAssembly is less capable than JavaScript in the browser and will remain that way for years. You can’t even run WebAssembly without JavaScript in the first place.

However, this question isn’t as straightforward as it appears. No, WebAssembly will never replace JavaScript, but very few people today write JavaScript that browsers actually execute. All modern web development funnels through a build process that compiles, optimizes, and otherwise transforms a source language into the final JavaScript bundle browsers run. The source language can be anything. The two most common sources are some modern flavor of JavaScript and TypeScript, a JavaScript-like language that adds language typing. Even if we write JavaScript, we still compile it down to JavaScript. The question for the future is “what will compile best?”

Modern developer JavaScript and TypeScript will evolve the same way they do now without any change. If you want to bet on the “Next Big Thing,” it doesn’t yet exist. Written JavaScript will continue to decline. TypeScript usage will continue to increase. What succeeds them both in the browser will be something that blends the optimizability of a heavily typed language and the iteration speed of a dynamic language.

Where can I find technical details?

WebAssembly.org is a great place to start. Check out their technical FAQ and developer guide. The technical specification is available on w3.org.