Freitag, 11. März 2016

Resources on how to learn C++

With great power comes great responsibility! This applies to C++. Whereas most "modern" programming languages offer you a more abstract view on the underlying operating system and its resources, with C++ you are able to work with the system directly.
If you are a programmer and you want or have to learn C++ for your next project, this is the way I did it and - may I say - I'm very satisified on how fast I was able to learn a good amount of C++ with these resources.

Three important things

With C++ you can of course cover a wide area of programming techniques in different domains. However, when I learn something new, I try to find out the core concepts of the thing i have to learn. With C++, there are the following three concepts every programmer of that language must be aware of:

  1. Object Oriented Programming in general
    C++ is all about object orientation. Therefore, OOP is a real must when learning C++. However, chances are that you have already experience in another OO-language such as Java or C#.
    C++ is different in some details (eg. there are no Interfaces in C++, but you can use multiple inheritance (of abstract classes) which is not available in Java or C#). But in most cases, C++ fits well in what you might already know about OOP
  2. The C++ core language
    Obviously, you have got to learn about the core language. This also includes C++ templates - at least their basics. (Templates may seem similar to what you might know as Generics in other languages. But templates are actually much more powerful in C++.)
    This also includes memory management - which might be new to you if you only used programming languages with garbage collectors before. Memeory management can be real pain if you don't know what you are doing. But if you use the appropriate techniques, the complexity of memory management abstracts away, making your code more stable and flexible. Regarding memory management (and in general) you have to know about:
    1. Objects (both in heap and on the stack)
    2. References (as aliases to objects)
    3. Pointers (raw pointers)
    4. Smart pointers ("managed" pointers that take care of memory management themself)
  3. The Standard Template Library (STL)
    The STL for C++ is what the respective frameworks are for Java and C#. You could write everything from scratch using pure C++, or you can use the implementations of th STL. The STL offers you very powerful, performand and secure implementations of the most important data structures and algorithms. You have to learn about the following concepts:
    1. Containers such as vecotr, map, set or list - how they work and what you use for which types of problem
    2. Algorithms (that can be fed by containers)
    3. Iterators (that act as abstractions for containers, so that the same algorithms work with different kinds of containers)

Resources I used in the beginning of learning C++

Here are some recommendations on resources I used in the beginning. If not mentioned separately, all resources are designed for at least C++ 11, which added a lot of new features to C++ and the STL. If you start learning C++, always check if the resources you look on are written for at least C++ 11. Though you might find a log of very good books for older versions as well.

Online video lectures

Introduction to C++:

The online course "C++ for C Programmers" on Coursera by Ira Pohl (from the University of California, Santa Cruz) provides an amazing introduction in all three of the core concepts mentioned above. Even if you don't do the exercises (which is highly recommended), watching the video alone will give you a very good jump start into the programming.
It covers a good amount of work with data structures, as well as object oriented and algorithmic thinking. As a "bonus", you will learn (and implement) the most important algorithms on graphs :-)

Digging into the STL:

There is a terriffic course available on Channel 9: C9 Lectures: Stephan T. Lavavej - Standard Template Library (STL)
Stephan T. Lavavej is maintainer of the Visual Studio C++ Standard Template Library implementation. So in this course you will learn about the STL from a person who actually implements the (more exactly: one) implementation of the STL. The course is very comprehensive and provides you also with exercises and showcases. After this course you should definetely know all the differences between the importand container data structures I mentioned above and you will be able to exactly know when to use which container.

Books

There are really tons of books available for C++. I was researching in the internet about what books I should get when I started learning and here are the ones I can personally recommend to you:

A tour of C++

This book is written by Bjarne Stroustrup, the creator of C++. Here, Bjarne gives a quick overview over the language, the STL, what is possible and how to use the feature, C++ provides. Don't expect any details here, though!

Kindle / ebook
Paperback


C++ Primer

In addition to the quick tour of C++ there are lots of "big books" available. While Bjarne Stroustrup himself also wrote one of that big books, I decided to get myself a different one - just to have C++ presented from yet another angle.

The C++ primer is written by people with manifold experience who coded in C++ for companies like Microsoft, IBM, Bell Laboratories, AT&T and Pixar. This book provides an in-depth view on all the important concepts and lots of exercises.

Kindle / ebook
Paperback


Effective C++

This book is not intended for beginners. However, in my opinion, it is a must read for every C++ programmer. It contains tons of material on how to make your code more robust, secure and performant. It covers all that important and subtle details that can make the difference between a good program and a mess.

Paperback

Effective Modern C++

This is the pendant of Effective C++ just for the new features braught in by C++ 11 and C++ 14. This book is also highly recommended for anybody wanting to switch from an older version.

Kindle / ebook
Paperback


More of the Effective C++ - Series

As I am very satisfied with that series, I'm going to get myself the other ones as well. These are the following:

More Effective C++: 35 New Ways to Improve Your Programs and Designs

This is part 2 of Effective C++"






Effective STL: 50 Specific Ways to Improve Your Use of the Standard Template Library

I'm definetely looking forward to this one, as it specifically covers the usage of the STL - the bread and butter of every C++ program.

Keine Kommentare:

Kommentar veröffentlichen