Book Deep-Read · A Philosophy of Software Design · Chapter 12
A Philosophy of Software Design · Ch 12 · Why Write Comments? The Four Excuses · Ousterhout · 2nd ed 2021
You buy a new washing machine. The buttons say "Quick", "Heavy", "Delicate". From the buttons alone, can you tell whether "Quick" is fine for jeans, or whether detergent goes in first? The buttons tell you what exists; the manual tells you how to use it and why. Comments in a program are that manual. This chapter is about why many programmers skip them, and why each of their four reasons falls apart.
Many programmers believe that "good code speaks for itself; it needs no comments." The author calls this a delicious myth, like a rumor that ice cream is good for your health: we would love to believe it, but it simply isn't true.
Whoever writes code carries a lot in their head: why it was done this way, where the traps are, when not to use it. The code captures only part of that. If they don't write the rest down, it stays in their head; months later even they forget, and whoever comes next has to read the code line by line and guess. Guess wrong, and you get a bug.
Four common excuses, and the author's answers:
Good comments move what's in the designer's head onto paper: the next person can use the code safely without reading all of it, and is less likely to hit traps they didn't know existed. One honest cost: comments do need to be maintained alongside the code, and left unattended they really do go stale.
Code says what it does; comments say what code can't. Without them, everyone else is guessing.
Want to see why comments are part of the abstraction itself, what a substring method's signature leaves out, how much time comments really cost, and the public debate between Ousterhout and the author of Clean Code? → Switch to Deep
You think comments are a patch for code that isn't written well enough; Ousterhout says comments are part of the abstraction itself. Code can express only a small part of a design; the rest (what a method means, its edge cases, the rationale) can live only in comments. Not one of the four excuses for skipping them (good code is self-documenting, no time, they go stale, the ones I've seen are useless) holds up, and the act of writing comments improves the design.
Chapter 12 opens the book's five-chapter run on comments: this one answers why write them; Chapter 13 covers what to write (things that aren't obvious from the code), 14 naming, 15 writing comments first, and 16 keeping them current when code changes. It builds on Chapter 2's diagnosis of complexity: comments are the main tool against obscurity. In practice it maps to API docs, docstrings, Javadoc and code-review norms.
The author observes that a significant fraction of commercial code, and an even larger fraction of open-source code, is poorly documented or not documented at all. Many developers sincerely believe that skipping comments is right, and their reasons sound respectable.
What happens if you don't fix this? The designer holds information the code cannot express, from a hardware quirk that explains a tricky stretch of code up to why a class exists at all. Unwritten, later developers must re-derive it or guess, which costs time and causes bugs when they guess wrong. And the "later developer" is often you: a few weeks away from a piece of code and you will have forgotten many of its details.
The author calls it a delicious myth, like the rumor that ice cream is good for your health: we would like to believe it, but it isn't true. Good names and clear structure do reduce the need for comments, but a great deal of design information cannot be expressed in code:
The book's example: a method that extracts a substring takes two arguments, start and end. From the declaration alone you cannot tell whether the substring includes the character at end, or what happens when start > end. Those are exactly the things a caller most needs to know.
This leads to the chapter's central claim: comments are fundamental to abstraction. The point of an abstraction is to hide complexity; if users must read a method's code to use it, there is no abstraction, and all its complexity is exposed. Without comments, a method's only abstraction is its declaration, and the declaration is missing too much essential information.
Some say "if you want to know what a method does, read the code." Reading large methods is slow and painful; so some go further and make methods tiny, which produces lots of shallow methods (Chapter 4's anti-pattern) and still doesn't remove the need for comments. The author also stresses that comments are written in human language: less precise than code, but more expressive, so they can give simple, intuitive descriptions.
Something is always more urgent than comments, so they keep sliding down the list, and once documentation may be deprioritized, you end up with none. The author's rebuttal has two layers:
10% of total development time. Even if there is as much comment text as code, typing it probably adds no more than about 10% to the total.More importantly, the most valuable comments are about abstractions: top-level documentation for classes and methods. Chapter 15 argues these should be written during design, where writing them is itself a design tool that exposes interface problems. Those comments pay for themselves immediately.
Comments do go stale, but the author argues this need not be a major problem in practice. Keeping them current doesn't take enormous effort: large documentation changes are only needed for large code changes, and the code changes will take far longer than the comment changes.
Two ways to keep the cost down (developed in Chapter 16): avoid duplicated documentation, so each fact lives in one place; and keep documentation close to the code it describes, so whoever changes the code sees it. On top of that, code review is a great mechanism for catching and fixing stale comments.
The author concedes this one probably has the most merit of the four: every developer has seen comments that add nothing, and most existing documentation is mediocre at best. But the problem is solvable; writing solid documentation is not hard once you know how. The following chapters supply the method, whose core test is Chapter 13's: comments should describe what is not obvious from the code, not repeat it.
The overall idea behind comments: capture information that was in the designer's mind but couldn't be represented in the code. Against Chapter 2's three symptoms of complexity (change amplification, cognitive load, unknown unknowns), good documentation helps mainly with the last two:
The author makes a larger claim too: written properly, comments improve the design; conversely, a good design loses much of its value if it is poorly documented.
Table 1 · The four excuses: what's true, where it goes wrong, the response
| Excuse | The true part | Where it fails | The author's response |
|---|---|---|---|
| Self-documenting code | Good names do reduce comments | Meaning, rationale and conditions beyond the signature can't be coded; forcing readers into the implementation means no abstraction | Treat interface comments as part of the abstraction |
| No time | Something is always more urgent | Typing is under 10% of total time; deprioritized docs drop to zero | Count it in the 10–20% design investment; write it during design |
| Goes stale | It can, and stale comments mislead | Upkeep scales with code changes and is far smaller than them | No duplication, keep it near the code, check in review |
| All useless | Most merit: bad comments abound | Treats "badly written" as "shouldn't be written" | Learn to write the non-obvious (Chapter 13) |
Table 2 · The two camps (per their public debate transcript)
| Question | Ousterhout (this book) | Robert Martin (Clean Code) |
|---|---|---|
| What a comment is | Part of the abstraction; enormously valuable | A failure to express intent in code; a "necessary evil" |
| What to do first | Write clear interface comments; methods can be longer and deeper | Fix the code: small methods, good names, avoid the comment |
| Staleness risk | Missing comments cost 10–100x what incorrect ones do | Treat every comment as potential misinformation |
| Common ground | Both oppose comments that merely restate code; both agree names matter | |
One test: can a user use it correctly without reading the implementation? If not, information beyond the signature is still unwritten, and that is exactly where a comment belongs.
Major language communities all accept that comments are necessary, but stress different things about what to write: some warn against explaining implementation, others against stale comments, which map onto this chapter's first and third excuses.
Evidence and sources · publicly verifiable
A line you can repeat in an interview or review: "The signature is the formal part of the interface, the comment is the informal part; together they make the abstraction." Today your code is also read by AI coding assistants, which likewise see only what has been written down.
① Designers hold much information the code can't express; comments get it out, or the next developer guesses, including you a few weeks later.
② Comments are fundamental to abstraction: a signature is a small part of the interface; meaning, boundaries, rationale and conditions of use need comments.
③ The substring example: the declaration doesn't say whether end is included or what happens when start is greater than end.
④ Forcing readers into the implementation means no abstraction; chopping into tiny methods only makes shallow ones.
⑤ No time: typing is under 10% of development time, comments add roughly 10% at most; once deprioritized, they go to zero.
⑥ Stale: upkeep follows code changes; avoid duplication, keep docs near code, use code review.
⑦ All useless: the excuse with most merit; the fix is learning to write the non-obvious.
⑧ Good comments mainly reduce cognitive load and unknown unknowns, and writing them improves the design.
⑨ The split with Clean Code is a public debate: whether missing or wrong comments cost more decides which side you're on.