tags:

views:

658

answers:

13

In your opinion what are the best C++ projects you have really learned a lot from learning their code? The design should be very clean and easy to follow, although it can be very advanced and huge, to show how good designs can abstract complexity. And of course the code should be available for free.

+23  A: 

boost, boost, and boost.

Edit for clarification due to all the discussions going on in the comments: In general, boost libraries have a very good and very well thought-out interface that's shaped and reviewed by top-notch C++ programmers. If there was an interface I didn't find well designed right from the start, reading the library's rationale or following the design discussions usually taught me why I was wrong and they were right. Sure, the implementation is often hard to read, but that's to be expected in code that compiles with just about every compiler worth to be labeled "C++", and then some. Also, many quirky seeming functions come with a comment explaining why it was done in such a funny way -- that makes me imagine how, in my code, something like this would go unnoticed for years or decades, producing rare and impossible-to-find errors that I would bang my head against until my nose is flat. Heck, just looking at boost::shared_ptr<> has taught me more than quite a few of the C++ books I read.

sbi
Don't forget boost and boost.
fbrereto
There are some parts of boost that I wouldn't exactly consider easy to follow. :)
mcjabberz
and it's not particularly object-oriented. Not sure if that is one of the OP's requirements, but it's tagged as such at least. +1 from me though. Good design > OOD
jalf
I agree, especially those parts which look like auto-generated from some tool :)If someone recommends specific projects in Boost it will be great.
haggag
Boost libraries tend to have very well designed interfaces, but reading through the implementation files is very difficult. They tend to have lots of compiler specific ifdef kludges and preprocessor hacks to get around deficiencies in the language (eg. variadic templates). I wouldn't recommend just reading through many of boost's implementations unless you want to learn about one specific thing that it does.
Greg Rogers
Did I forget to mention BOOST?
Maciek
Boost is not the answer :) ... as Greg mentioned. I like 'using' it a lot, but its implementation isn't what I'm looking for to learn from it what I described in my question.
haggag
The interfaces are good for learning... the implementation is typically full of compiler-specific hacks and so very very ugly. That said... have you tried boost, boost, boost, boost, boost, boost, baked beans, boost, boost, and boost?
coppro
You can learn a lot from poking through the documentation and samples, but yeah, the actual source code teaches you little more than that "portable C++ is messy"
jalf
+3  A: 

WebKit (Safari & Chrome's layout engine) and V8 (Chrome's Javascript engine). They are very big and by no means simple projects but you can learn much more than you barganed for with them.

mcjabberz
+11  A: 

Qt

nmuntz
Qt is much more consistent than boost.
Łukasz Lew
+5  A: 

The Adobe Source Libraries, though not well known, has some real gems in it.

fbrereto
+1  A: 

This isn't the answer to the question you asked, precisely, except obliquely. Have you read Meyers "Effective C++" and "More Effective C++". These are books with paper covers that you buy and read -- admittedly a primitive technique. I realize the internet puts a premium on things being FREE FREE FREE, but sometimes it helps to go with Ben Franklin, who is accused of having said "Empty your the coins from your purse into your mind, and your mind will fill your purse with coins".

John Lockwood
I agree that people should pay some money to earn more money. But the purpose of asking for projects, and not for books, that I want to see living examples which applies all the good things, in the book you mentioned and in other books. And the purpose I wanted it to be free, because I don't think someone will donate his closed source project so others can learn from it :)
haggag
+1  A: 

OpenSSL - one of the first open source, what I used.

den123
A: 

Qt and QCAD

Stewbob
A: 

QuantLib -- and also see the draft book on the design of the library.

Dirk Eddelbuettel
I have an issue with their cavalier attitude to API stability (recently on their mailing list they were contemplating doing sudden backward-incompatible changes to *date functions*, which extremely important in financial software). I wouldn't want my production code depend on them for analytics.
quant_dev
It's a fair comment, yet on the other hand they always said 'no API stability before the 1.0' release. Plus you get to choose when to change production builds. I maintain add open-source add-on project (RQuantLib) and yes, I also had to adapt to their changing interface over the years. But it is a price I am willing to pay given the quality of the library.
Dirk Eddelbuettel
A: 

This is not answering the question.

I've learnt more from reading and debugging crap code than from a well specified and well designed (and documented) code base. And yes, I've learnt from my own crap code!

Learning humility is hard.

Sam
Sure. This helps in debugging/problem solving skills. But not in projects' construction.
haggag
A: 

boost is the best, but do not forget about wide range of Apache libraries (well, not so wide, and most of them written in C, but still interesting). Xerces-C++ was most useful for me.

Kirill V. Lyadvinsky
A: 

I've learned a lot from the discussions on the development of the C++0x standard (sadly now deferred to 201x). It's brought me back to a lot of the STL that I never properly learned in the first place.

Also, the std::bind library in Modern C++ Design blew my mind and got me interested in C++ templates again.

Ether
+1  A: 

ScummVM. It's really well thought out and put together - quite easy to dive into and read.

Josh Matthews
A: 

Poco's codebase certainly is clean and easy to understand. I am sure that most developers can learn a few good things from it.

StackedCrooked
Please explain when you are downvoting.
StackedCrooked
Even I don't understand this; when there's a difference of opinion, it should be commented, rather than bluntly downvoting. I've upvoted you.
legends2k
I suspect boost zealotry :)
StackedCrooked