Every developer loves writing code. Few of us love deleting it.

There's something deeply satisfying about building. Adding features. Watching a project grow. Lines of code feel like progress. They feel like work.

But some of the best work I've ever done involved removing thousands of lines in a single commit.

It felt wrong at first. Like burning money. All those hours. All that cleverness. Gone.

Then the tests ran faster. The builds finished sooner. New developers stopped asking questions about that weird module nobody understood.

The codebase got better by getting smaller.

The Weight of Legacy Code

Every line of code is a liability. Not an asset. A liability.

Code has to be read. Understood. Maintained. Tested. Debugged. Every line increases the surface area for bugs. Every abstraction adds cognitive load.

We don't think about this when we're writing. We think about solving the problem in front of us. We think about elegance. About covering edge cases.

We rarely think about the developer three years from now who has to figure out why this exists.

That developer might be you. And you won't remember.

Signs You Should Delete Something

Not all code is worth keeping. Here's what to look for:

  • Features nobody uses anymore
  • Abstractions that only have one implementation
  • Comments that explain what the code does instead of why
  • Fallbacks for browsers or systems you no longer support
  • Clever solutions to problems that no longer exist

If you're scared to touch something because nobody understands it, that's not a reason to keep it. That's a reason to kill it.

Dead code isn't harmless. It misleads. It suggests patterns that shouldn't be followed. It makes grep results noisy. It creates fear.

Fear is the mind-killer. And the codebase-killer.

The Psychology of Hoarding

We keep code for emotional reasons. Not rational ones.

Someone spent time on this. Maybe it was you. Deleting it feels like saying that time was wasted.

But the time is already spent. The sunk cost fallacy is real. Keeping bad code doesn't redeem the hours. It just extends the pain.

There's also fear. What if we need this later? What if there's a reason it exists that we don't understand?

That's what version control is for.

Deleted code is debugged code. It has no bugs. It has no security vulnerabilities. It requires no maintenance.

someonesomewhere on the internet

You can always bring it back. Git remembers even when you don't.

How to Get Good at Deleting

Start small. Find something obviously dead. A function with no callers. A file that hasn't been touched in two years. A feature flag that's been on for everyone since 2019.

Delete it. Run the tests. Deploy.

Notice how nothing bad happens.

Then do it again. Build the muscle. Get comfortable with subtraction.

Eventually you'll start seeing deletion as progress. Because it is.

The best codebases aren't the ones with the most features. They're the ones where every line earns its place.

Every line should justify its existence. If it can't, it should go.

Your future self will thank you. So will everyone else who has to work in that codebase.

Delete more code. Ship less. Sleep better.