Understand the Need for WebAssembly Components
In the “Use wasm-tools to Investigate and Manipulate WebAssembly Artifacts” Shortcut, I introduced you to the wasm-tools
collection of functionality. It is similar to the WebAssembly Binary Toolkit but is a more modern suite of tools that reflects how the standards have evolved. I indicated that there was a new artifact type called a component, in addition to our friend the module. In this Shortcut, I am going to explain the need for the WebAssembly Component Model before introducing it in a subsequent Shortcut.
In the GitHub repository for this Shortcut, you should enter the directory 21-Why-Wasm-Components
. In it you will find a readme.md
file describing the installation instructions for the tools, so you can follow along. There are also a handful of files you have seen before that we will again explore.
This Shortcut is, in some sense, a pause and review activity. The larger purpose is to highlight the perhaps not obvious arc linking the topics we have covered, with an eye toward where we are going. Most of the Shortcuts stand on their own, but together they are telling a very big story.
In the Shortcut I mentioned above, I used a .wat
-based expression of some simple arithmetic and showed how wasm-tools
helps us explore the module structure. Let’s now revisit the higher-level expression of our add
function in Rust in add.rs
:
#[no_mangle] pub extern "C" fn add(x: ...
Get Understand the Need for WebAssembly Components 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.