Now that we have a good overview of WebAssembly and its goals, namely performance, efficiency, portability, and safety, it's time to start coding!
Hold on... WebAssembly is a binary format?! Does that mean we have to write binary? Luckily, the answer is no 🙌.
WebAssembly has two file types:
.wasm
contains the Wasm bytecode.wat
is the human-readable textual representation of the bytecodeThe bytecode can be represented in a human-readable, easily editable, and debuggable form called the WebAssembly Text Format (WAT). The text format is another intermediate representation for exposure in IDEs, browsers, or developer tools.
Being able to write WebAssmebly by hand is actually quite handy. While the majority of tutorials and blog posts focus on specific toolchains, such as Emscripten for C++ or wasm-pack for Rust. However, as mentioned in the beginning, a deep understanding of WebAssembly and how its text format (WAT) fundamentally works is helpful in several ways:
Let's dive in!