Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Start by learning C. The best way to learn C is by reading The C Programming Language by Kernighan and Ritchie.

Then read Effective C++, More Effective C++, and Effective STL by Scott Meyers. Then move on to Exceptional C++, More Exceptional C++, and and Exceptional C++ Style by Herb Sutter.

Stay away from Alexandrescu's books. Template meta-programming and "modern C++" is very powerful but will only end in tears. It's great to know this stuff but probably shouldn't be used in production code that you actually want to ship.



I strongly disagree with this advice. If you want to learn C++, learn C++. Well-written C and well-written C++ look very different, and you want to avoid habits from C carrying over into C++.

That said, the Effective * books are great.


In the beginning, a lot of the foundation of the C++ language was laid by taking things that were design patterns in C and making them language features in C++. While I do not subscribe to the idea that learning one thing somehow ruins you for learning another, it is true that if you start out doing C programming, you'll be doing some extra work that is handled for you in C++ by classes and vtables, and be learning design habits you'd have to drop to effectively use C++ later.


+1 on this. I used to advocate learning C as a precursor to C++, but that changed as soon as I took a C++ course: C and C++ code look completely different.

Before then, my justification was that C presented a cleaner environment than C++ to some of the core concepts, like pointers not being cluttered by having to know about references or the `new` operator. But things like that pale in comparison to the overall style of program design between the languages, which I think is far more important.


Raymond Chen has a great quote: "Good advice comes with a rationale so you can tell when it becomes bad advice. If you don't understanding why something should be done, then you've fallen into the trap of cargo cult programming, and you'll keep doing it even when it's no longer necessary or even becomes deleterious." http://blogs.msdn.com/oldnewthing/archive/2009/11/04/9917052...

How dare you simply tell a newbie C++ programmer "Template meta-programming and 'modern C++' ... will only end in tears" without providing a rationale or at least the details of whatever bad experience you had with it. The world has enough cargo cult programmers and enough people who do convoluted things to avoid using some language feature that they believe is "bad" without really knowing why they think it is bad.


Here's my rationale: I've worked on projects that were 1 million lines of code and took a minute or longer to link because of the overuse of templates.


This is the typical advice given by C programmers turned to C++.

Illustrating the best reason why you should NOT learn C before C++...


I learned C++ before I learned C. I've been writing C++ for about 12 years now. I was writing production code during Alexandrescu's Modern C++ era.

Great C++ looks like code written in Meyer's and Sutter's books.

I suggested TCPL because C++ is one huge mishmash of features. TCPL teaches you the basics of function calls, loops, conditionals, memory management, pointers, etc. The Meyers & Sutter books help you write great classes and code that is exception safe, and generic, etc.

All of the other books about C++ I just can't recommend for learning.




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: