Throw Away Your Code
Source code is read many, many more times than it’s written, so it’s usually worth some effort to help make the code more human-readable.
This quote from Pragmatic Thinking and Learning resonated with me during a recent experience at Readwise.
Last week, while investigating user reports about tweet saving issues, I stumbled upon two functions: pull_tweet_v1 and pull_tweet_v2 (simplified for brevity). As a new engineer, I naturally gravitated toward v2, assuming newer meant better. After some time, I learned from a colleague that v2 was actually deprecated - Twitter’s API changes had forced us back to v1, but the obsolete code remained, silently misleading anyone who encountered it.
This experience highlighted a common challenge in software development: we form emotional attachments to our code. Every function represents hours of effort, making it surprisingly difficult to hit that delete key. We keep code around “just in case” or because ”we spent so much time on it.” But this attachment comes at a cost.
As 37 Signals notes in Getting Real:
You’d think that twice as much code would make your software only twice as complex. But actually, each time you increase the amount of code, your software grows exponentially more complicated. Each minor addition, each change, each interdependency, and each preference has a cascading effect.
Dead code isn’t just harmless digital clutter - it’s a silent productivity killer. When debugging, every line is a potential suspect, and dead code creates false leads that waste precious time. New team members must wade through unnecessary complexity, trying to understand relationships between components that no longer matter.
The solution? As Getting Real suggests: “The way you fight this complexity is with less software. Less software means less features, less code, less waste.” When you find dead code, document what you’re removing and why. If there’s valuable logic worth preserving, capture it in documentation. Remember, Git history is always there if you need to reference something later.
Making this a regular practice isn’t easy - it requires overcoming our natural instincts to hold onto things we’ve created. But like cleaning out an old closet, the result is always worth it. The only real price is a small hit to our ego, and that’s a price worth paying for the sake of those who’ll work with our code in the future - including our future selves.