Exceptional C++ and More Exceptional C++

Two essential aids for the C++ Interviewee

Book review This pair of books brings together a variety of small but annoying puzzles mediated by Herb Sutter through the news:comp.lang.c++.moderated newsgroup.

However, any irritation is in a good cause. Each puzzle illustrates an important point in C++ that many of us still get wrong. An early example is exception safe programming, which most of us (OK, yes, me), have struggled against. Fortunately for my self esteem, these puzzles are given a difficulty score of between 7 and 9 out of 10.

This gives a clue as to what these books really are, they’re not just textbooks. Instead, they map out 100 or so interview questions. Hence their awkward nature; the questions are supposed to be tricky. As a pimp who used to be a C++ contractor, I can say with some confidence that if you can get through these books, you will pass more than 80% of C++ interviews. However, these are not “…For Dummies” books, you are required to think hard and there is no real common theme beyond that of shattering any wishful thinking about your being a C++ guru.

Sutter is a Microsoft lackey, but fortunately, these aren’t Visual C++ books. Even though VC++ is vastly more standards conformant than it used to be, it is rarely mentioned except in connection with issues where the compiler gets to make choices.

Although inheritance is a common playground for interviewers, the coverage is sparse, probably reflecting Sutter’s accurate belief that as an O-O technique it is over used and, rightly, in relative decline as a programming technique.

Large scale design issues are skipped over lightly and, in general, these are books about programming in the small rather than the large. The exception to this is some waffle about header files in big projects and how to make them faster, which is rarely a critical issue in these days of precompilation and fast processors.

The second book emphasises STL and templates rather more and brings in threads. This is an area you really do need to start thinking about. Multi-core architectures mean that bog standard single thread code will execute 50%, or even 75%, more slowly than multi-threaded code on the same hardware; and that ratio is increasing. This is part of the optimisation theme, and although many books talk of writing “good” code, the hardcore stuff of making your code faster is usually rather skipped over in other books. Later in the book, Sutter points out some of the horrors that await the unwary over-optimiser [that’s good – Ed].

There is yet more on exception safety, which is clearly important enough for Sutter to bring his notion of programming “morality” to the topic. More Exceptional C++ also gives rather good coverage of the ancient dark art of pre-processor macros, a topic skipped over lightly in most other books. The sparse style is great for focusing on each issue, and for such short books, there's an impressive amount that you'll learn from them, although this comes at a price: if you don’t understand the example, you simply have to stare at it until it makes sense, because there is only ever one. You can of course argue that this is a good thing.

Exceptional C++ and More Exceptional C++

Verdict: If you’re going to go to a C++ interview any time in the next year, read these books and halve your chance of failure.

Author: Herb Sutter

Publisher: Addison Wesley

ISBNs: Exceptional C++ 0201615622; More Exceptional C++ 020170434

Media: Book

Buy Exceptional C++ at Cash & Carrion!

Buy More Exceptional C++ at Cash & Carrion too!

Sponsored: 5 critical considerations for enterprise cloud backup