WebAssembly (WASM) is a new assembly-like language on the web that aims to allow developers to write fast, portable code in the language of their choice. It is currently usable in all modern browsers and Node.js, and some WebAssembly only runtimes.
Another performance problem with WebAssembly is the high overhead for calling web APIs from WebAssembly. Mozilla has optimized this, but Chrome and Node.js still have this problem. However, WebAssembly performance is improving, and eventually, it might even be possible to get native performance with WebAssembly.
Widespread WebAssembly adoption is still far away, but it is making progress. Now we will look at the state of WebAssembly in web browsers, on servers, and the best languages to use.
If you are trying to create a complete web application using WebAssembly, the easiest way to do that as of now is using Rust and a framework such as Yew with Trunk. However, because of the small ecosystem, WebAssembly is currently best for small performance focused parts of an application rather than whole applications.
WebAssembly on the server is quickly growing. WebAssembly offers ultralight isolation, which makes it great for serverless functions because serverless functions need to start rapidly and have a low footprint. For an example of how this works, let's look at how one of the most popular serverless function services, Cloudflare Workers, operates.
Cloudflare Workers executes serverless functions using V8 isolates rather than containers in separate processes. V8 isolates are lightweight V8 execution environments that start-up significantly faster than traditional sandboxed environments.
As you can see, WebAssembly is an excellent choice for servers due to how it can execute in a lightweight, secure environment. If you want to look at benchmarks including Cloudflare Workers to show the speed improvements of isolates, here are some.
WebAssembly is still new to the world of the web. However, it is already finding a place in lightweight serverless function execution. I hope you have learned something from this, and this wraps up the first article in State of the Web. Thanks for reading!