For online information and ordering of this and other Manning books, please visit www.manning.com. The publisher offers discounts on this book when ordered in quantity. For more information, please contact
Special Sales Department Manning Publications Co. 20 Baldwin Road PO Box 761 Shelter Island, NY 11964 Email:
2019 by Manning Publications Co. All rights reserved.
No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by means electronic, mechanical, photocopying, or otherwise, without prior written permission of the publisher.
Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in the book, and Manning Publications was aware of a trademark claim, the designations have been printed in initial caps or all caps.
Acquisitions editor: Brian SawyerDevelopment editor: Toni ArritolaTechnical development editor: Ian LovellReview editor: Ivan MartinoviProduction editor: Anthony CalcaraCopy editor: Rebecca Deuel-GallegosProofreader: Tiffany TaylorTechnical proofreader: Arno BastenofTypesetter: Dottie MarsicoCover designer: Marija Tudor
Preface
Compared to my friends, I was a late bloomer when it came to programming. I only discovered it in high school by chance because I needed another computer course, and my guidance counselor suggested Computer Ed. I was expecting to learn about how computers work, but, much to my surprise, the course was about programming. It didnt take long before I was hooked, and I adjusted my career direction from one dealing with building architecture to one in software architecture.
In 2001, I landed a job with Dovico Software helping it maintain and improve its C++ client/server application. The winds of change were blowing, and in 2004, Dovico decided to switch to a software-as-a-service model, and I moved to the web application product. I still helped maintain the C++ applications, but my core focus became web development with C# and JavaScript. These days, I still do web development, but my focus has shifted to the architecture side of thingsbuilding APIs, working with databases, and exploring new technologies.
I enjoy being able to give back to the developer community through blogs and public speaking. In September 2017, I was asked if Id be interested in giving a presentation at a local user group. As I was browsing for ideas on what I could talk about, I ran across an article from PSPDFKit that talked about a technology called WebAssembly (https://pspdfkit.com/blog/2017/webassembly-a-new-hope/).
I had read about Googles Native Client (PNaCI) technology, in which C or C++ compiled code could run in the Chrome web browser at near-native speeds. Id also read about Mozillas asm.js technology, where you could compile C or C++ code to a subset of JavaScript and have it run really fast in browsers that supported it. In browsers that didnt support asm.js, it would still run, but at normal speed, because its just JavaScript. Somehow, this was the first Id heard of WebAssembly.
WebAssembly takes the improvements that asm.js brought and aims to address its shortcomings. Not only can you write code in a number of different languages and compile it into something that works safely in a browser, but its already available in all major desktop and mobile browsers! Its also available outside the browser, in places like Node.js! I was blown away by its potential and spent every spare moment from then on digging into the technology and blogging about it.
Late in 2017, my blog posts were noticed by Manning Publications, and I was contacted to see if I would be interested in writing a book about WebAssembly. At first, the book was going to cover multiple languages as well as show you how to work with the technology from both a backend and frontend developer perspective. By the first review, however, it became obvious that the book wasnt focused enough, so we decided that it would be best to narrow the scope to the C++ programming language and focus more on backend developers.
The WebAssembly community and working groups havent been sitting still while Ive been working on this book. In fact, several advancements to the technology are in the works. Recently, the ability to use multithreaded WebAssembly modules in the desktop version of Google Chrome became possible without the need to turn on a developer flag! WebAssembly has the potential to help bring web development to a whole new level, and Im excited to see where things go.
Acknowledgments
I was told that writing a book took work and time, but I wasnt expecting it to take as much work as it did! With help from my editors and reviewers, and feedback from those who purchased an early copy, I believe this has turned out to be a great book that will help you get started with WebAssembly.
I need to thank a lot of people who made this book possible. First and foremost, I need to thank my family for their patience with me as I worked long into the evenings and on weekends and holidays, and even used up some vacation time to meet deadlines. My wife Selena and my girls Donna and AudreyI love you all very much!
Next, thank you to my first editor at Manning, Kevin Harreld, who helped me get up and running with writing this book. Kevin later accepted a job at another company, giving me the opportunity and pleasure to work with Toni Arritola for the remainder of the book. Toni, thank you for your patience while working with me, your professionalism, your honesty where you didnt beat around the bush and told it like it was, and your desire for quality.
Thank you to everyone at Manning who has played a role in this book, from marketing to production. Your tireless work is appreciated.
Thank you to all the reviewers who took time out of their busy lives to read this book at the various stages of its development and gave constructive feedback, including Christoffer Fink, Daniel Budden, Darko Bozhinovski, Dave Cutler, Denis Kreis, German Gonzalez-Morris, James Dietrich, James Haring, Jan Kroken, Jason Hales, Javier Muoz, Jeremy Lange, Jim Karabatsos, Kate Meyer, Marco Massenzio, Mike Rourke, Milorad Imbra, Pavlo Hodysh, Peter Hampton, Reza Zeinali, Ronald Borman, Sam Zaydel, Sander Zegveld, Satej Kumar Sahu, Thomas Overby Hansen, Tiklu Ganguly, Timothy R. Kane, Tischliar Ronald, Kumar S. Unnikrishnan, Viktor Bek, and Wayne Mather.
Special thanks to my technical editor, Ian Lovell, who gave lots of invaluable feedback throughout the process, and my technical proofreader, Arno Bastenhof, who gave the code one last review before the book went into production.
And finally, a huge thank you to the browser makers that have worked together to bring a technology to market that will benefit the web for years to come. Thank you to the many people around the world continuing to work on improving WebAssembly and extend its reach. The possibilities are enormous for this technology, and I cant wait to see where WebAssembly takes us.