Shafik Yaghmour

Compiler Dev(LLDB) interested in C++, C, compilers and undefined behavior.

Where to Get Started Learing C++ and What Resources to Use

05 Sep 2019 » C++, learning

Some variation of the “where to get started with learning C++” or “What are the resources for getting started in C++” has come up often enough on Twitter that I figured it was about time to turn it into a more permenant resource.

I am going to do this in two parts. One is this blog post and second I will post a version of this up as a github repository so that the list can grow and update as needed.

First, use cppreference as your goto C++ reference. It is not a tutorial but it is relatively complete and is kept up to date. It will note the difference between various versions of C++. It has a compiler support section, so you can figure out which versions support which features.

Compiler Explorer aka Godbolt allows you to experiment with C++ (and other languages) live. You type in code and it will compile it on the fly. This allows instant feedback on what you are trying and avoids having to install anything in order to try something out. It easy to share links which can make it easier for others to help you when you don’t understand something.

A second tool C++ Insights allows you to see some of the magic that the compiler does for you when you use features like lambdas, range-based for-loops and structured bindings.

There are a lot of C++ conference/meetup/weekly videos available on Youtube, there is way more than any one person could consume but you are sure to find some great material if you spend the time looking. C++ Weekly and CppCast stand out as two that may be more useful to be those just starting out.

There are many good C++ blogs. They vary in level but whatever level you are at you should be able to find several that give you helpful advice and approaches.

Twitter has a great community of C++ folks who friendly and are happy to help, I have a hand curated list that can be used as a Tweetdeck column or just as a guide for who you might want to follow.

#include C++ is an awesome organization that works for inclusion and diversity in the community and they have a discord server where you can find channels for learners.

Learn about your compilers warning flags if you are using clang or gcc then -Wall -Wextra -pedantic should be a good start but there is a lot of debate on this topic. I personally recomend using -Werror for builds (but not for release) since we should be treating all warnings as errors and fixing them on the spot. One word of caution, clang as the -Weverything flag but it is not meant for production.

Know what undefined behavior is. Know the tools you can use to prevent or catch it (to a degree). It won’t totally make sense in the beginning but in the long-term knowing about it is critical.

There are many books to choose from. For a quick tour of modern C++ “A Tour of C++” is a quick and light introduction. For more in depth coverage of C++ “The C++ Programming Language, 4th Edition” is a good choice. For up to date C++17 coverage either of these two books would be a good bet “C++17 in Detail” and “C++17 - The Complete Guide”.

“Effective Modern C++” and the previous version “Effective C++” are important books to read to understand best practices although they are becoming a little dated.

There are some more specialized books that are worth checking out further along your journey such as “C++ Templates - The Complete Guide, 2nd Ed.” and “C++ Concurrency in Action”. If you want to think in a more functional way then “Functional Programming in C++” is worth a look.

Much later on in your journey reading The Design and Evolution of C++ is essential to understanding where C++ came from and why it is the way it is today. A lot of tough trade-off were made along the way and understanding the choices and why there were made can help you to appreciate the langauge despite its warts.

If you are going to be working in C++ long-term you should become familair with the C++ standard. If you want to refer to standard we have link-able versions online Latest C++ draft. C++11/C++14/C++17 versions of the draft can be found here. Part of the standard process is proposals, for new proposals we can use wg21.link for example https://wg21.link/P0476 .

Thank you Patricia Aas for the feedback on this write-up.

Of course in the end, all errors are the author’s.