Rereading Classic C++ Books
Last month I'd been looking for books to help me get better at C++ template metaprogramming. The book "Modern C++ Design" by Andrei Alexandrescu continually came up in searches. I originally passed on it since it was written in 2001.
I was hoping to find a book written post-C++11; a book that incorporated a more recent standard and preferably pointed out how changes in C++11 and C++14 have made for more effective template metaprogramming. However, "Modern C++ Design" kept coming up in Google and Amazon searches.
An interesting item I came across when searching was a 2006 blog post by Scott Meyers titled "The Most Important C++ Books... Ever". I was happy to see that three out of four of the books on the list are books I have in my personal library. These are books I'd owned for years. The list:
"The C++ Programming Language" by Bjarne Stroustrup - Meyers lists editions one through three in his blog post but after the release of C++11 Stroustrup released the 4th edition of this book. I bought it shortly after and continue to read bits and pieces of it to this day.
"Effective C++" by Scott Meyers - I suppose not putting his own book on this list might not be good for sales?... :) Seriously though, there's good info in this book. I've learned a lot from it.
"Design Patterns" by the GoF - I'm a big fan of design patterns and continue to refer to this book years after purchasing it. One of my favorite things about patterns is that not only are they proven software designs but they're also tools for communication. For example, if I'm looking at a new codebase, and I'm told classes X and Y implement the Observer Pattern and class Z is an Abstract Factory interface I immediately know a lot about the code before I've even started looking at it.
"The International Standard for C++" - I'm all about embracing my inner C++ nerd, but if I ever find myself spending copious amounts of time reading the standard I might've journeyed down the path of no return. :) Honestly though, the standard is the definitive authority. And I have seen StackOverflow answers where quoting the standard has helped clear things up.
- "Modern C++ Design" - See, I told you it kept coming up in searches. It was around this time I decided to purchase it. I'm currently on chapter 3. It's not your average C++ book, but it's definitely been an interesting and enlightening read so far.
This blog post by Scott Meyers got me thinking about classic C++ books from my past. For the last month or so I've dedicated a little bit of time each day reviewing "The C++ Programming Language" and "Effective C++", as well as a couple of other well regarded classic C++ books that are in my library:
"C++ Coding Standards" by Sutter and Alexandrescu - 101 Rules, Guidelines, and Best Practices.
- "C++ Common Knowledge" by Stephen Dewhurst - Sixty three items that should be common knowledge for every C++ developer.
Each day I usually read a few pages from the latter half of "The C++ Programming Language" and also an item or two from each of the other three books. It only takes maybe 15 minutes for each and it's great refresher info. As someone who originally learned C before moving onto C++, it never ceases to impress me how much there is to the C++ language and its design concerns.
It's important to keep in mind that "Effective C++", "C++ Common Knowledge" and "C++ Coding Standards" were all written well before C++11. There have been some things in the newer standards that make bits of advice from these books a secondary choice or incomplete but this is minor considering how much overall beneficial info these books contain.
One example is item #56 of "C++ Coding Standards" which mentions a way to "steal" the contents of an object into another object. This was before move semantics existed. And item #6 of "Effective C++" shows how to disable object copying by declaring the copy constructor and assignment operator private. In C++11 we have "=delete".
These are just a couple of the many improvements we've gotten with C++11. These enhancements and many of the others have helped make the programmers intent clearer and also makes the language easier and more powerful to use. Things like this make me continue to appreciate C++11 and beyond.
That said, C++ had been around a good 25+ years before C++11 and I think the books mentioned above do an excellent job of covering best practices, rules and guidelines for writing effective C++.