The C++ Programming Language

C++ is a Goliath of a programming language and the one essential reference book in every C++ programmer’s quiver is the The C++ Programming Language by Bjarne Stroustrup. This is not a book to read cover-to-cover, which was possible with The C Programming Language by Kernighan and Ritchie.

After many years of C++, to me it is a mess of a language. It has a C past which it cannot and will not shed. It tries to acquire every possible programming paradigm in the worst possible way (procedural, object-oriented, functional and template metaprogramming). And if you follow its development over the years, you quickly realize why design-by-committee is the worst possible way to evolve a language! ­čśÉ

Why that rant on C++? Well, all the confusing mess of C++ continues on in the language reference book by its creator. The organization of the chapters is disappointing and Stroustrup rambles quite a bit when not needed. And when clarification is sorely needed, the minutiae are no where to be found. For example, the explicit constructor is useful to prevent unintended implicit conversions. If you look up explicit in the book to see how to use it, you will not know if this qualifier should be specified in the header or source file or in both. Actually, this qualifier is used in the header and not allowed in the source file, but you would not find that information in this reference.

Also, the examples are uninteresting and the book on the whole is uninspiring. However, since the actual C++ standard is so goddamn un-readable by any mortal, this book remains the prime reference to look up anything about the language. (Thankfully, the STL has a much better book by Nicolai M. Josuttis.) Whenever I need any clarification on any C++ language feature, I look up the index of this book and jump from there. Last updated in 2000 for its Special Edition (3rd Edition), this book is badly in need of a re-write due to the C++0X features introduced since then.

The C++ Standard Library

Rating: 4/4 (A gentle introduction and a must-have reference for all C++ programmers.)

One of the love-hate features of C++ is the standard library. A predominantly large part of the library is the Standard Template Library (STL), which consists of containers, iterators and algorithms. The C++ programmer combines these classes to write his application. Due to the size of the library, the number of classes and functions and their odd eccentricities, a good reference is needed to use it properly. Thankfully, the The C++ Standard Library (A Tutorial and Reference) by Nicolai M. Josuttis is up to the job. This is probably the C++ book which I have used the most in the past few years.

The containers, iterators and algorithms of the STL use template metaprogramming heavily. However, learning this is still quite an uphill task for most programmers. I love this book because it cleanly sidesteps that part of C++, while still being to introduce and provide a compendium of usage of the STL classes. The reader only needs to read and understand the introductory chapters. The rest of the book serves as a reference to lookup when he actually faces a task that needs a container or algorithm. Chapter 6 (Containers) and Chapter 9 (Algorithms) are what I refer to most frequently almost every day. There are very few books which deal with the C++ standard library, thankfully this one is very good! The C++ Standard Libary is a must-have reference for all C++ programmers.

Effective STL

Rating: 3/4 (Recommended for the bookshelf of any STL user)

I find myself using STL a lot in my C++ code. I also found that I was continuously rewriting the STL code, every time I discovered subtle bugs in the way I was using it or when I found a more elegant solution to the same problem. Looking around for wisdom on STL, I picked up Effective STL by Scott Meyers. Scott has authored two other books: Effective C++ and More Effective C++, both of which I have found to be approachable and useful.

Like the other books in the Effective series, this one too has 5x chapters or items, as they are called. The topics they deal with include containers, iterators, algorithms and functors. The whole area of extending STL has been skipped and left for other books. Each item in the book is self contained with a title, introduction, examples, explanations, guidelines and sometimes even trivia. I found the book very useful, showing up mistakes in my code and also sharing a lot of idiomatic methods to write what I wanted. While reading the book, I found myself compelled to go back to my code and start polishing it immediately! Much like the other Effective books by Meyers, Effective STL too is really easy to read, understand and apply. Recommended for the bookshelf of everyone who uses STL.

Related: My notes from this book can be found here.

Create a free website or blog at