This is a review of the book WebAssembly in Action, an hands-on guide to bring your C++ code to the browser (or Node.js) using WebAssembly.
What is WebAssembly
This is a book that contains information about both the theory and the practice of using WebAssembly to bring C++ code on the browser. If you do not know what WebAssembly is, this is an explanation:
WebAssembly, or wasm, is a low-level bytecode format for in-browser client-side scripting. If you are writing a compiler for a programming language one option is to target a platform, like the JVM or .NET, and compile your language to the target bytecode. WebAssembly occupies the same role, so when you compiling to WebAssembly you are making your software available for all platforms where it is supported, in other words all browsers.
If you need a more in-depth introduction of WebAssembly you can read our article about it: Understand WebAssembly: Why it Will Change the Web.
in our lives in the browser is over. In less dramatic terms: you can now program in other languages and use them in the browser. This is good for productivity and amazing for re-use and maintenance. You can now bring your existing codebase in the browser. You can have the core functionality of your software in one library an re-use everywhere, from mobile to the browser. Of course it will not be trivial to bring a 20+ years old codebase in the browser, but now at least it is feasible.
Is This Book for You?
std::vector class) that should be common knowledge even among novice users of C++. One thing to notice is that the book goes really in-depth into explaining the inner workings of WebAssembly. This is true to the point that it dedicates a chapter to build a WebAssembly module by writing WebAssembly text format by hand. So, it could also be useful if you need in-depth technical information about WebAssembly and plan to use another language, other than C++.
How the Book is Organized
The book is divided in four parts: two are dedicated to explaining the WebAssembly format and how to use it, the others two are dedicated to advanced topics.
The four parts are:
- First steps. The first one is dedicated to explaining what is WebAssembly and a detailed description of the format of a module. The last chapter of this part shows how to create your first WebAssembly module (i.e., a program in a sense) with all the basic information to use Emscripten (i.e., the tool that compile C++ in WebAssembly)
- Advanced Topics. It is a collection of different advanced topics: combining dynamically multiple WebAssembly modules, using web workers and threads and using WebAssembly in Node.js
Should You Buy This Book?
In terms of classification this is a peculiar book: it is a guide, but also a reference book with chapters detailing every single possible combination of elements. It is about WebAssembly, but also the specific C/C++ WebAssembly tooling (i.e., Emscripten). It leads you to very advanced topics, like debugging code by looking at the WebAssembly text format, but it also assumes you know nothing about how to test software.
This is what I mean when I say that is also a reference book:
- it shows the code of one example and then it shows you how to use it if you include standard C/C++ functions in the WebAssembly module (e.g.,
malloc) or how to use it if you replace it with your own version of these basic functions
It is very thorough, and I honestly cannot think of a combination or option that was not explored.
For example, this is what you can see throughout the book. A diagram explaining the organization of the current example:
Every piece of code that was written or edited for the current project:
And a detailed explanation of most complex changes:
It is also a good book for people looking for a detailed explanation on the WebAssembly format because they want to build their own WebAssembly tooling. Yes, you could find the same information online, but you will take hours to find it and here it is explained better. For example, the description of how to interpret control flow statements bytecode in a stack-based machine it is fundamental to make WebAssembly tools. And if you have never worked on compilers, you might not even be aware that you need to know that.
The only people that would not like this book are the ones looking for a quick read: what are to some detailed explanations and a careful examination of each option might seem to them just a lot of filler content.
Disclaimer: the publisher gave us a copy of the book for the review and we do have an affiliate agreement, but our review is honest. To avoid a conflict of interest we simply do not publish reviews of books we do not like.
The Best Programming Languages
Get the guide to the best programming languages to use in each situation delivered to your email and read it when you want on the device you want