WebAssembly (Wasm) is a virtual instruction set architecture (ISA) that can run at near-native speeds. One of the great benefits of Wasm is that it provides its own built-in isolation to keep systems secure.
So what does this mean? It means that developers can code a program in any source language that can be compiled to WebAssembly (or, for interpreted languages like JavaScript, where the interpreter can be compiled to WebAssembly). These compiled binaries can then be run in a secure way across many different kinds of systems.
Because WebAssembly is not tied to any specific programming language, there are many advantages for developers, including:
Greater flexibility in choosing a language that best supports the application they are building.
Aligning language choice with developer expertise. This is great in organizations with multiple developer teams and where the proficiency in certain languages varies across teams.
Ability to reuse existing code bases written in different programming languages and compile them to WebAssembly.
Access to an ecosystem of diverse tools, libraries and frameworks. Even better, there are community-driven initiatives and open-source projects that contribute to the continual growth of the ecosystem, to provide developers with more resources and options.
WebAssembly was originally developed for web browser applications, so that people could run performance-critical code or heavy workloads like image editing programs and video games in the browser. Before long though, developers were seeing just how useful WebAssembly is outside of the browser. For example, WebAssembly is increasingly being used for server-side development.
In addition to the benefits listed above, developers using WebAssembly outside of the browser enjoy:
Greater performance - WebAssembly can compile directly to machine code. This makes it an easy choice for developers building applications or running workloads that require fast execution.
Greater security - WebAssembly runtimes often enforce sandboxing which isolates the WebAssembly modules and prevents them from interfering with other programs or from accessing sensitive system resources. In addition WebAssembly modules have limited control over memory which makes it difficult for them to corrupt data or cause memory leaks.
You can think of a runtime as an engine that runs WebAssembly code. It interprets or translates the code into something a computer or server can understand. There are many runtimes available today, each having different strengths and supporting different use cases. Below are a few of the more popular options:
Wasmtime: Wasmtime is an open-source, high-performance, secure runtime created by the Bytecode Alliance. Wasmtime is compliant with WASI (WebAssembly System Interface) which defines a standard for running Wasm modules outside of the browser. Wasmtime supports multiple programming languages and is suitable for a wide range of use cases.
Browser runtimes: As the name suggests, these runtimes are designed to work within the web browser. Examples of runtimes that work in browsers include V8, a JavaScript and WebAssembly engine used in Google Chrome; and SpiderMonkey, which is also a JavaScript and WebAssembly engine, and is used in Mozilla Firefox.
Fastly laid the foundation for our edge platform through early work with WebAssembly and the Bytecode Alliance. Fastly's Compute platform runs WebAssembly programs, which are compiled from other languages such as Rust, JavaScript and Go. Building on WebAssembly (Wasm) supports our commitment to an open source standard that fosters collaboration. An example of this collaboration is Wasmtime, a fast and secure runtime for WebAssembly. At Fastly, we believe that having a WebAssembly foundation will greatly benefit our compute offering over time as we work with other ByteCode Alliance members to build a more secure, performant compute ecosystem that uses common standards.
Get started with Fastly Compute today and learn more on our developer hub. Also, check out this awesome video from Lin Clark, Senior Principal Engineer at Fastly and co-founder of the Bytecode Alliance, to learn about the future of WebAssembly at Fastly.