Building High-Performance Portable Software with Wasm
Introduction
- What This Book Will Teach You
- How This Book Is Structured
- What Makes WebAssembly Different
- A Note on Versions and Stability
Chapter 1: What Is WebAssembly and Why It Matters for Systems Programming
- From Browser Bytecode to Systems Platform
- The Portability Problem in Modern Systems Programming
- Performance Characteristics and Trade-offs
- The WebAssembly Ecosystem Landscape
- What This Book Will Build
Chapter 2: Architecture Deep Dive: The WebAssembly Execution Model
- The Stack Machine Design Philosophy
- Types and Values in WebAssembly
- Instructions and Control Flow
- Functions as First-Class Units
- Verification and Safety Guarantees
Chapter 3: Memory Model: Linear Memory and Allocation Strategies
- The Linear Memory Abstraction
- Memory Operations and Bounds Checking
- Stack Allocation Within Linear Memory
- Heap Allocators for WebAssembly
- Memory Sharing and Inter-Module Communication
Chapter 4: Modules and Interfaces: The WebAssembly Component Model
- WebAssembly Modules: Structure and Semantics
- Exports and Imports: Connecting Code
- The WebAssembly Component Model
- Resource Management in Components
- Building Composable Systems with Components
Chapter 5: Toolchains and Development Setup
- Installing Core Runtimes: Wasmtime and Wasmer
- Compiling from Rust to WebAssembly
- Compiling from C and C++ to WebAssembly
- Build Tools: wasm-pack, wasm-tools, and cargo-wasi
- Development Workflow Patterns
Chapter 6: WASI: The WebAssembly System Interface
- Why WASI Exists: Bridging Modules and Operating Systems
- WASI Preview 1 API Surface
- Running WASI Modules with Wasmtime
- WASI Preview 2 and the Component Model
- Custom Host Implementations of WASI
Chapter 7: Language Interoperability: Writing and Calling WebAssembly from Multiple Languages
- Rust as a First-Class WebAssembly Language
- C and C++ Compilation to WebAssembly
- Go WebAssembly Support and Limitations
- AssemblyScript and TypeScript-to-Wasm
- Cross-Language Calling Patterns
Chapter 8: Building Reusable WebAssembly Modules and Libraries
- Designing Stable APIs for WebAssembly Modules
- Memory Management Across Module Boundaries
- Packaging and Distributing WebAssembly Libraries
- Dependency Management in WebAssembly Projects
- Case Study: Building a Data Processing Library as WebAssembly
Chapter 9: Command-Line Tools and Plugins with WebAssembly
- Building CLI Tools That Run as WebAssembly
- The Plugin Architecture Pattern
- Building a Plugin Host in Rust
- Writing Plugins as WebAssembly Modules
- Real-World Plugin Systems Using WebAssembly
Chapter 10: Server-Side WebAssembly: High-Performance Services
- Server-Side Runtimes: Wasmtime, WasmEdge, and Spin
- Building HTTP Services with WebAssembly
- Compute-Intensive Workloads in WebAssembly
- Multi-Threading and Parallelism in Server-Side Wasm
- Scaling WebAssembly Services
Chapter 11: Security and Sandboxing: Trusting Untrusted Code
- The WebAssembly Security Model
- Capability-Based Access Control with WASI
- Threat Models for WebAssembly Systems
- Side Channel Attacks and Defenses
- Secure Plugin and Extension Architectures
Chapter 12: Debugging, Profiling, and Optimization
- Debugging WebAssembly Code
- Profiling WebAssembly Performance
- Runtime Optimization: JIT and AOT Compilation
- Code-Level Optimization Techniques
- Benchmarking WebAssembly Applications
Chapter 13: Testing WebAssembly Systems Software
- Unit Testing WebAssembly Modules
- Integration Testing Strategies
- Property-Based Testing and Fuzzing
- Cross-Runtime Compatibility Testing
- Mutation Testing and Coverage Analysis
Chapter 14: Deployment and Operations
- Packaging WebAssembly Applications for Production
- Deploying to Cloud Platforms
- Monitoring and Observability
- Updating and Versioning Deployed Modules
- Operational Best Practices
Chapter 15: Advanced Systems Programming with WebAssembly
- Building Custom WebAssembly Runtimes
- WebAssembly in the Kernel and Operating Systems
- Advanced Networking with WebAssembly
- Memory-Mapped I/O and Hardware Access Patterns
- The Future of WebAssembly as a Systems Platform
Conclusion: The WebAssembly Systems Programming Paradigm
- What WebAssembly Does Well
- When WebAssembly Is Not the Right Choice
- A Practical Decision Framework
- The Skills You Now Have
- Looking Forward