What you'll get out of this post
- If you've seen the "another level of indirection" quote and want to actually own the principle, not just nod at it
- If you read the M x N post, the mini AI SDK build, or the MCP series and sensed the same move being made in all of them
- If you want the vocabulary that turns "I'd add a wrapper here" into a precise, named argument -- the kind that lands in a system design interview
This is the parent concept behind several posts on this blog. Master it once and you'll recognize it everywhere: in pointers, in DNS, in compiler IRs, in this year's AI protocols.
This is a living post
Fundamentals don't change, but worked examples accumulate. As this blog builds more things that turn out to be indirection in costume, they get added here. Three are in so far: the mini AI SDK, MCP, and the PTY.
The quote, and what it actually says
"All problems in computer science can be solved by another level of indirection."
The line is commonly attributed to David Wheeler -- the Cambridge computer scientist who, fittingly, invented the subroutine -- and it spread through Butler Lampson's classic Hints for Computer System Design, which credits Wheeler for it (links in Sources). It gets quoted so often because it keeps being true: an enormous share of the field's landmark designs are, at bottom, somebody inserting a level of indirection at the right spot.
The corollary matters just as much, and most quoters drop it:
"...except for the problem of too many layers of indirection."
Hold on to both halves. The first half explains why the trick works; the second is the warning label. We'll get to the warning -- but first, the mechanism.
Key Concept
Indirection
Instead of A referring to B directly, A refers to something in between -- a name, a pointer, an interface, a protocol, a broker -- which resolves to B. That's the whole definition. The power comes from what the middle thing makes possible: once the reference is a first-class object, you can change it, share it, intercept it, and standardize it without touching A or B.
The move, stripped to its skeleton
Change B, and A breaks; share B, and everyone fights; watch traffic to B, and you can't
↓
A depends only on the middle layer -- and the middle layer is yours to manage
Why one trick keeps solving "all problems": the four payoffs
"Indirection" sounds like a single move, but it gets bought for four distinct reasons. Naming which one you're buying is the difference between architecture and cargo cult.
The four things an indirection layer can buy
| Header | Meaning | Example |
|---|---|---|
Swap the target | Change what's behind the reference without touching anyone who holds the reference | DNS (name stays, IP changes), symlinks, feature flags, dependency injection |
Collapse M x N | Both sides adapt to the middle layer once, so integrations grow as a sum, not a product | USB, LSP, compiler IRs, MCP -- the standardization payoff |
Insert a control point | Everything passes through the layer, so the layer can log, cache, authorize, throttle | Reverse proxies, API gateways, virtual memory page tables, ORMs |
Share one thing safely | Many holders, one referent, with the layer managing the aliasing | Pointers, copy-on-write, interned strings, virtual memory (again) |
Two notes worth pinning:
- The same layer often buys several payoffs at once. Virtual memory is a swap (pages move between RAM and disk), a control point (protection bits), and safe sharing (two processes mapping one page). That's why it's one of the most celebrated designs in systems history.
- The "collapse M x N" payoff got its own post -- The M x N Problem -- because it's the one driving this decade's protocol gold rush. But it's one payoff among four, not the whole principle.
Now the fun part: watching the principle wear two completely different costumes in things this blog has already built.
Worked example 1: the AI SDK's intermediate representation
In Build Your Own Mini Vercel AI SDK, the pain was concrete: OpenAI's and Anthropic's wire protocols disagree about everything -- message shapes, tool declarations, stream events. Writing app code against either vendor directly means rewriting your streaming logic, your tool loop, and your JSON repair for every vendor, for every feature.
The SDK's fix is a textbook indirection layer, in the compiler costume: an intermediate representation. The @ai-sdk/provider package defines unified messages, unified tools, and unified stream events -- an "internal English" that only circulates inside the system. App code and core features (the agent loop, stream transforms) are written once against the IR; each vendor gets one bidirectional translator between its dialect and the IR.
Check it against the payoff table:
- Swap the target: changing models means changing one value --
model: deepseek.chat("deepseek-v4-flash")-- because app code holds a reference to the IR contract, never to a vendor. - Collapse M x N: N vendors times M features collapses into N translators plus M features written once. The post does this math explicitly: 3 providers x 4 features = 12 hand-written adapters, erased.
And the corollary shows up right on schedule: the IR can't express every vendor quirk, so the contract carries a providerOptions passthrough -- a deliberate, labeled leak in the abstraction. That's what a well-engineered indirection layer looks like: it knows it's lossy and gives the loss a door.
Worked example 2: MCP's protocol layer
The MCP series is the same principle in the protocol costume. AI applications on one side, tools and data sources on the other, and a JSON-RPC protocol in between: every tool wraps itself as an MCP server once, every AI app embeds an MCP client once, and neither side ever learns the other's internals.
Against the payoff table:
- Collapse M x N: the headline payoff -- the whole first post derives it from scratch.
- Insert a control point: the quieter payoff people miss. Because every tool call passes through the host's MCP client, the host can gate side-effecting tools behind user confirmation, log every call, or refuse some entirely. MCP's split between read-only Resources and side-effecting Tools only works because there's a layer enforcing the distinction.
- Swap the target: the hand-built WordPress server is driven by a DeepSeek CLI one minute and Claude Desktop the next, with zero changes -- each side holds a reference to the protocol, not to the other side.
Put the two examples side by side and the lesson sharpens: one is a type contract inside a single process, the other is a wire protocol across processes. Different costume, different transport, different decade of prior art -- identical move. Indirection doesn't care what the middle layer is made of; it cares that the middle layer exists and is the only thing either side depends on.
Worked example 3: the pseudo-terminal
Why tmux Became the Control Room for AI Agent Teams is the principle in the device costume, and the oldest instance on this blog by several decades. A shell never talks to terminal hardware; it talks to a terminal-shaped kernel interface. Whatever sits behind that interface is free to change -- and it has, three times.
Against the payoff table:
- Swap the target: teletype → CRT terminal → GUI emulator window → tmux daemon, across sixty years, without the shell changing a line of code. Each generation re-backed the same interface.
- Insert a control point: because every keystroke passes through the layer, the kernel implements line editing (Backspace, Ctrl+C → SIGINT) once for all programs -- and tmux taps the same stream to read screens and inject input, which is what lets an agent drive an interactive CLI like Claude Code as if typing.
The corollary shows up here too: programs that genuinely need per-keystroke input (vim, fzf) must punch through the default line discipline by switching the PTY to raw mode -- a labeled escape hatch, same role as providerOptions in the SDK example.
The corollary: what every layer costs
If the first half of Wheeler's quote built modern computing, the forgotten second half explains most of its accidental complexity. Every level of indirection bills you in three currencies:
- Runtime hops. Every reference followed at runtime is a lookup, a translation, a serialization, or a network round trip. DNS resolution, vtable dispatch, an extra proxy in the request path -- individually cheap, collectively the reason your p99 looks like that.
- Debugging hops. This is the cost people underestimate. Each layer is one more place where the answer to "where is this value actually set?" can hide. A request that traverses five layers has five places to lie to you, and
grepstops working the moment a name gets resolved dynamically. - Fidelity. A middle layer carries what it was designed to carry. Everything else either gets dropped (lowest common denominator) or escapes through a side door (
providerOptions, vendor extensions, protocol escape hatches) -- and every side door quietly reintroduces the direct coupling the layer was built to remove.
The failure mode has a face you've seen: the codebase where every class has an interface with exactly one implementation, "for flexibility." That's indirection with none of the four payoffs -- pure cost, bought out of habit. The corollary isn't a joke; it's a budget.
Iron rules
⚡ Iron Rule #1
Name the payoff before you add the layer
Indirection buys exactly four things: swap the target, collapse M x N, insert a control point, share one thing safely. Before adding a wrapper, an interface, or a broker, say out loud which one you're buying. If you can't name one, you're not architecting -- you're decorating.
⚡ Iron Rule #2
Every layer bills you twice
Once in runtime hops, once in debugging hops -- and the debugging bill is usually larger. When you add a layer, you owe the next engineer an answer to "where do I look when this misbehaves?" If the layer doesn't come with that answer, it isn't finished.
⚡ Iron Rule #3
Read architectures by interrogating the middle
When you meet a famous design -- virtual memory, DNS, an IR, a protocol -- ask: what's the level in between, and which of the four payoffs does it buy? The answer is the design, every time. This question is also the fastest way to sound like a systems person in an interview, because it's the question systems people actually ask.
Sources
The quote's provenance, and the primary documents behind the examples:
- David Wheeler -- Cambridge computer scientist, co-inventor of the subroutine; the aphorism is commonly attributed to him
- Butler Lampson, Hints for Computer System Design (1983) -- the classic systems paper through which the quote spread; Lampson credits it to Wheeler
- Indirection (Wikipedia) -- covers the quote, its frequent misquoting as "abstraction," and the corollary
- Language Server Protocol -- the editors-x-languages instance discussed in the M x N post
- Model Context Protocol -- the AI-apps-x-tools instance built by hand in the MCP series
And the worked examples on this blog, in reading order: The M x N Problem → Build Your Own Mini Vercel AI SDK → Why MCP Exists → Hand-Rolling a WordPress MCP → Why tmux Became the Control Room for AI Agent Teams.