Day 1: Read Other People’s Code

This is day one of our series on how to become a better developer in 30 days. During this series, I will discuss during one month 30 ways for anyone to become a better developer.

Today, I would like to talk about something that few people do voluntarily: reading other peoples code.

Writing good code is the goal of most developers, but what we sometimes forget is that in order to become good writers we also need to be good readers. This is just a reality that has been verified since elementary school, when we first learned to write our language by reading how other writers do their job.

Separating Good and Bad

What makes things a little more complicated for developers is the simple realization that there is huge amount of bad code out there. In fact, without any fear of offending anyone, I can say that most code out there is BAD code. By that, I don’t mean just code that barely works, but also code that was not made for “human consumption”, usually as a result of being written under the time pressure to make a release possible.

While this is sadly the most frequent case (for reasons that have mostly to do with the realities of the software industry), this doesn’t mean that developers cannot find good examples of code to read.

In fact, I believe that just the opposite is the case. For example, many available open source programs are written at a high quality level, and could very well be read just for the leaning experience. The Linux kernel is certainly a case in point. The whole kernel is really large, but the central routines are really well maintained and are in used by many schools as a live example of operating system internals.

Another case in point is software written as literate programs. Literate programming is a term created by Knuth for programs that are written is a style similar to an essay.  In such a style, programming language code is secondary to the description of the algorithm in English. Code enters the picture only as a concrete illustration of the comment section. That code is later on be processed by literate programming tools and transformed into an executable artifact. A classic example of literate program is the source of TeX, the typesetting software used by most mathematicians and computer scientists.

What to Look For

Whatever the style of the program you are reading, it is important to make sure that you are learning new techniques. Thus, it is important to read programs with an objective, such as to understand a new programming paradigm, or to learn how to work well with a new API. In these cases, reading code may be a much more efficient way of learning a topic than reading documentation.

One thing that I wished existed in the software development world is a catalog of software that would be interesting to read. Most APIs come with some sample code, which usually is not enough to teach anything useful. An alternative would be a resource where we could list good software to read if you want to learn a specific technique or concept. For example,  to learn how to write a kernel you can read the Linux kernel, or the MINIX. What would be good sources to learn compilation techniques, or the inner working of a database? Let me know if you ever found a resource answering these questions.


To become good writers it is important to read what really works. Sadly, developers don’t take the time necessary to read what other people are doing. What contributes to this issue is the problem that most code is of low quality. I believe that despite this, it is still possible to find a lot of interesting code to read. In the future, we might have a library of open source code that would be voted as great examples for each major technique and concept in software development. I believe this is a fun and useful way to learn how to write better software.

Further Reading

Go to the next posts of the series:

Similar Posts:

About the Author

Carlos Oliveira holds a PhD in Systems Engineering and Optimization from University of Florida. He works as a software engineer, with more than 10 years of experience in developing high performance, commercial and scientific applications in C++, Java, and Objective-C. His most Recent Book is Practical C++ Financial Programming.

10 Responses to “Day 1: Read Other People’s Code”

  1. Agree with you.

    Only by looking other people’s code we can come to know how our code is doing (either good/bad). This is why it is recommended to do peer reviews at all stages of project build.

    Interesting series, expecting the upcoming posts! :)

    By Veera on May 28, 2009

  2. Very accurate and interesting article. It would be really helpful for a Linux kernel programmer to go through the open source code and learn the way to program. However, it is difficult to get open source code in other software technologies like dot net, how would somebody get access to good code?? looking at linux code does not really help with object oriented proramming?? Any suggestions would be helpful. Thanks again Carlos for coming up with the better programmer series…you have stepped up to create a better software world!!!

    By Sam on Jun 3, 2009

  3. @Sam: hi, it is true that the Linux kernel is an extreme example, but you would be surprised at how much code you can find for any technology. You can go for example to and search for your favorite language, such as C, C#, Java, Ruby, etc. You will find lots of free software ready to be discovered. In the end, you can even get new ideas to improve the code and become one of the contributors. This is the way most people start on open source.

    By coliveira on Jun 4, 2009

  4. This is a good article. I had prepared slides that summarize key points in this architecture. PPT slides can be downloaded at:’s%20Code.ppt

    By Xiao Qin on Aug 30, 2010

  5. Thanks for the link Xiao. I am glad you found the article useful.

    By coliveira on Sep 1, 2010

  6. Carlos, thanks for nice articles. Qt is an excellent C++ framework with over 14 years of usage. We can learn lot from Qt code which is available freely. Hope the following Qt API Design Principles helps,

    By A Geek on May 3, 2011

  7. amazon link is wrong.

    it goes to “Understanding Linux Network Internals”
    instead of the intended destination of “Understanding the Linux Kernel”

    By anon on Jun 5, 2012

3 Trackback(s)

  1. May 28, 2009: Benjamin A. Shelton | Blog » Blog Archive » Links: May 27th
  2. May 29, 2009: links for 2009-05-29 -
  3. Apr 15, 2012: Technology | Pearltrees

Post a Comment