views:

3622

answers:

13

The best way to learn is by practicing, but it's always good to learn from others who are smarter than you. What is the best example of a well-designed, well coded open-source project? I'm specifically interested in C++ projects, but other exceptional examples would be welcome, as well.

+17  A: 

Boost, it contains a plethora of well-designed, peer-reviewed C++ libraries using advanced C++ design techniques. Using Boost libraries and reading the headers has often taught me new things about C++.

Torsten Marek
I don't fully agree. Boost is wonderful, but it is optimized for portability, features and speed, not for readability. Large parts of it have a higher complexity than any code you'll ever write yourself. Unless you're already guru, most of boost is not the right place to learn.
Leon Timmermans
I've taken a look at a lot of the boost code, and being a library they've had to do things differently than "normal" projects would, but there's a lot to be learned in there, nonetheless.
Eclipse
+7  A: 

See also:

epatel
Thanks, this hadn't shown up in my searching.
Eclipse
+3  A: 

'Best' is a rather subjective thing obviously. In my opinion, the best thing you can do is read a wide variety of different projects' code. What is good for a certain project might not be ideal for a different project, so it's good to see a wide variety of styles and approaches. That said, there are certainly some projects that can still be recommended. If you are not scared away by a large and complex code base, I would highly recommend taking a look at WebKit. Because it is a large and complex project, it is a bit difficult to get your mind around how everything works, but it is remarkably clean and well-written for such a complex project and I think it is a good example of practical C++ code done well.

jonner
+8  A: 

As a Windows developer, I've enjoyed perusing the source code from and learned a learned a lot from these...

WTL

Google Chrome

Winmerge

Songbird

Tortoise CVS

The Matrix Template Library

jschroedl
+1  A: 

I found the C++ codebase of LLVM to be inspiring.

sanxiyn
A: 

practice, practice, practice. don't just code when you have to (like for school or work) but code in your free time to sharpen your skills even if the project or program is just arbitrary, as long as you learn a little something.

It's all well and good to practice, but without outside influences it's very easy to develop some very bad habits.
Eclipse
+2  A: 

There is this similar question: http://stackoverflow.com/questions/27793/well-written-open-source-projects-for-learning

Jim Buck
+1  A: 

ACE/TAO (An OO Network Programming Toolkit in C++)

Tim
+1 ACE: a less-known treasure.
Amit Kumar
A: 

I like my previous project SmartWin++, but I am biased there. Since I'm the founder of that project...

It demonstrates some pretty nifty feature though, but the code is very advanced. Templates "all over the place". Partial Template specialization, policy based design, and even my own invention; "Magic Enums" to inherit from only parts of the implementation of a class...

Thomas Hansen
A: 

You can find some examples in a different thread, though they are in C: http://stackoverflow.com/questions/53264/what-is-the-most-beautiful-code-you-have-ever-seen-or-written#176882

J S
+2  A: 

I learned a lot of good OOAD C++ techniques from the Ogre3d project.

ChalkTrauma
A: 

I figured I'd point out this comment here as a very interesting insight.

Eclipse
+1  A: 

You could check out Crypto++, a C++ encryption library. I've used it for simple MD5 hashing but it's hugely powerful.

From the FAQ:

The library is an powerful and elegant tool for performing complex cryptography. It uses advanced C++ features such as templates, multiple inheritance, and exceptions to achieve that power and elegance.

For people who are familiar with C++, the library will appear intuitive and easy to use. Others may need to view it as a learning opportunity. If you are a C++ beginner and you are under a very tight schedule, or if you are "afraid" of the more advanced features of C++, this library may not be for you.

20th Century Boy