Exploring WebAssembly (WASM)

Getting Started with WebAssembly

Section Summary

In this section, we’ll explore the fundamentals of WebAssembly and its practical applications:

  • WebAssembly Binary Format (WASM)
  • Human-readable Text Format (WAT)
  • WebAssembly System Interface (WASI)

You’ll build a simple “Hello World” module in C, C++, or Rust, compile it to WASM, and embed it in a web page using the WebAssembly JavaScript API. Hands-on labs will guide you through environment setup, compilation, and execution in both browser and WASI runtimes.

Key Topics

TopicDescriptionReference
WebAssembly Binary FormatCompact bytecode optimized for performanceWASM Spec
Text Format (WAT)Readable s-expression syntax that assembles into WASM binaryMDN WAT Guide
WebAssembly System InterfacePOSIX-like APIs for file I/O and networking in WASI environmentsWASI Docs
Module Creation & ExecutionCompiling from Rust/C/C++ to WASM and running modules locallywasm-bindgen
JavaScript IntegrationLoading and calling WASM functions via the WebAssembly JS APIMDN WebAssembly API

Prerequisites

Make sure you have:

  • Node.js (v14 or later)
  • Rust/C/C++ toolchain with WebAssembly targets
  • A modern browser supporting WASM

By the end of this lesson, you will be able to:

  • Differentiate between WASM binary and text formats
  • Compile and run WebAssembly modules locally and in the browser
  • Leverage WASI for system-level interactions
  • Embed and interact with WebAssembly modules from JavaScript

The image lists objectives related to WebAssembly, including working with its formats, creating and running modules, and gaining practical experience through hands-on demos.

Useful Resources

Watch Video

Watch video content

Previous
Demo Running a Simple C application in Browser