Book Reviews
Professional Multicore Programming: Design and Implementation for C++ Developers by Cameron Hughes and Tracey Hughes
ISBN:
978-0470289624
Publisher:
Wrox
Pages:
648
For a long time, we could count on the chip manufacturers to simply provide ever faster processors with ever increasing clock frequencies. As the chip manufacturers hit the practical limits of single core design, the answer is to increase overall capacity by putting multiple processors on a single chip. These multicore computer architectures have now entered the mainstream. And the challenge for software developers is to make programs scale and take advantage of multiple cores. It's a different kind of programming.
The Art of Multiprocessor Programming turned out to be a really good introduction to the building blocks used for parallelization. I believe that even as an application programmer it's important to have a grasp on what's happening under the hood and the trade-offs involved when designing parallel programs. And Multicore Programming felt like the next natural step with its focus on the application level and how to put it all together. The scope of the book looks promising: discussions on hardware architecture, the role of the operating system, comparisons of processes and multithreading approaches, and high-level models for application design. And despite my preference for Erlang, I even partly buy into the idea of using C++; C++ is low-level enough to show the pitfalls of shared data and high-level enough to be able to express interesting abstractions. Further the world is filled with legacy C++, so a book like this could have been an important companion for the software maintainer. But please note my emphasis on could; as it turned out, Multicore Programming is a major disappointment.
C++ is a terribly complex language to learn and use. Particularly when trying to develop parallel programs. But if you write a book about it I expect you to master the combination and the authors unfortunately don't. The included C++ code has so many problems that it's hard for me to know where to start: no exception-safety, potential memory-leaks, erroneous copy semantics, lack of const-correctnes, etc. It's basically C code wrapped in classes. Classes with implementation details leaking through and augmented with an occasional bug or two. But potentially worse are the many logical errors in the examples. One example is the attempt for multithreading on page 87: a loop iterating through an array with threads. The body of the loop runs each thread and immediately waits in a join for the thread to finish! Sure, you do launch mutliple threads but your program is completly sequential. Another common problem with the book is the terminology, which gets quite confusing at times. For example, I'm pretty sure the authors mean "functional", not "logical" programming most of the time.
The idea behind the book was promising but the execution is terrible. By removing all the tedious repetition the book could have been stripped to half of its 600 pages. To save it, the C++ code would have to be completely rewritten. I would also drop POSIX in favor of the boost libraries . There might be a good book somewhere deep inside waiting to get out. But as it stands now, it's a terrible waste of trees.
Reviewed October 2010