WebAssembly in Action
Gerard Gallant
  • MEAP began November 2018
  • Publication in Spring 2019 (estimated)
  • ISBN 9781617295744
  • 375 pages (estimated)
  • printed in black & white

WebAssembly in the future and when you want to know what is going on, you should read this book.

Sander Zegveld

“Any application that can be written in JavaScript, will eventually be written in JavaScript.”
 — Jeff Atwood, Cofounder of StackOverflow

“Atwood’s Law” is driven by the idea that all applications will ultimately wind up on the web and therefore must be written in JavaScript. WebAssembly may be your way out! With WebAssembly, you can write in nearly any modern language and run your code in the browser through a memory-safe, sandboxed execution environment that can be embedded in a web browser and other platforms. Getting set up and moving with WebAssembly requires you to modify your web dev process; WebAssembly in Action will get you started quickly and guide you through real-world examples and detailed diagrams that help you create, run, and debug WebAssembly modules.
Table of Contents detailed table of contents

Part 1: First Steps

1 Meet WebAssembly

1.1 What is WebAssembly?

1.2 What problems does it solve?

1.2.1 Performance improvements

1.2.2 Faster startup times compared with JavaScript

1.2.3 Ability to use languages other than JavaScript in the browser

1.2.4 Opportunity for code reuse

1.3 How does it work?

1.3.1 Overview of how compilers work

1.3.2 Loading, compiling, and instantiating a module

1.3.3 Structure of a WebAssembly module

1.3.4 WebAssembly Text Format

1.4 How is WebAssembly secure?

1.5 What languages can I use to create a WebAssembly module?

1.6 Where can I use my module?

1.7 Summary

2 Creating your first WebAssembly Module

2.1 The Emscripten toolkit

2.2 WebAssembly modules

2.3 Compiling C or C++ with Emscripten and using the HTML template

2.4 JavaScript plumbing code

2.4.1 Compiling C or C++ with Emscripten generated JavaScript

2.4.2 Creating a basic HTML webpage for use in browsers

2.5 Only the WebAssembly file

2.5.1 Compiling C or C++ as a side module with Emscripten

2.5.2 Loading and instantiating in a browser

2.6 Feature detection: How to test if WebAssembly is available

2.7 Summary

Part 2: Working with Modules

3 Creating a WebAssembly module that JavaScript talks to

3.1 Using C or C++ to create a module with Emscripten plumbing

3.1.1 Making the C++ modifications

3.1.2 Compiling the code into a WebAssembly module

3.1.3 Creating the webpage

3.1.4 Creating the JavaScript that will interact with the module

3.1.5 Viewing the results

3.2 Using C or C++ to create a module without Emscripten

3.2.1 Making the C++ modifications

3.2.2 Compiling the code into a WebAssembly module

3.2.3 Creating the JavaScript that will interact with the module

3.2.4 Viewing the results

3.3 Summary

4 Creating a WebAssembly module that talks to JavaScript

Part 3: Advanced Topics

5 Allowing multiple WebAssembly modules to talk to each other

6 Running code in a separate thread from the UI in a browser

7 Working with WebAssembly modules in NodeJS

Part 4: Debugging and Tools

8 The WebAssembly Text Format

9 Debugging

10 Tools

11 Future WebAssembly improvements that are in the works

Appendixes

Appendix A: WebAssembly Known sections

A.1 Known sections

Appendix B: Installation & tool setup

B.1 Python

B.1.1 Running a local web server

B.1.2 The WebAssembly Media Type

B.2 Emscripten

B.2.1 If you are using Windows

B.2.2 If you are using a Mac or Linux

B.3 NodeJS

B.4 WebAssembly Binary Toolkit

B.5 Bootstrap

Appendix C: ccall, cwrap, and direct method calls

C.1 ccall

C.1.1 Building a simple WebAssembly module

C.1.2 Building the webpage that will talk to the WebAssembly module

C.2 cwrap

C.2.1 Adjusting the JavaScript code to use cwrap

C.3 Direct method calls

C.4 Passing an array to a module

About the Technology

WebAssembly compiles code written in C, C++, Rust, and other high-level languages into an ultra-compact bytecode files that run in the browser and other environments at near-native speeds. Besides vastly improved performance, opportunities to reuse existing code, and the freedom to build in your favorite language, this game-changer allows access to newer and faster libraries. WebAssembly is the joint effort of industry leaders like Microsoft, Mozilla, Google, and others, with support built into all major browsers.

About the book

WebAssembly in Action introduces the WebAssembly stack and walks you through the process of writing and running browser-based applications. Expert developer Gerard Gallant gives you a firm foundation of the structure of a module, HTML basics, JavaScript Promises, and the WebAssembly JavaScript API. After building simple modules, you’ll delve deeper into dynamic linking of multiple modules at runtime, working with NodeJS modules, building modules with C/C++ and the Emscripten toolkit, and running a UI-independent thread with an HTML5 web worker.

To ensure your code is error-free, you’ll also learn about WebAssembly Text Format, which is vital for debugging. You’ll reinforce your learning with real-world examples and get a glimpse of features-to-come, including host bindings and garbage collection. WebAssembly makes it possible to create apps for online video gaming, image and video editing, virtual reality, peer-to-peer collaboration, music streaming, and many more without adjusting to the idiosyncrasies of JavaScript. This well-rounded tutorial is your ticket!

What's inside

  • The WebAssembly format
  • Dynamic linking of multiple modules at runtime
  • Communicating between modules and JavaScript
  • Debugging modules
  • Unreleased features like host bindings and garbage collection!

About the reader

Written for developers with a basic understanding of C/C++, JavaScript, and HTML.

About the author

Gerard Gallant is a Microsoft Certified Professional and a Senior Software Developer at Dovico Software. He blogs regularly on Blogger.com and DZone.com.

Manning Early Access Program (MEAP) Read chapters as they are written, get the finished eBook as soon as it’s ready, and receive the pBook long before it's in bookstores.

placing your order...

Don't refresh or navigate away from the page.

FREE domestic shipping on three or more pBooks

A great comprehensive introduction to a new frontend technology.

Denis Kreis

With the well-organized content, the author has made sure that everyone from beginner to very experienced developers will have something to learn.

Reza Zeinali