Review: C++ Multithreading Cookbook

The C++ Multithreading Cookbook should really be called The C++ Windows Multithreading Cookbook. The entire book is composed of tips and code examples that are intrinsically Windows, with only one short section that contains tips on multithreading in a platform independent fashion – although the author notably doesn’t mention that OpenMP is also available for non-Microsoft platforms.

After chastising myself for hoping for platform independent coding tips despite the fact that I’d read the table of contents, I gave it a chance but was sadly disappointed.

For starters, the book’s a collection of antipatterns. One simple example is a function that generates a supposedly random number by generating a random double and scaling that to fit into the specified min/max domain. Consistently, the code for each example file is preceded by several lines of using directives, making it difficult to find out where a given function comes from. And generally, although the author does put most of his code into classes, its style is a lot more like C than C++. Char arrays abound in place of strings, preprocessor directives and define statements are everywhere, and functions that signify if they were successful or not return an integer return code instead of raising exceptions or returning a boolean. The code has the volume of extreme verbosity with all the disadvantages of spartan terseness – rather than including files common to several examples, the author copies and pastes the code into new files and asks the reader to do the same. In one chapter, the author writes proudly that only a few lines separate the current from the precious example. Which ones? Of the >300 lines shown again and again in each section, none are highlighted. Put the book in a plastic bag, because it’s definitely a WET read.

If you are looking for a book that contains numerous examples on multithreading using the possibilities the Windows operating system offers you, you’re at the right place. The examples could occur in real life and you can follow them with a bit of effort. However, don’t expect the API to be explained well or, in many cases, at all, and don’t expect it to be portable or especially well designed. There are some interesting sections that explain the theory behind parallelism and object orientation, but the author doesn’t follow his own tips with OOP and the parallelism theory is too poorly explained for most beginners, yet too well-trodden ground for those above the intermediate level.

I would love to be able to write a more positive review for this book, but sadly I can’t, and I highly doubt I will open it again myself.

Advertisements
About

My name’s Daniel Lee. I’m an enthusiast for open source and sharing. I grew up in the United States and did my doctorate in Germany. I've founded a company for planning solar power. I've worked on analog space suit interfaces, drones and a bunch of other things in my free time. I'm also involved in standards work for meteorological data. Now I work for the German Weather Service on improving forecasts for weather and renewable power production.

Tagged with: , ,
Posted in Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

From the archive