How to learn C++

C++ is surely the most challenging programming language to learn, probably because it is also the most flexible and generic as you can use it for low level (embedded) and high level development.
Recently a new standard has come out and there are a lot of new interesting techniques which makes our lives easier, but the main concepts of C++ development are still valid.
Here are some suggestions to learn C++ quickly, especially if you come from another programming language (if you are a totally newbie to the Computer Science you’d better buy an introduction book).
This is a working progress list, as there is always something to learn with this language.

  • Adhere to a coding style such as the Google C++ Style Guide
    Every company out there has a coding style, a way to write the source code nicely. Following some strict rules seems a bit boring at the beginning, even restricting your creativity.
    Instead, it is a way to make the source code easier to read (we will read the source code of that function much more often than the time we have spent in writing it!).
    Understanding and use the coding style will make easier to put in practise the several options that you have when writing source code; you will understand, for example, what are the advantages of using or not using exceptions, what are the advantages of using references as input parameters, where to your const, etc.
  • Watch Youtube videos of (or attending) CppCon.
    CppCon is the main C++ conference and listening to the invaluable hints and ideas of the major C++ developers in the world is definitely the best way to speed up your learning process. These people are not only very smart but also very good speakers: you’ll learn quite a lot just watching 1 hours of their videos and then reading the related slides. It’s really an effective way if you do not like reading books.
  • Use a good compiler, enable and pay attention to ALL warnings.
    Clang is my favourite compiler at the moment, it gives you a lot of nice messages and it really helps you to understand all your mistakes.
    Paying attention to every detailed message is a bit of work at first, but in the long term it really pays off as you will start writing much more reliable code after you have understood why the compiler is complaining.
  • Read the right books!
    The C++ community is quite huge, but there are people really great and somehow the fathers of the language.
    You should not waste your time in the first tutorial for dummy: go straight to learn C++ from the people who have created, taught, forged in its standard and used in commercial environment.Here is my list:
    A Tour of C++ – Bjarne Stroustrup
    This is a quick but complete introduction on what you should know to be considered a good C++ programmer.

    Effective C++ – Scott Meyers
    This is one of the best and most common book among the developers: it simply tells you what is the best thing to do among all the possible solutions.
    This book is becoming a bit oldish as it is not updated to the recent standard, but its techniques are still effective and used worldwide (sure compilable!).

    Effective STL – Scott Meyers
    Knowing STL and its containers is basically compulsory when you use C++. This book helps you in understanding what is the best structure, algorithm to use at a given point in your source code. In my opinion in working with structures and algorithms you will gain a kind of attitude which makes you try to find the best solution for a problem.

    The C++ Programming Language – Bjarne Stroustrup
    This is a complete guide of C++. It is more a reference book than a tutorial but it is complete. Stroustrup is clearly a scientist and you can see that every detail of C++ is clearly analysed here, although sometime you feel that the book is overwhelming.
    It is so complete that includes the C++11 standard as it is quite a recent book.

    Effective Modern C++ – Scott Meyers
    This is a really new book, which I have bought it as an online version before the final paper release. It gives you a perfect idea of the ways of working with the new C++11: it is probably the first attempt to write a book only focused on this and then it may seem a bit too “futuristic”, as many features of the standard are still not common around (but look at Facebook for example).

This entry was posted in programming and tagged , , , . Bookmark the permalink.

Leave a comment