Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've heard that you should read 10 times more than you should write. This applies to both literature and source code. Therefore, I'd like to study the best c++ packages we've developed.

I'm interested in discovering extremely high quality software packages that use c++, c and assembly. This begs the question, "What determines high quality?". Well, that's kind of up to you. Could you provide a bulleted list of your reasons for choosing your packages and also the list of open source c++ packages.

For example my list of qualities that I think make good software are:

  • Well commented (with full javadoc comments for every function, method and class signature)
  • Well organized (files broken up into logical, manageable pieces)
  • Well documented (a reasonable amount of up to date, bug free documentation. Hopefully with some documentation on the high level structure)
  • Well named classes and variables (succinct, verbose variable names; this should reduce the need for inline comments, however inline comments are always welcomed; no single-letter variables)
  • Should have unit tests.
  • Consistent style and formatting.
  • Hopefully demonstrates clean and recommended usage of a good library like Boost, Qt, STL, etc.

My list of packages is:

I'm aware of this post. It's two years old and doesn't have the list of reasons.

Thank you very much for your contributions, in advance. :-)

UPDATE: I've created a github repository will all of the packages listed below. I'll continue to update it as more are added.


migration rejected from Dec 13 '13 at 10:50

This question came from our site for professional and enthusiast programmers. Votes, comments, and answers are locked due to the question being closed here, but it may be eligible for editing and reopening on the site where it originated.

closed as off-topic by gnat, GlenH7, MichaelT, Kilian Foth, Bart van Ingen Schenau Dec 13 '13 at 10:50

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions asking us to recommend a tool, library or favorite off-site resource are off-topic for Programmers as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it." – gnat, GlenH7, Community, Kilian Foth, Bart van Ingen Schenau
If this question can be reworded to fit the rules in the help center, please edit the question.

Nothing wrong with single letter variables. – unapersson Apr 27 '11 at 22:37
I disagree. Expect for in for loops, they miss opportunities to tell the reader about the code. Why not just write it in hex? Source code is human readable for a reason. It's supposed to make sense to humans as well as compilers. If you don't like to type out variables, get a proper IDE that autocompletes. – Homer6 Apr 27 '11 at 22:44
@Homer I've spent quite a proportion of my life writing instructional materials for programmers, and all our tests indicated that shorter LOCAL variable names (of which you will have perhaps two or three in a function) are more readable. – unapersson Apr 27 '11 at 22:51
Okay, first you should make up your mind: which do you want: well commented, or Javadoc? Never the twain shall meet. Likewise, do you want "succinct", or "verbose"? The two are virtually diametrically opposed. You'll also notice that in C++, the emphasis tends to be more on the code itself than all the "other stuff" that you've emphasized. – Jerry Coffin Apr 27 '11 at 22:53
you're welcome - i tried to make up for it by leaving a response, which i see you saw, and i hope you'll find useful. cheers – justin Apr 28 '11 at 5:18

one recommendation i'd like to make is the llvm project:

the most publicly prominent subproject here is the clang compiler.

the project is:

  • designed to scale well.

  • designed for modularity and reuse.

  • issue resolution turnaround is generally low.

  • well documented.

  • employs fairly modern practices.

  • has several unit and regression tests.

  • is very active (a positive and negative).

  • follows conventions i generally find agreeable (although personal)

  • has good debugging, diagnostics, and error reporting which (by and large) don't significantly interfere with production releases.

  • has taken its audience into consideration.

  • considers portability.

  • etc.

sure, there are several things i'd have done differently (including differences in taste - and i don't mean to imply the end result would be better, just different), but i think it fits the criterion of the topic, and is worthy of mention, and that much useful information can be gleaned from reading the sources.

often digging is CLang codebase (trying to contribute with only several hours a week) I must admit it's relatively easy to hop in. I don't agree with a number of naming conventions (but that's always subjective), but the coding standard is clear, and the code follows. Like many open sources it could do with more documentation though :) – Matthieu M. Apr 30 '11 at 12:32

I not sure the analogy between literature and programming is perfect. In my experience reading other people's code, and I've read a lot, teaches you more about coding style and habits than it does about the way the code works.

Style is extremely important and many elements of my coding style have been copied from programmers whose code I have read. But to understand code there is nothing more valuable than really diving into it, not just reading it. And nothing forces you to understand it better than a concrete task like:

  • fixing a bug
  • adding a feature
  • using it as a component is your application

or just single stepping through the debugger. This "hands on" use of other peoples code is more valuable than passively reading through code.

However you do it, I agree that exposure to other people's code is a good thing and is an excellent way to learn new techniques and approaches to solving problems. Good luck!

+1 for a unique perspective... valuable – Homer6 Apr 28 '11 at 2:30
the exception I would add to this is that diving into a piece of well written code, struggling through it, and eventually learning their design pattern from the bottom up is a very rewarding and useful exercise. You learn many tricks and techniques that you would have otherwise not learned. – Jonathan Henson Mar 16 '12 at 16:57

sqlite3's source code is around 13~14 K lines. Considering it implements an SQL parser among other things a DBMS has, it is small.

There is adequate comments. Appears to follow GNU style indentation. There is a good deal of callbacks.

EDIT: Also, consider looking at pcc (Portable C Compiler). It is very small, development happens with no rush and the number of developers is not very big too. It can compile itself, and implements many C99 features.

Looks like a good project (and very popular which may make it practical). Thx. – Homer6 Apr 28 '11 at 6:13
+1 - forgot to bump this one... good suggestion. – Homer6 Apr 30 '11 at 4:17
SQLite is written in C, not C++ – Imran May 5 '11 at 1:30
It is. Since the question is open to C++, C and assembly, I think sqlite is fine for a suggestion. – vpit3833 May 5 '11 at 1:39
you must be joking. Last time i looked it was more like 150K lines. – Jo So Sep 15 '15 at 6:13

Catmother is one of the best organized, best formatted and laid out C++ code bases I have ever seen. And I have seen a lot of code since 1983!

It was a pretty advanced 3D game engine when it was written and the code stands up even today almost 10 years later, especially the tight integration with Lua for scripting.

This code base is especially easy for Java programmers to dive into even though it is C++.

+1 - I like! Nice, clean code. Well documented. Thank you for your contribution. – Homer6 Apr 30 '11 at 4:16
I like how they reimplemented java.lang in C++ ("lang/ -- Core classes, e.g. Unicode support and thread-safe reference counting. -- Designed to match closely java.lang.*") – quant_dev Apr 30 '11 at 16:45
C++ is never easy for Java programmers. – Sjoerd May 5 '11 at 0:44
@Sjoerd, Java is never easy for C++ programmers either. ;-) But in all seriousness take the time to look at the code. It is C++ that is in all seriousness the most assesable C++ to Java programmers. – Jarrod Roberson May 5 '11 at 5:21
It's only for windows right? – qed Feb 9 '14 at 11:45

Qt is pretty excellent. They have good standards w.r.t. code, documentation, public and private data etc.

It's a mature cross-platform project with a lot of classes and interactions, so in terms of OOP design it's pretty neat too. There are many different subsystems (of different sizes) that interact so you should be able to find a smaller part (the state machine for instance) that is more graspable, than say the widget hierarchy.

One caveat though: Since it's old (& cross-platform), it does not use templates as much as more "modern" C++ frameworks might do (simply because writing template code that works on many compilers was nearly impossible at the time Qt was created.)

Thanks for your contribution. However, I was looking more for a package than a library. And, I also mentioned Qt in my question. – Homer6 May 6 '11 at 16:55
Ok. What's the difference? OSG is definitely a library/framework in my view. – Macke May 6 '11 at 16:59
Fair enough. +1 for good example and reasoning. Thx – Homer6 Feb 8 '13 at 21:43

I think you're missing one of the best examples of modern opensource C++ out there. It's a beautifully crafted, powerful and easy-to-use library called POCO. Quoting their web:

Modern, powerful open source C++ class libraries and frameworks for building network- and internet-based applications that run on desktop, server and embedded systems.

And they seem to be quite proud of it:

Written in modern, standard ANSI C++, using the C++ Standard Library. Modular design, very few external dependencies, builds out-of-the-box. Good mix of "classic" object-oriented design with modern C++. Clean, easy-to-understand code (we frequently get compliments on that), consistent coding style, comprehensive test suite.

I hope you enjoy looking at its source code, and maybe learning some advanced C++ stuff :)

+1 - Wish I could upvote this more. I hadn't discovered POCO when I wrote this question before, but have since used it for several projects. I love it. – Homer6 Feb 8 '13 at 21:39
Thanks Homer! POCO is great! – David A. G. Feb 10 '13 at 23:03

I wouldn't start analyzing a project with 1 Mio Lines of Code. Take something smaller. If you're at the beginning of learning C++, you should also avoid looking at the sources of the Boost-Library (Template Meta Programming - completely different from "normal" C++). If you want to use Qt4 in your later projects take a look at QLandkarteGt or Meshlab. Or use a code search machine like

Also a good starting point to improve your coding style is to read a book from Scott Meyers.

Not all of boost is template metaprogramming. Sure, things like proto certainly are, but things like program_options are plain old C++. – Billy ONeal Apr 27 '11 at 23:49
Thanks for the comments. I've read Scott Meyers' books. I've read smaller projects. And with all due respect, I'm not interested in "starting small". I've already started. What I want it to read the best of the best. I want to stick my hand into the bucket of glue that is genius, because when I pull it out, some of that genius will indelibly be on me too. – Homer6 Apr 27 '11 at 23:51

Not the answer you're looking for? Browse other questions tagged or ask your own question.