Practical C++ Programming

by Steve Oualline

2nd ed., 570 pages, ISBN 0-596-00419-2, O'Reilly Media, Sebastopol, CA, 2003.

Reviewed by J. M. Haile, Macatea Productions,

This is the best book on programming that I have encountered in over 35 years of coding and teaching others to code. It is particularly satisfying that Oualline's writing and organization skills have been applied to C++, the language that all serious programmers must learn. C++ is important, first, because it serves as the basis for the syntax and structures of so many later languages: knowing C++ significantly eases the toil of learning many other languages. Second, C++ is important because it is a medium-level language: for many applications, you can code exclusively at a high level, if that is your preference. But when the project requires, you can use C++ to get close to machine-level manipulations.

Consider first the book's organization. The text of 514 pages is divided into five parts and a total of 30 chapters. That averages 17 pages per chapter, which is a nice friendly size, particularly for advanced topics: just when you think a chapter is about to overwhelm you with technical details, it ends. This leaves you feeling that, with modest effort, you will be able master the material. The book covers, of course, the syntax and grammar of the language, but it also does much more—it tries to help you develop important skills and attitudes toward the entire programming process. For example, Oualline gives us Chapter 3 on coding Style, Chapter 7 on The Programming Process, Chapter 17 on Debugging and Optimization, Chapter 26 on Program Design, and Chapter 27 on Putting It All Together. These are crucial topics that all programmers confront and overcome as they develop mastery; moreover, much of the material in these chapters is general, not limited to a particular language, such as C++. I particularly like that the chapter on style is placed before any details of the language are presented. Style matters.

Now consider the book's content. The presentation nicely balances (1) stating the rules of C++, (2) discussing what the rules mean, and (3) illustrating their use. Further, in discussing the rules, Oualline habitually tells what the rules do not say and he warns us of common misinterpretations to avoid. He gives bad examples as well as good ones. These features imply an author who has had long familiarity with his subject. Distributed through the text are Questions to challenge the reader. Most of these are snippets of code, introduced with a simple challenge: "What's wrong with this code?" or "Why does this code give the wrong answer?" Often the error is a simple typo, or a misplaced statement, or a misused variable; in other words, the kinds of mistakes we all make, but which take years of coding to recognize immediately. At the ends of chapters, Oualline poses a few exercises. Many of these are clever: easy to state, but not necessarily easy to accomplish. For example, at the end of the chapter on control statements we find

Exercise 8.6: Write a program that converts numbers to words. Example: 895 results in "eight nine five."

The writing is informal and easy to read; the presentation is in O'Reilly's familiar house style. My eye caught only a couple of editorial lapses: lines in which a word was completely dropped from a sentence.

Perhaps most valuable is that a programmer will not soon outgrow this book. You can use the book to learn the rudiments of C++ quickly, and immediately start getting practice by writing "simple" code. Then as your facility improves, you can return to this book to explore more advanced features of the language. Even if you evolve away from C++ to other languages, the chapters on the programming process will still be of value. So the book combines the best features of a text and a reference: a worthy addition to any programmer's library.

(jmh 12 September 06) © 2006 by J. M. Haile. All rights reserved.