Skip to content

Lesson 4 of 17 · Setting the Stage

Reading Code vs Writing Code

Intermediate•
lesson•
September 1, 2026•
~9 min read

You did less typing than you think

Take an honest accounting of the last time you worked on a new feature or the time when you fixed a bug. How much of it did you actually spend typing code that ended up in the diff? An hour? Ninety minutes? Where did the rest of the eight-hour day go?

If you're like every developer I've ever worked with, the rest went to reading.

  • Reading the ticket.

  • Reading the existing class you needed to change.

  • Reading the test that broke after your edit.

  • Reading the model the test depended on.

  • Reading the migration that created the column.

  • Reading the pull request from six months ago that introduced the weird condition you're now trying to remove.

Writing code is a small fraction of the job. Reading code is most of the job. We don't talk about it that way, because writing feels like work and reading feels like preparation, but the time on the clock disagrees.

This is the lesson that should change how you write every line you produce after it.

The ratio nobody talks about

The ratio of reading to writing in a long-lived codebase is roughly ten to one. Robert Martin makes the point in Clean Code. Every line you write today will be read by you, your teammates, the person who replaces you, the auditor doing a security pass, the contractor who joins for two months, and the future engineer trying to figure out why production is on fire at 3am.

The computer reads each line in microseconds. The humans read it for hours, on and off, for years.

If you write code optimized for the few seconds it takes to type, you're optimizing for the reader who costs you the least: yourself, in the exact moment you already understand what you meant. The expensive readers are the ones who matter, and they're the ones you ignore by default.

Why we optimize for the wrong one

Almost everything that teaches you to write code teaches you to write code. Tutorials show you a working snippet. YouTube videos cut to the moment the test goes green. Bootcamps grade you on what you ship. Side projects are dominated by writing because nobody reads side projects.

So you build a decade of instincts around getting code to work, and almost no instincts around how that code feels to a stranger reading it cold.

Then you join your first long-lived codebase and discover that the job is mostly reading, and your instincts are aimed at the wrong half. You write things that pass review, get merged, and become a small ongoing tax on every person who has to walk past them later.

What "easy to write" code looks like

Easy-to-write code has a few common shapes:

  • Clever one-liners that compress three operations into one expression. Fast to type, slow to read.

  • Deeply nested ternaries. Saves three lines, costs anyone reading it ten minutes.

  • Generic names. Manager, Helper, Util, Service, Handler. They mean nothing, so the writer doesn't have to commit to anything.

  • Magic strings and magic numbers used directly inline. Painless to type, opaque to read.

  • Conventions that only the original author knows. "All the validators live next to the controller, except this one, because at the time it felt different."

  • Comments that describe what the code does instead of why.

None of this is malicious. All of it is the path of least resistance when you're focused on getting your own change merged.

What "easy to read" code looks like

Easy-to-read code is mostly boring:

  • Names that say what the thing is, even when they're long. pendingInvoicesForCustomer beats getData.

  • Linear control flow. The reader can scan top to bottom and follow the story.

  • Whats before hows. The top of a function reads like a summary; the details come further in.

  • Predictable shapes. Files of the same kind look like each other. The reader doesn't have to relearn the layout for every new module.

  • One reason to change per file. The reader knows what kind of question this file answers and what kind of question it doesn't.

  • Comments that explain the reason behind a decision, not the mechanics of the loop underneath.

The boring version is rarely the most fun to write. It's almost always the cheapest to live with.

A small worked example

Same logic, two ways. The job: given a list of orders, return the total revenue from paid orders placed in the last 30 days, in cents.

Easy to write:

PHP
<?php declare(strict_types=1); namespace App\Reporting; final class RevenueReport { /** * @param array<int, object> $orders */ public function totalRecentRevenue(array $orders): int { return array_sum(array_map( fn ($o) => $o->p === 1 && $o->c >= time() - 30 * 86400 ? $o->a : 0, $orders, )); } }

It works. It fits on one screen. Anyone reading it has to:

  • Decode p, c, a from context.

  • Remember what 1 means in p === 1.

  • Mentally compute 30 * 86400 and recognize it as "thirty days in seconds".

  • Hold a map and a sum in their head simultaneously.

  • Trust that nothing else in the codebase uses different conventions for the same letters.

Easy to read:

PHP
<?php declare(strict_types=1); namespace App\Reporting; use App\Orders\Order; use Carbon\CarbonImmutable; final class RevenueReport { /** * @param array<int, Order> $orders */ public function totalRecentRevenueInCents(array $orders): int { $thirtyDaysAgo = CarbonImmutable::now()->subDays(30); $recentPaidOrders = array_filter( $orders, fn (Order $order) => $order->isPaid() && $order->placedAfter($thirtyDaysAgo), ); return array_sum(array_map( fn (Order $order) => $order->amountInCents(), $recentPaidOrders, )); } }

More lines. More words. Almost nothing to decode. The reader knows what the code is doing before they understand how, and they don't have to take anything on faith. The names tell the story. The shape tells the story. The work the writer did to get there is invisible, which is exactly the point.

The first version felt smart while writing it. The second one feels obvious while reading it. "Obvious while reading" is the property you actually want.

The hidden cost: reading before changing

The previous lesson was about how the cost of changing code grows over time. Most of that cost is reading.

When a year-three change takes three weeks, you don't spend three weeks typing. Most of that time goes to reading: tracing callers, reconstructing intent, validating assumptions, asking colleagues, opening old pull requests. The diff at the end is small. The reading is what cost the calendar.

That means anything that makes future reading cheaper is a direct discount on every change that touches that area of the code. Better names, smaller files, honest dependencies, predictable structure. None of these are luxuries. They're how you keep the cost-of-change curve from going vertical.

Future you is the most important reader

There's a comforting frame where "writing readable code" is a favor you do for your colleagues. It's true, and it's also incomplete.

The most common reader of your code is you, months from now, when you've forgotten the constraints and conversation that led to the design, and the obvious-at-the-time reason for that one weird condition.

Six-month-old code is, for all practical purposes, someone else's code. You will read your own pull requests with the same confused face you make when reading your colleagues'. The kindness you build in for others is the same kindness you're building in for yourself, just on a longer delay.

This is also the most concrete way to motivate the habit. "Be nice to your team" is abstract. "You're going to open this file when the next bug report comes in and have no memory of writing it" is specific.

The dangerous shortcuts

A few things we all tell ourselves to avoid the cost of writing for readers:

  • "I'll add comments later." You won't. The pull request will be approved, the next ticket will land, and "later" will not arrive. If the comment is worth writing, it's worth writing now, while you still know the why.

  • "It's obvious from context." It's obvious to you, right now, with the full context loaded into your head. That context drains in days. The next reader will not have it.

  • "Anyone reading this will understand." No they won't. The readers will be junior, or tired, or on call, or onboarding next quarter with no idea this part of the system even existed. "Anyone" is a fantasy reader; the real ones are people, and people get tired.

When you catch yourself thinking any of these, you've found a place worth investing thirty seconds in a better name or a one-line comment.

Practical habits

A few things that pay off the next day, not in some distant future:

  • Write the name first. Before you write the function body, write the function signature with the name you'd want to read in a stack trace at midnight. If the name is hard, the design is probably wrong, and that's worth knowing before you write the body.

  • Re-read your diff before pushing, as a stranger. Pretend you didn't write it. If something needs explaining out loud to make sense, the code needs to be changed, not the reader.

  • Optimize the file you're already in. Don't refactor the world. When you touch a file for any reason, leave one or two readability improvements behind. Over a year, this compounds into a much better codebase without anyone ever scheduling a "cleanup sprint".

  • Make clever earn its place. Cleverness costs the reader. It's allowed when it pays for itself, with a real, measurable benefit. Most of the time it doesn't, and the boring version wins.

They're the difference between a codebase that gets easier to live in over time and one that gets harder.

What this isn't

Optimizing for the reader is not the same as writing more code. Verbose, ceremonial code with nine layers of indirection is also painful to read. A function with twelve required parameters and a fifty-line docblock is not "more readable" than a clean three-line one. Readability is about clarity.

It's also not a defense of comments-everywhere. Most comments age badly. The best readability investments are in names, structure, and locality. Comments are a backstop for when the why genuinely doesn't fit in the code itself.

The goal isn't more lines. It's lines that explain themselves to a tired person on a Wednesday afternoon.

The one thing to remember

You write code once. It gets read by humans, including you, dozens of times after that, often years after that, often under pressure. Optimizing your craft for the writer is optimizing for the easiest, cheapest, fastest moment in a line's whole life.

Optimize for the reader. The reader is who you're actually working for, even when the reader is just future you with less coffee and less context.

Course Content