Channels ▼
RSS

Accelerating C++ Programming


Mar01: Programmer's Bookshelf

Peter is the president of Engineering Objects International, producers of commercial and custom Delphi and C++ components. Peter can be contacted at http://engineeringobjects.com and peteroth@erols.com.



Accelerated C++: Practical Programming by Example
Andrew Koenig and Barbara E. Moo
Addison-Wesley, 2000
352 pp., $34.00
ISBN 020170353X

Accelerated C++, by Andrew Koenig and Barbara E. Moo, is the answer to the question, "What is the best book for me to buy to learn C++?" Obviously, an introductory text is aimed at the beginner, but you must seriously consider this book if you have a small education budget and are looking to optimize your learning.

Because of the clear writing and the explanations of the subtleties inherent in C++ programs, more advanced programmers will also enjoy this text: the journeyman, who has been coding in C++ for a couple of years and who wants to improve her code; the teacher, who is looking for an introductory course text; and especially, the student who has enrolled in a course in which the professor announces on the first day of class, "a knowledge of C++ is assumed."

Accelerated C++ is the third book in the "C++ In-Depth Series," edited by Bjarne Stroustrup. As is the custom with these books, there is no CD, but there is a web site (http://www.acceleratedcpp.com/). As of this writing, the site lists the Contents, the Preface, and Errata.

Std::Hello, std::world!

You might think that the seven pages used in Chapter 0 to describe Hello, world! is more than anyone could possibly say about such a tiny program, but this is seductive writing. Accelerated C++ draws you into how the language works, whilst laying the groundwork for what follows.

Chapter 1 continues with another small program that extends hello world to use <string>, and you get to play around with streams. By Chapter 2, you are hooked because you are succeeding. You have a few working programs under your belt, so now you're ready for control structures. Up to this point, the only types introduced have been string, char, and int, but when you finish the chapter, you are already thinking in terms of loop invariants. You are also convinced that asymmetric ranges, used later in iterators, are the obvious "natural" way to count.

Each chapter ends with a set of exercises, the first of which is always "run the programs developed in the chapter." Accelerated C++ assumes that you already know how to build a program (edit, compile, and link), and then run that program on your system. The tasks that the example programs solve are simple enough that they don't obscure your focus on the language.

The book takes you up the learning curve smoothly through the first eight chapters. These are the clearest presentations I've seen of lvalues, objects, reading input files, typedef, and the like.

After Chapter 8, the air becomes somewhat more rarefied. At the close of the book, Chapters 14 and 15 are what I would call "optimizing" chapters. That is, given a solution to a programming problem in an earlier chapter, these chapters consider ways to make the previous solution faster, smaller, easier to modify, easier for clients to use, and so forth. These chapters implement yet another level of abstraction, and are thus more difficult to understand.

On an initial power scan of the book, I thought, geez why are there floating-point divisions all over the text? Closer inspection revealed that the authors have listed cross references as section number/page number; for example, 11.5/203. I soon overcame my distaste for this notation when I realized that my practice with cross references was to search for the section, observe the page number, then flip back to the reference and pencil in the page numbers myself. Here, the authors have used their machines to do the work for me (thanks!). I recommend this technical improvement to other authors as an aid to their readers. If we shouldn't use our technology, who should?

Right after Accelerated C++ hit the stores, posts to the comp.lang.c++.moderated Usenet newsgroup indicated that varying levels of adjustments needed to be made to the code in order to compile it with various compilers. So why wasn't the book written to cater to the whims of Visual C++ 6, or one of the other popular compilers? Koenig responded in part with: "I'm the project editor for the C++ Standard. If I shouldn't write a book that teaches Standard C++, who should?"

So What's Missing?

I asked Koenig via e-mail why user- defined namespaces were not presented. He responded that there was simply no way to cover everything within their prescribed page limitations.

I also note that there is no emphasis on the "software-design process" per se. Rather, the approach is more like "active problem solving with C++," such that the software design is provided implicitly as part of the answer to the problem. Of course, a complete list of omitted topics is unwarranted: After all, this is an introductory book.

Conclusion

It looks like the authors had fun writing the book. More than any other writer, Koenig uses the mantra "any problem can be solved by introducing an extra level of indirection." Keep this in mind when you discover the "Easter Eggs" in the index.

Accelerated C++ is not perfect, as the typo list on the web site attests. However, it incorporates a wry sense of "play," contributing to the idea that learning should be fun, and then supports that idea by ensuring that the student succeeds. I therefore rate it a "must-read" for C++ programmers.

DDJ


Related Reading


More Insights






Currently we allow the following HTML tags in comments:

Single tags

These tags can be used alone and don't need an ending tag.

<br> Defines a single line break

<hr> Defines a horizontal line

Matching tags

These require an ending tag - e.g. <i>italic text</i>

<a> Defines an anchor

<b> Defines bold text

<big> Defines big text

<blockquote> Defines a long quotation

<caption> Defines a table caption

<cite> Defines a citation

<code> Defines computer code text

<em> Defines emphasized text

<fieldset> Defines a border around elements in a form

<h1> This is heading 1

<h2> This is heading 2

<h3> This is heading 3

<h4> This is heading 4

<h5> This is heading 5

<h6> This is heading 6

<i> Defines italic text

<p> Defines a paragraph

<pre> Defines preformatted text

<q> Defines a short quotation

<samp> Defines sample computer code text

<small> Defines small text

<span> Defines a section in a document

<s> Defines strikethrough text

<strike> Defines strikethrough text

<strong> Defines strong text

<sub> Defines subscripted text

<sup> Defines superscripted text

<u> Defines underlined text

Dr. Dobb's encourages readers to engage in spirited, healthy debate, including taking us to task. However, Dr. Dobb's moderates all comments posted to our site, and reserves the right to modify or remove any content that it determines to be derogatory, offensive, inflammatory, vulgar, irrelevant/off-topic, racist or obvious marketing or spam. Dr. Dobb's further reserves the right to disable the profile of any commenter participating in said activities.

 
Disqus Tips To upload an avatar photo, first complete your Disqus profile. | View the list of supported HTML tags you can use to style comments. | Please read our commenting policy.
 

Video