codingbat-like site for C++

I don’t think such a site exists and I doubt it ever will. The reason is that C++ is huge – and I mean reeaallllyyy huge.
When you start to write C++ code professionally (that is, 40hrs per week) and take 1 or 2 hrs for learning new stuff about C++ every day (that is, 5-10hrs per week), reading books and articles, you will need months, if not years, to become a real professional C++ programmer – unworldly presuming your job doesn’t require you to learn any 3rd-party APIs, new tools, technologies, and whatnot, which will distract you from learning C++.
For several years, I have taught C++ to students who already had one year exposure to Java. In 4-5 months, 12-15 lectures, and at the very least twice that time in the lab, I’ve managed to drag them from “Hello, world!” all the way to a short introduction to template meta programming. Everyone who know all of the area covered by that span will tell you that, after this, they’d still be bloody novices.
(Heck, I’m using C++ for >15 years, earn my money writing C++ code >10 years, and still learn new stuff about it almost weekly. And that’s not even considering the huge amount of stuff dumped over us by the new standard, which has been “just around the corner” for several years).

Due to the sheer size of the territory to cover in order to learn C++, and also due to the fact that C++ is old enough that its programmers can be categorized into several generations when it comes to which standard idioms and “best” practices they learned, and finally because (again due to its incredible hugeness) new techniques are constantly discovered and evolving (template meta programming, now a very important feature of C++, was an accident nobody had planned for), the C++ community’s opinions on idioms and practices isn’t as compact as, say, the Java community’s, and can hardly be communicated as a set of a few dozen rules without arousing heated discussions.
(I think the fact that there are several different very good and recommended Best Practices books listing several dozen rules of thumb each, and the fact that some of them managed to later acquire a supplementing More Best Practices book, literally speaks volumes about this.)

You will find many professional C++ programmers who happily use only 30% of what C++ offers. For example, many use it just as an OO language, missing out templates (maybe except for the STL), exceptions, and other very useful stuff. But C++ is a multi-paradigm language. It supports object-oriented programming as well as generic programming, generative programming, a lot of functional programming stuff, and quite a few other paradigms. And it becomes most powerful where those paradigms are combined.


So what’s my advice?

Have a look at The Definitive C++ Book Guide and List.

First make your pick from the beginner’s books. Since you say you already had exposure to C++, I’d recommend Accelerated C++ by Andrew Koenig and Barbara Moo. That’s an excellent introduction which can’t be praised enough for the way it changed teaching C++, but it comes with quite a steep learning curve. Also, with 250 pages, it’s really just a short introduction.
An alternative to that would probably be either Stanley Lippman’s C++ Primer (which, at 1000 pages, covers the same ground in detail) or Bruce Eckel’s Thinking in C++ (which I don’t know) or Bjarne Stroustrup’s classic The C++ Programming Language (also 1k pages) or his newest book, Programming – Principles and Practice Using C++ (which I haven’t looked at yet).
These books come with enough tasks to keep you busy for a while. Add a few of your own to that and you can be busy learning for months.

Then slowly work your way down the list.

The next C++ standard, now generally expected in 2011, will add a few challenging concepts to the language (like rvalue references) and a vastly expanded standard library. (The current draft has almost twice as many pages as the last one.) Unfortunately, since the standard isn’t yet finished, there are no books available teaching it. It’s all spread out in articles and in online discussions (although Wikipedia has a pretty good article about it), and it’s all meant for fluent C++ programmers, not for C++ novices. There is, unfortunately, not a single text out there teaching C++1x to C++ newbies And I’m afraid it might take years before you can make your pick between several recommended books doing this.

And don’t forget the C++ FAQ, which is a pretty good (and very readable) online collection of best practices (and their rationals), although it’s by no means an introductory text.

Leave a Comment