The Art of WebAssembly

Author: Rick Battagline
Publisher: No Starch
Date: May 2021
Pages: 304
ISBN: 978-1718501447
Print: 1718501447
Kindle: B08TSYXJTS
Audience: WebAssembly developers
Rating: 5
Reviewer: Ian Elliot
WebAssembly is the coming thing - or so we are told.

WebAssembly (WA) is an attempt to introduce a universal intermediate language that can run in the browser among other things. In principle it should make it possible to take existing application written in C and other languages and compile them to WebAssembly and from there you should be able to run them anywhere. You must have heard this sort of idea before. It goes back to the early days of P code and today is best known as the Java byte code language and possibly .NET IL.

At the moment the impact of WA on the average JavaScript programmer is minimal as most of us don't need the speed and ability to use existing code it provides. Even if you do need to use WA the chances are you will opt to use a high level language and a suitable compiler. At the moment this is difficult enough to make it a barrier to the casual use of WA, but this is likely to change. More to the point, it has to change if WA is going to become more widely used.

So a book on WA is a good idea even if you might not need it just yet. However, you need to know that this particular book takes the approach of teaching you all about the raw use of WA. That is no high-level language or compiler involved - just write the WA code as if it really was assembler. 

Yes, this is low level coding!

Banner

The good news is that getting started it much easier with assembler than with a high level language. The book suggests using Visual Studio Code and a suitable extension. This lets you write assembly code in text and try it out. You also need to install Node.JS for many of the early examples - you can't get away from JavaScript as WA needs it to get started and do most of the user interaction. 

The book starts off with a general look at WA and explains why you might want to use it. This is where we learn about Visual Studio and Node and look at a first simple example. Chapter 2 gets into the details of writing WA. Chapter 3 is all about functions and function tables.

Chapter 4 starts to tell you about things that you probably should know before you start with any assembly language - low-level bit manipulation. However, given the range of backgrounds programmers have today and the number who don't encounter low-level programming, perhaps it is a good idea to go over the basics. I found some of the illustrations a little too simplistic and more suitable for a dummy's book, but this is a style problem and doesn't make the book any less readable or useful. Chapter 5 explains how to use strings - always more difficult in a low-level language.

The rest of the book slowly moves away from learning the basics of WA to how to make it work with the rest of the system. Chapter 6 is about dealing with memory; Chapter 7 explains how to interact with the DOM to create a Web App; Chapter 8 extends this to working specifically with the Canvas element to create graphics; Chapter 9 is about optimization and profiling and Chapter 10 introduces the debugger.

The final chapter introduces AssemblyScript which is a TypeScript-like higher level language that is easy to compile into AW. It isn't clear why this is covered in a book on AW and it probably deserves a book in its own right. Using AssemblyScript makes writing larger programs much more feasible, but whether this is a good bet for the future is too early to say. It is undeniably a more familiar way to program for most JavaScript programmers.

This is a really good book, but it isn't essential reading for every JavaScript programmer. It is more suited to the experimenter and the existing assembly language programmer wanting to try out new ideas. Unlike many of the books out there this one actually has some technical content, but it might be too technical for many readers - this is a failure of the reader rather than the book. 

To keep up with our coverage of books for programmers, follow @bookwatchiprog on Twitter or subscribe to I Programmer's Books RSS feed for each day's new addition to Book Watch and for new reviews.

Banner


Assembly x64 Programming

Author: Mike McGrath
Publisher: Easy Steps
Date: November 2021
Pages: 192
ISBN: 978-1840789522
Print: 1840789522
Kindle: ‎B09FTNN4P5
Audience: Developers wanting to learn assembler
Rating: 5
Reviewer: Harry Fairhead
Assembler, why would you want to learn that!



C++ Programming, 6th Ed (In Easy Steps)

Author: Mike McGrath
Publisher: In Easy Steps
Date: April 2022
Pages: 192
ISBN: 978-1840789713
Print: 1840789719
Kindle: B09V2T9SJD
Audience: Developers wanting to learn C++
Reviewer: Mike James
This is the 6th edition of a slim book on C++. Can you really learn C++ in easy steps?


More Reviews

 

Last Updated ( Friday, 24 December 2021 )