How I Learn(ed) C++
I’m a self taught programmer, the reasons for this choice I’m not going to share here and I don’t think they matter that much, and even though the Internet is full of great resources if you are just starting out programming or C++ in general it’s going to be a bit tough when it comes to choosing from them.
I’ve started my programming journey with C not because I really wanted but because my highschool taught the C programming language and also the forums that I was often reading featured a lot of C stuff, like tools, questions, algorithms they were all written in C.
After a couple of months of programming I’ve got exposed to C++, I don’t remember exactly what but I still remember how I stared for hours at some template heavy code, I was like “what the hell is that alien syntax”.
I got hooked, but what I should use to learn this language? Well I’ve started with some online tutorials but all of them looked like they presented a subset of C++ that closely mirrored C. Everything was full of raw pointers, malloc()/free() kind of manual memory management, C style strings. Unfortunately even today you may find actual books and tutorials that present the language this way and most of us just end up thinking that C++ is just some newer version of C.
Lucky me I stumbled upon The C++ Programming Language, 4th Edition by Bjarne Stroustrup the creator of the language. It’s a fantastic book where you are exposed to C++11 which introduces a lot of new language features. It presents the basics in depth and gradually dives into advanced topics. It’s a heavy book so you’ll likely have to read it multiple times before things actually make sense and you understand them but hower it’s a pleasure to read. I highly recommend it even to professional programmers that want to learn C++.
For like 2-3 years this was my main book the one from which I’ve learned the most, even after I’ve had landed a professional job, this book became like sort of a reference. After getting hired my mentor which suggested a couple of books that really helped me out giving me a better understanding on how the language is used in a professional setting and how certain language features can affect the overall design decisions that you have to take when writing code in C++.
- A Tour of C++ (2nd Edition) by Bjarne Stroustrup
- Effective C++ (3rd Edition) by Scott Meyers
- More Effective C++ by Scott Meyers
- Effective Modern C++ by Scott Meyers
A Tour of C++⌗
It’s kind of a reference book, it’s a good short book if you want to quickly start with C++. You’ll go over the essentials of the language with an emphasis on the standard library abstractions. To take full advantage of this book you should pair it with The C++ Programming Language.
Effective C++ and More Effective C++⌗
Even though these books focus on the language prior of C++11 they are extremely valuable if you want to become a professional in C++, as my mentor said at the time “read these two and you already know more than 90% of C++ programmers out there”.
If The C++ Programming Language lays down the foundation these two books take it to a new level. They teach you how to write good C++ code, what to keep in mind when doing it and what pitfalls to avoid. You’ll learn how to write exception safe code, use RAII to protect your resources from leaking when exceptions do occur and how to use certain language features to efficiently solve problems. The books are structured around items and each item is dedicated to a certain topic making it easier to navigate through.
Effective Modern C++⌗
Another great book by Scott Meyers. This one covers items that revolve around C++11/14 language features. You’ll learn how to efficiently use smart pointers, what are move semantics and how you can leverage it to create efficient data structures, how to work with lambdas, what pitfalls to avoid with concurrency primitives and lastly the auto keyword and its uses.
Where to go beyond books⌗
As far as books go thats it, those are the books that helped me the most so far. Nowadays I rely mostly on cppreference as my main source of information related to C++. It covers a lot of topics from basic language features, to advanced template meta-programming and standard library features such as data structures, algorithms, concurrency primitives and much more. It’s also kept up to date, so the chance that you won’t find some quirk from the latest standard is quite slim.
Another website worth following is isocpp especially their Super-FAQ section which has some pretty good knowledge on classes and inheritance.
If you really want to go full bleeding edge mode you can follow The C++ Standards Committee where you’ll find proposals about what to change in the standard.
Conclusion⌗
I hope that you’ll find these books as helpful as I’ve found them no matter if you’re a beginner programmer or a professional that’s looking to grow.
PS: I’m in no way affiliated with the publishers of these books it’s just my honest opinion.