WebAssembly with Rust
Minimum price
Suggested price

WebAssembly with Rust

Create Applications with Rust and WebAssembly

About the Book

The book is written in a cookbook style. Each recipe focuses on a concept in the WebAssembly world.

Part 1 focuses on the basics of WebAssembly, WebAssembly Text Format, onboarding and using various tools like WABT, Binaryen.

Chapter 1 gives a brief introduction to LLVM. What it is and how to use it.

Chapter 2 introduces you into the `emscripten` world. Emscripten is a toolchain that helps to convert C/C++ into WebAssembly module. We will see how to install and manage the emscripten toolchain. Create our first WebAssembly module and run it on the browser and Node environment.

Chapter 3 explores the WebAssembly module, how the module is made and what are the different sections. We will also explore the WebAssembly Text Format and how to write WebAssembly Text Format and convert it to WebAssembly binary.

Chapter 4 explores how to install and use WebAssembly Binary Toolkit (WABT).

Chapter 5 explores various section inside the WebAssembly binary and what are its purpose.

Chapter 6 explores how to install and use Binaryen.

Part 2 focuses on converting Rust to WebAssembly for fast, reliable code to run on the JavaScript Engine. Find out various ways of sharing data between Rust and WebAssembly. Explore how to use various tools that Rust and WebAssembly ecosystem provides.

Chapter 7 starts with Rust and various ways to convert Rust into WebAssembly module and ends with wasmbindgen.

Chapter 8 focuses on how wasm bindgen along with crates like js-sys, web-sys helps to share entities from the WebAssembly world to JavaScript world.

Chapter 9 explores wasm-pack and how it makes it easy to build Rust and WebAssembly application.

Chapter 10 explores some Rust and WebAssembly examples.


Chapter 11 briefly introduces WebAssembly System Interface (`WASI`) and various ways to run WASI.

About the Author


Polyglot developer who likes to choose the right tool for the right job. I admire concise, readable code. I am passionate about open source. It is a decentralized place to learn and evolve.

Table of Contents

  • Introduction
  • LLVM
    • Compiled Languages
    • LLVM in action
  • Emscripten
    • Setting up Emscripten
    • Hello world with Emscripten in Node
    • Hello world with Emscripten in Browser
    • EMSDK other options
    • Optimisations
  • WebAssembly
    • WebAssembly Module
    • WebAssembly Text Format
  • WebAssembly Binary Toolkit (WABT)
    • Getting Started with WABT
    • WAST to WASM
    • WASM to WAST
    • WASM to C
    • wast2json
    • wasm-objdump
    • wasm-strip
    • wasm-validate
    • wasm-interp
  • Sections in WebAssembly Module
    • Imports and Exports
    • Globals
    • Start
    • Memory
  • Binaryen
    • Binaryen Installing & Using
    • wasm-as
    • wasm-dis
    • wasm-opt
    • wasm2js
  • Getting Started with Rust and WebAssembly
    • Introduction
    • Installing Rust
    • Rust to WebAssembly via emscripten
    • Rust to WebAssembly via Cargo
    • Installing wasm-bindgen
    • Rust to WebAssembly via wasm-bindgen
  • Boundary Crossing between Rust and WebAssembly
    • Sharing Classes from Rust to JavaScript
    • Sharing Classes from JavaScript to Rust
    • Calling JSAPI via WebAssembly
    • Calling Closures via WebAssembly
    • Importing the JavaScript function into Rust
    • Calling webAPI via WebAssembly
  • Build, Pack
    • Bundle WASM with Webpack
    • Bundle WASM with Parcel
    • Introducing wasm-pack
    • Pack & Publish with wasm-pack
  • Advanced Rust and WebAssembly
    • Minimise WebAssembly Modules
    • Memory model in WebAssembly
    • Analysing WebAssembly Module with Twiggy
  • WebAssembly System Interface
    • wasmtime - runtime for WebAssembly
    • wasmtime - various options
    • Errors to note in WASI
    • Lucet - the WebAssembly Compiler

The Leanpub 60-day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

See full terms

80% Royalties. Earn $16 on a $20 book.

We pay 80% royalties. That's not a typo: you earn $16 on a $20 sale. If we sell 5000 non-refunded copies of your book or course for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

In fact, authors have earnedover $12 millionwriting, publishing and selling on Leanpub.

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub