3 min read

Why read open source code?

I’ve never been a fan of new year’s resolutions because I feel they are doomed. And yet, the holidays are a good time to take a pause and really reflect. I’m thinking I want to read more open source code…

Because accomplished coders did that

via a book I had read in 2011:

From JWZ in ‘Coders at Work’ book :

Is there a key skill programmers must have?
Well, curiosity – taking things apart. Wanting to know what’s going on under the hood. I think that’s really the basis of it. Without that I don’t think you get very far. That’s your primary way of acquiring knowledge. Taking something apart and looking at it is how you learn to build your own. At least for me. I’ve ready very few books about computers. My experience has been digging through source code or reference manuals. I’ve got a goal and, alright, to do this I need to know what this thing does and what this thing does. And I’ll just sort of random-walk through that until I find where I’m going.

From Brad Fitzpatrick in ‘Coders at Work’ book :

Do you have any advice for self-taught programmers?
Always try to do something a little harder, that’s outside your reach. Read code. I heard this a lot, but it didn’t really sink in until later. There were a number of years when I wrote a lot of code and never read anyone else’s. Then I get on the Internet and there’s all this open source code I could contribute to but I was just scared shitless that if it wasn’t my code and the whole design wasn’t in my head, that I couldn’t dive in and understand it.
Then, I was sending in patches to Gaim, the GTK instant-messenger thing, and I was digging around that code and I just saw the whole design. Just seeing parts of it, I understood. I realized, after looking at other people’s code, that it wasn’t that I memorized all my own code; I was starting to see patterns. I would see their code and I was like, “Oh, OK. I understand the structure that they’re going with.”Then I really enjoyed reading code, because whenever I didn’t understand some pattern, I was like, “Wait, why the **** did they do it like this?” and I would look around more, and I’d be like, “Wow, that is a really clever way to do this. I see how that pays off.” I would’ve done that earlier but I was afraid to do it because I was thinking that if it wasn’t my code, I wouldn’t understand it.


Reading code by itself is not a sustainable activity as Peter Seibel has written at https://gigamonkeys.com/code-reading/

To make it a sustainable practice, we will experiment with the suggested “reimplementation of key bits” approach.


Specifically, I’m thinking of 3 steps:

  1. Guess – Imagine how you would implement something (e.g. Redis)
  2. Read – Read the actual source code, but not everything, only the main structure and what you’re fuzzy about in the previous step
  3. Try – Try reimplementing the key bits

This is also inspired by the “I wonder…?; What if…?; Let’s try!” approach in Sesame Street.

Because practice makes perfect

Because it’s challenging and can lead to opportunities

  • Because it’s challenging 🙇🏽
  • Because it’s fun 😅
  • Because it will lead to more knowledge 🎓, maybe some open source contributions 👩🏽‍💻, and maybe better job opportunities 💰.

Update on Aug 17, 2022

Also see: