Why is C++ training so bad?

I work on a team that uses C++ for our day-to-day work. Because it is so important to what we do, we care about keeping our C++ skills current, and finding the best way to do things. Unfortunately, keeping current with C++ is a surprisingly difficult problem. This situation seems ironic. C++ is consistently rated in the top five most popular programming languages. It has been around for four decades, and it is constantly changing and evolving. It is arguably the most feature-rich programming language in the world. It is widely used in many industries, and is the gold standard for building complex software projects that require high performance. There are over 5 million C++ developers in the world, a number which has grown steadily over the past decade. With such a large developer population and with so many critical projects using it, there is a large industry writing books, teaching courses, or hosting training courses about C++. Unfortunately, much of this educational material is of poor quality--sometimes it is outdated, sometimes it is overly complex, and sometimes it is just plain wrong. How did we end up here? Why is the available training often so bad? More importantly, what should you do about it?

 

The Multi-Paradigm Problem

To understand why we ended up in this situation, it helps to look at the history of C++. Originally, C++ called itself an "object-oriented" language, or "C with objects." Object-oriented programming started as a way to try and solve problems of code complexity and code reuse. As the language evolved, however, it became clear that object-oriented programming has some downsides. It does allow for some code reuse, but charges a penalty in verbosity and performance. To address these problems, C++ added new programming paradigms. In addition to the structured style of C and the object-oriented style of Simula, C++ also has features to allow for generic programming and functional programming. These features can be combined in many ways, and make the experience of C++ programming feel a little bit like working in a language factory, where you get to invent your own programming style from a rich set of tools. This is why C++ is called a "multi-paradigm" language. This flexibility means that each C++ program can have a completely different way of doing things. Each developer will have their own unique style and best practices, which in turn were shaped by the types of problems they worked on. Most professional C++ developers are familiar with a particular flavor of C++ development, and use only a particular subset of the language most of the time. These combinations of programming paradigms  mean that it's hard to give general advice that applies to all C++ programmers. Even someone with decades of experience in C++ is likely to have focused on a particular flavor or dialect of the language. While they can give advice that was helpful in their own situation, the same advice may be actively harmful to others.

 

The Bright Spots

While it's true that there is a lot of bad C++ advice out there, and relatively few experts who have broad experience with a wide swath of the language, this doesn't mean that there aren't any at all. I have collected here four sources that I found both useful and authoritative.

  1. Stack Overflow keeps The Definitive C++ Book Guide and List. It collects "the few pearls among the dozens of bad C++ books that are published every year." If you wish to buy a book to help you learn C++, I strongly recommend choosing from that list.
  2. You should be aware of and read the core guidelines. The core guidelines are not a strict style guide, and they allow a lot of room for flexibility; this is to help keep the advice independent of the needs of your specific application, while still providing useful best practices. The important thing about the core guidelines is that they are written and edited by the same group of people who design the C++ language itself; this makes them an authoritative expression of what the C++ designers *intended* to do.
  3. Regularly participate in community events, so that you can hear from C++ developers who work outside your domain. CppCon is the most important annual convention targeted to C++ developers. You can attend in person, but they also publish all of the talks on their YouTube channel. There are many of them, so start with "Sort By > Most Popular."
  4. Talk about C++ with your colleagues or others in your community. At Autodesk, I run a "C++ Study Group." Every two weeks, C++ developers from all over the Americas meet and discuss parts of C++ that we find interesting or frustrating. These conversations push us to ask questions and think more deeply about the code we are writing every day.

C++ is a difficult language to learn, but it is also the language that powers some of the world's most fascinating technology. It is fun to work in, and knowing it well can lead to a rewarding career. I hope these resources will help you navigate the mire of terrible C++ advice and become a better developer.

 

 

About the author... Adam Helps is principal engineer at Autodesk