Take the 2-minute tour ×

I'm trying to improve my c++ coding technique by reading c++ source code. Which open source project would you recommend? Is the code of Boost C++ Libraries a good one?

share|improve this question

closed as primarily opinion-based by MichaelT, Corbin March, GlenH7, Bart van Ingen Schenau, svick Sep 1 '13 at 11:57


Why close votes? The question is clear and concrete. –  Nemanja Trifunovic May 31 '12 at 17:23
STLs implementations –  dukeofgaming May 31 '12 at 18:53
@dukeofgaming: you forgot the "ironic" tag. –  Doc Brown Jun 1 '12 at 7:20
Well I guess the boost source code won't be that good an idea for a beginner. You will probably drown in templates and SFNINAE techniques you don't understand their workings and reasons yet. –  Christian Rau Jun 1 '12 at 9:22
The close votes are because this question, while concrete, is not constructive. It will just result in a list of everyone's project, where no one answer can be "the answer". For more behind this check out the FAQ. –  Walter Jun 1 '12 at 12:11

8 Answers 8

I would recommend any of Google's open source C++ code, such as the following:

Advantages of using Google code:

  • It's written to high standards and is peer reviewed (unlike some open source code).
  • It has good developer documentation (which makes it easier to pick up and understand).
  • It uses some moderately advanced C++ techniques (and thus is good for learning).
  • It's probably easier to understand than Boost because it doesn't rely so much on advanced template metaprogramming and preprocessor metaprogramming and isn't weighed down as much with countless compiler compatibility hacks and special cases.

The Google C++ Style Guide that Google's C++ code uses is generally good, but it does have some fairly unusual bits (such as some of their naming guidelines or their disallowing exceptions), so keep in mind that their C++ code will differ in those respects from what you'll see in the field.

share|improve this answer

I wouldn't recommend reading a code base. I'd recommend reading C++ FAQS. There's also an excellent book that goes along with the site. Best way to improve your C++ coding skills.

share|improve this answer
-1: I very strongly disagree. Reading other peoples code is very important part of improving one's coding skills. Fixing bugs in that code is even better, though. –  Jan Hudec Jun 8 '12 at 7:49
@Jan Complete agreement from me. However, most C++ source code sucks and employs all kinds of bad patterns that would teach bad techniques. Do you know of a good OSS project which may serve as an introductory reading? –  Konrad Rudolph Jun 8 '12 at 8:48

Reading existing clean C++ code is a great way to learn the language.

The code in the OpenFST toolkit is very clean, for example. It is readable and uses slightly advanced features without going overboard.

Boost, on the other hand, can be a bit hard to read, partly because they use C++ tricks that are hard to understand and because they often sprinkle the code with different workarounds for different compiler versions.

share|improve this answer

I would suggest reading the "Effective C++" by Scott Meyers and using the suggestions he has in little toy programs.

share|improve this answer
You won't learn anything on little toy programs. You need to write programs that solve actual problems. They don't have to be large, you won't manage to write large programs alone, but they must not be just toys. –  Jan Hudec Jun 8 '12 at 9:02
@JanHudec: What you describe is what I call toy programmes: a piece of code that solves a single problem. So, for example a Runge-Kutta algorithm would be a "toy programme" whereas a full N-body simulation would not be. –  Sardathrion Jun 8 '12 at 9:26
Those are both "toy programmes". Because the problems are contrived examples of a problem unless you are doing numerical simulations and most programmers don't. Actual problem is something you or somebody you know is going to actually use. It will probably have GUI or at least rather complex command-line parsing and manipulate files or connect to network and use some existing libraries and won't have any non-trivial algorithms, because 99% programs out there don't. –  Jan Hudec Jun 8 '12 at 9:56
@JanHudec are you saying that a person doesn't learn anything by working with small, constrained problems first? If programmers jump directly into large and complicated problems without learning at least some basic principles and some basic language idioms, this is how we end up with these huge "Big Ball of Mud" apps. –  Onorio Catenacci Jun 8 '12 at 14:30
I'm not sure if this answers the question, but every C++ programmer should read that book (and its sequels.) –  Steven Burnap Aug 30 '13 at 17:08

Try reading something that has been existing for years and is large in size. It will take a few months of time to start to understand the code and getting to do something in it.

Firefox, Thunderbird, OpenOffice.org, LibreOffice come to the mind. There should be many more similar ones too. These projects run on many operating systems and hardware platforms. Also, they have to score on readability. These could should you the techniques you look for.

share|improve this answer

Even better than reading the code would be to work with that code in form of fixing bugs and adding small improvements here and there. Pick some program, preferably one you have use for, sign up to the mailing list, start going through their bug tracker and try to diagnose some bugs. Ask on the mailing list if you find solution for something whether it's reasonable or when you get stuck. That will give you some specific goals when reading the code, force you to really understand and is what you'll be doing most of the time in any work.

You can perhaps look at some KDE application. Most are written in C++ and you can start with some smaller one first.

share|improve this answer

Yes, the code of Boost C++ Libraries is a great resource to learn from, if not one of the best on the Planet. However, for a novice, learning from Boost code may make learning curve very steep. If you really want to try reading Boost, start with some small and simple libraries like Boost.Array.

share|improve this answer
I think that'd be like suggesting a good way to learn to ski is buy hitting the double-black diamond slopes. –  Steven Burnap Aug 30 '13 at 17:09
@StevenBurnap please, read my answer once again and point out that ridiculous suggestion I made. Stop b*****iting, would you, and point out a better comprehensive library worth to read by beginners. You'll come to conclusion that best examples that fit beginners are from a book for beginners. –  mloskot Aug 31 '13 at 19:20

Try reading the C++ PDF. It's free, and I learned C++ from it, even though I had no other programming experience, and I'm only 14. Amazing.

share|improve this answer
Can you add a link to some resource related to this projects? –  Giorgio Nov 12 '12 at 20:26
What C++ PDF do you mean? –  Martijn Pieters Nov 12 '12 at 21:11
