Dr. Dobb's Journal October 2000
Programming books these days seem to be more like "stiff magazines" rather than texts you would keep through the course of your career. In fact, I estimate the half-life of a typical programming book to be about one year. Perhaps this will increase for C++ books, now that there is a Standard. The books I review here are all two years old and therefore past their primes. Consequently, I present them in alphabetical order, rather than in order of merit.
The C++ Standard Template Library (STL) itself is still not portable, claims to the contrary notwithstanding. Problems continue to surface in Usenet newsgroups where programmers mention the difficulties of trying to move code from one environment to another. All of the texts examined here make reference to this problem in varying degrees.
STL for C++ Programmers, by Leen Ammeraal, starts at a fairly high level. The book references Microsoft Visual C Version 5 and what appears to be Borland C++Builder Version 1. The book is small and easy to handle. The code is available for download, so no CD-ROM is supplied. Vectors are used right away, and the vector of vectors is a useful introduction to compound date structures using the STL. A one-plus page concordance program shows off the power of the STL. There is a lot of code. The text presents a "Large Number" class, which is useful to some readers. On the other hand, the pages on calculating
will appeal to far fewer readers.
The use of "using namespace std;" in all programs conveys the wrong approach to writing programs. Further, the text uses int where bool is preferable these days. A tiny taste of auto_ptr in Chapter 1 should be postponed for a later discussion. Presenting binders in Chapter 2 seems a little early, especially since little detail is given. The text refers to Borland C++Builder with the incorrect abbreviation BC5.2, a rather ancient variety of C++ compiler. Some space is spent dealing with the now irrelevant incompatibilities between VC5 and Borland C++Builder.
In Data Structure Programming, Joseph Bergin touches all the STL bases: iterators, containers, function objects, and the like. It's difficult to see where this book would fit in the spectrum, but my best guess would be as a source for a course taught by Bergin, because it is hard to tell if C++ is a prerequisite, or if it is being taught along with the data structures.
Since the software is downloadable, there is no CD-ROM. However, the URL in the book is incorrect. After poking around the Pace University (where Bergin is a professor of computer science) site, I did find http://csis.pace.edu/~bergin/STL/ STL.html. However, the following disappointing notices appear on the site:
Files for the book are here. They are NOT guaranteed to be bug free. Some of them were left in an incomplete state. The book was written before the standard was finalized. To see how to use the book (and the STL) with the final version of the standard look here. The first printing has a few errors. Here is the errata sheet.
Data Structure Programming has the feel of a repackaged book on data structures. Nonetheless, there were still some holes. There was no explanation of the terms "invariant" or "concept," or how to use them for development. The char* data type was used, whereas string would be more appropriate in a standard program. There were no answers to odd-numbered problems to support independent study, and there was a reference to Plauger, Stepanov, and Musser's phantom text. Bergin presents an implementation of a database without using relational technology. Finally, you could argue with statements like "most software is written to be used by other programmers," and "The second most important aspect of an algorithm is its efficiency."
Designing Components with the C++ STL, by Ulrich Breymann, was first published in German in 1996. The English edition appeared in 1998, and the target audience is C++ programmers. Here, I'm reviewing the first edition; a second edition is available for $10.00 less, although I have not seen it.
Since all the examples are available via FTP, no CD-ROM is included. And because solutions are provided to selected exercises, this book could be used both as a class text, and for self-directed study. Breymann recognizes that trying to explain everything at once is impossible, so he gives a broad-brush picture first. He provides a general-purpose introduction, an abbreviated chapter on iterators, a chapter on containers, and a discussion of abstract data types. Then in Part 2, he discusses algorithms for 70 pages. In Chapters 6 through 11, he takes up Set operations, Hashed Maps, and Hashed Sets -- thereby showing how to extend the STL. He also presents applications that generate thesauruses, permuted indexes, and cross-references. Engineering vectors and matrices are also presented, but only insofar as storing them. Since matrix arithmetic operations were not addressed, I thought this chapter was kind of a cheat. I was hoping to find a fast Gaussian inversion routine, at least.
The Vector class made no use of the built-in subscript-checking function at(). No attention was given to namespaces, because, of course, it was not in the Standard at publication date. The text reads with a Germanic flavor. The syntax is stilted, but then, who cares? Most of us are reading for the code anyway.
The stated aims of Data Structures in C++, by Timothy Budd, are to help beginning C (!) students solve problems, while assuming that those students are learning about programming in C++. Budd also aims to stress the important while eschewing the incidental. Source code is available via FTP from Budd's personal web site, and there is an errata web page.
The text covers several academic subjects. There is a chapter on program proofs, which introduces the concepts of invariants and pre- and postconditions. Recursion is proffered as a problem solving technique, the function object concept is introduced early, and there is a chapter for each of the basic data structures. Additionally, hash tables, sparse matrices, and graphs are covered.
Data Structures in C++ is also said to be a rewrite of a data structures text, and it feels like it. STL containers are introduced in Chapter 6, so the first 106 pages are actually introductory material.
If I were trying to learn from this text as a raw undergraduate student who knows C, I would've been scared by the introduction, and discouraged in general. Consider this: Chapter 1/Section 1 refers to Chapters 7 through 9, and 12, and then introduces the problem of generating a concordance. Section 1.2.4 discusses bit-wise operators. Section 1.2.6 introduces pointers, but fails to tell why you would want to use them. Later in the text, there are statements of the form: "describing the first few steps will clarify..." These statements intimidate students, especially if the description does not clarify the issue. The text puts the onus of not understanding on the student, rather than the teacher (where it belongs). To add insult to injury, this book has the highest price of the lot, which reminds me of the halcyon days when I was the gouged student. And once again, a database is, sadly, built without relational technology.
My copy of Using the STL: The C++ Standard Template Library, by Robert Robson, is the first edition. I've seen that a second edition is now available for $55.00, although I haven't found a copy yet. The text assumes the reader has a good grasp of C++, and no effort is made to review the language except the barest review of templates.
A good explanation of Big O notation is presented in Chapter 1, along with a table indicating the depth at which to read various sections (skim, dig in, use as reference). Then Robson takes up algorithms. I think this presentation order will appeal to C programmers who are making the switch to C++, since their thinking is still primarily procedural.
For each point to be discussed, the text presents a short example, on the order of 15 lines of code. The example is followed by a listing of trial input and output. I liked this; it makes it fairly simple to mentally execute the code on the page.
Using the STL contains no CD-ROM, and no references are made to a web site. Although most of the examples are small enough to type in, there are several longer examples that would be more usefully presented as source code. A couple of diagrams were not typeset properly. (How do these get by the editors?) Robson uses the HP STL from 1995, so the #includes are all incorrect. Once again, a database is built without relational technology and this is most unfortunate because the names of the fields are hardwired into the application.
Of these books, I would rate Breymann's highest because it is most useful in my circumstance, and the editing is the cleanest. However, its place would be as a supplement to -- not a replacement for -- my copy of Matt Austern's text Generic Programming and the STL : Using and Extending the C++ Standard Template Library (Addison-Wesley, 1998), which remains my primary STL tutorial and reference.
DDJ