WebAssembly Today #9
Updates & commentaries on WebAssembly related technologies, including Rust, serverless, cloud, blockchain, and AI. Focus on the server-side.
Editorial:
This week, we continue to see examples of WebAssembly’s rise on the server-side, and its role in the serverless infrastructure. In parallel, Rust sees more mainstream adoption from big companies and famous projects, such as Microsoft, Facebook, and perhaps even the Linux Kernel!
Learn Rust and get a Raspberry Pi for free. Check out this article for more information!
WebAssembly Today
SSVM, a new Wasm virtual machine for the server-side 👏
The SSVM 0.6.0 version supports WASI to access operating system resources in a controlled manner (ie “capability-based security”). In addition to WASI, the SSVM supports additional, albeit non-standard, WebAssembly extensions to safely access the host system — such as a storage interface for attached key/value storage, an AI inference interface for specialized hardware, and the Ethereum interface for a host blockchain.
For JavaScript developers, SSVM makes it easy to incorporate high-performance Rust functions into Node.js applications.
Use WebAssembly modules from C 🤖
In our previous newsletter, we discuss the idea of “portable C” as the safe universal binary, and the wasm2c toolkit that enables it. This week, we see an example of this in the real world!
Peter Salomonsen wrote an article to demonstrate how to compile WebAssembly modules into C, and then use it. His article comes with an example from the WebAssembly Music Project. It is very interesting.
WebAssembly as lightweight runtime in FaaS infrastructure 👍
This article elaborates there are three major approaches to the serverless FaaS infrastructure, of which is to use application-specific VMs, such as WebAssembly. This approach is emerging and provides a high level of abstraction. The WebAssembly VM can provide a high level "capability-based" security model for accessing system resources (e.g., through the WASI specification) instead of coarsely-grained operating-system-level isolations. WebAssembly on the server-side looks promising.
JavaScript vs WebAssembly 💯
Will WebAssembly replace JavaScript? Whose performance reigns supreme? Alex Fallenstedt shared his performance benchmark on Twitter. It shows that JavaScript is faster when doing a string comparison, and Rust + Wasm is faster with arrays.
It is probably because string manipulation is THE most common task for JavaScript in browser settings. As a result, the C/C++ runtime engines for JavaScript are hyper-optimized for string operations. It is not such the case for numeric operations.
Moral of the story? It is hard to discuss performance in abstract settings. We must judge performance in actual application scenarios.
Machine Learning with Rust and WebAssembly 💻
This article shows how to use Rust crates and server-side WebAssembly to do K-means clustering and visualization. Rust could allow developers to write high-performance machine learning functions, and WebAssembly/SSVM provides runtime safety, code portability, and manageability.
Use WebAssembly to run scikit-learn models? 🖥
WebAssembly is a high-performance runtime for ML/AI applications (in the browser and on the server). In this article, the author describes how they build a WebAssembly runtime for a FaaS service specializing in ML models. The advantages of WebAssembly in ML FaaS include the following.
Ease of use
The WebAssembly model deployments are fast, compared with Docker Container
WebAssembly model deployment has a small memory footprint. WebAssembly model is much smaller than AVM.
The portability of WebAssembly models allows running them on servers, in browsers, or on the edge.
Safe and verifiable
WebAssembly binaries make A/B Test simple
How to Implement Azure Serverless with Blazor WebAssembly 😋
FreeCodeCamp published an article on how to build a rich client application in browsers using WebAssembly, and then build a backend for the app using Azure serverless functions.
Enhancements in Firefox 🦊
Firefox 78 includes a new RegExp evaluator, to meet ECMAScript 2018. It also brings enhanced support for WebAssembly.
Rusty News
A discussion on Linux kernel in-tree Rust support 🦀
In our previous newsletter, we covered the possibility for the Linux Kernel to adopt and support Rust. Since then, an email thread among the Linux core developers shed lights on how Rust could be supported. According to the summary from crabbytag on Reddit:
Nick Desaulniers asks "should we do this?" or "how might we place limits on where this can be used?"
Most people including Greg Koah-Hartmann are interested in attending the discussion
Josh Triplett, rustc developer - I'd be happy to have the Linux kernel feeding into Rust language development priorities. If building Rustic interfaces within the kernel requires some additional language features, we should see what enhancements to the language would best serve those requirements.
Linus Torvalds - I don't want us to be in the situation where any new rust support isn't even build-tested by default.
This email thread has attracted tons of discussions in the Linux and Rust community.
Writing a winning 4K intro in Rust 🌅
A 4k intro is to write an entire scene of a video simulation (including data) in 4096 bytes or less. The intro is written in a combination of Rust and glsl. Glsl is used for rendering a UI on-screen, while Rust does everything else, including world creation, camera and object control, creating instruments and playing music, etc. Check out the demo video!
Microsoft and Facebook released projects written in Rust 🚀
Microsoft releases project Freta, a cloud-scale security vulnerability scanning tool. It is written in Rust!
Facebook releases an internal project which builds a web-based bookmarking tool using Rust.
Moving from TypeScript to Rust/WebAssembly 😎
The Boardgame Lab team decided to switch the engine of Boardgame Lab from TypeScript to Rust. Their rationales are:
WebAssembly is faster than JavaScript and TypeScript
The Rust server is leaner. Rust uses less memory than Node.js under the same load.
Growing Gold with Rust 👀
Flake Growth, written in Rust, is a tool for simulating the growth of single-crystalline gold flakes from an initial single atom up to the micrometer scale (i.e. billions of atoms).
It also has a WebAssembly version compiled from Rust, which runs in the browser.
Serverless world
Serverless Days 2020 Looks at Future of Serverless Architecture 👁
This InfoQ article covers a recent Serverless Day event. Serverless computing is growing from a “glue” for other cloud services into a full-stack application service in its own right, hence, the rise of the serverless architect.
Enjoyed reading this newsletter? Please subscribe to make sure that you do not miss a future issue. ❤️
This newsletter is a collaborative effort. Don’t forget to leave comments! Suggest topics or projects you would like to see we cover next week. Thanks!
Until then, stay safe, stay healthy! 😷