To be great at anything, you run the extra mile, bench press the extra kg, and yes run the stairs before punching the air. So, as you crush your unrecyclable coffee cup, ignoring the fresh coffee stains on your sweatshirt and the environmental cost, you stare wildly across the Thames you know there’s nothing you wouldn’t do.
So, how to become a great programmer? Read other programmers code. “That’s easy” you rise on the caffeine surge and ready the next step. What should I read? This is where it gets tricky. With the notable exceptions of Knuth and Fitzpatrick most could recommend nothing.
Why am I writing this?
I am reviewing the available information and writing for a beginner reading open source. The best overview pieces are How to quickly and effectively read other people’s code and One sure fire way to improve your editing. This is a summary of all the content I’ve reviwed - the references section makes up all the content. The content is annecdotal - there’s nothing to say this is correct.
What to choose?
The general advice is to choose code that motivates you to understand it - the motivations are:
- Code you rely on
- Code that impresses you
- Code by people you like
If you’re new to code reading then choose something you understand to keep motivation.
Read code actively
The general advice is to have an ‘active reading style’ - take notes, explain problems, and treat it like a puzzle which can mean visual representations of the problem with charts, tables and diagrams - try to offload hard problems to ‘paper’.
- Work through the
- Look at the examples
- Keep and work through a list if there is over two items of interest
- Run the tests
- Choose a feature you are interested in
- Test you understanding by changing the code and running the tests
- Accept that any code other than something you have just written is ‘crap code’
Watching this in action
Videos of this in action brought this together for me:
James Edward Grey II produced two videos on code reading called Codalyzed. He chose small libraries, Mote and Micromachine, and followed the ‘active reading style’. I recommend the videos … but you cannot buy them. There are unedited code readings on dotenv on youtube but the paid videos are better for being concise.
My Next Step
It’s surprising code reading isn’t a popular. Am I missing something? While disappointing, it will not stop me grabbing a library I can ‘grok’ and working through it in an active style.
I have found little on code-reading - are there more references?