Generate WebAssembly Modules from Rust
While you will certainly want to be able to use other people’s existing modules, it’s important to learn how to generate your own. One of the nice aspects of WebAssembly is that it is increasingly easy to generate WebAssembly modules (including the instructions to execute) from arbitrary languages. Not every language is equally well supported, but before long we will have the ability to run any code in any language on just about any environment on any platform. There are clearly a lot of details behind all of those “any”s, but with this WebAssembly Shortcut series, you will learn the ins and outs in bite-sized chunks over time.
In this Shortcut, we will focus on using the Rust language to generate WebAssembly modules. The choice of Rust is both arbitrary and deliberate. It is arbitrary because it could be any language, as just noted. You will see how to use other languages as source code in subsequent Shortcuts. It is deliberate because Rust is a popular language on the ascent that improves on many of the problems of other languages. Rust has also had a very comfortable and natural relationship with WebAssembly because of its basis on LLVM. This architecture is modular, so you can support a new programming language by modifying the frontend parsing of source code. The middle layer allows for reused optimizations from other languages on an intermediate representation of the code. The backend ...
Get Generate WebAssembly Modules from Rust now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.