Starboy
While listening to Starboy by The Weekend I’m reminded about some codebases that I have to dive into more deeply. When reading codebases, be they for fun or profit, I tend to take a systematic approach to exposing them, described as:
- Get it building and running – not always as easy as it should/could be.
- Change code to break it – Once it’s going I try to make changes to understand how and why they break things.
- Understand all comments – Where applicable.
- Delete all comments – To avoid biases.
- Rename like mad – Going over the code I tend to rename functions and structures to fit my *current( understanding. This is an iterative approach as mu understanding deepens. In good codebases my final rename matches closely the original names.
- Draw pictures – This is an ongoing and also iterative process.
- Refactor code – Once I think I understand what it’s doing I try and refactor the code to my understanding. This hearkens back to breaking things. :p
- (Re) Add comments – Comments are added back based on the understanding achieved (or not) and modifications made.
- Read, read, read – Supplemental reading is an ongoing act.
Some great codebases I’ve read and mucked around with include:
C
- CLIPS – Expert system shell and programming environment
- Supplemental reading: Expert Systems: Principles and Programming
- Emacs – The bytecode interpreter is especially interesting
- io – Prototypal programming language
Clojure
- core.logic – Logic programming library for Clojure & ClojureScript
- Supplemental reading: The Reasoned Schemer
Pascal
JavaScript
- Functional JavaScript – Oliver Steele’s original functional library for JS.
- Supplemental reading: My own thing
- transducers-js – Transducers implementation in JS
Lua
- Fennel – A Lisp compiler targeting the Lua runtime
C++
- Factor – The VM for Factor is pretty amazing
Java
- Guava – Google’s Java libraries
- Supplemental reading: The Guava Philosophy
BASIC
- 10 PRINT – A book about a tiny fragment of Commodore 64 BASIC
Rust
- intermezzOS – A small and simple OS kernel.
- Supplemental reading: The book of the same codebase
Emacs Lisp
- Advice – Function advice implementation
There are countless other interesting codebases to explore and over time I’ll point out some more. These should keep us busy for a while.
:F
2 Comments, Comment or Ping
M
You have a typo, “Guave” should read “Guava”.
Dec 10th, 2018
Aaron Brooks
That’s a great list.
One thing that I find perennially useful is looking at the startup / initialization code. Getting all the pieces up and hooked together says a lot about how the broader system is expected to work.
I’ve also found that understanding core data structures and tracing their lifecycles is very helpful. In the Clojure context, adding clojure.spec.alpha specs where these specs are missing adds helpful insights about your understandings of the domains of values in these data structures / shapes.
I’d say that I typically execute the above activities shortly after getting things up and running and are part of the “break things” step.
Dec 10th, 2018
Reply to “Starboy”