Skip to content
← All writing
2026-06-12 · 11 min read fundamentalsarchitectureabstractionindirection

Another Level of Indirection: The Oldest Trick in CS

Pointers, DNS, the AI SDK's intermediate representation, MCP -- one principle underneath. What an extra layer buys, and what it costs.

What you'll get out of this post

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

Direct
A depends on B itself

Change B, and A breaks; share B, and everyone fights; watch traffic to B, and you can't

↓

A
→
the level in between
name / interface / protocol / broker
→
B

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

HeaderMeaningExample
Swap the targetChange what's behind the reference without touching anyone who holds the referenceDNS (name stays, IP changes), symlinks, feature flags, dependency injection
Collapse M x NBoth sides adapt to the middle layer once, so integrations grow as a sum, not a productUSB, LSP, compiler IRs, MCP -- the standardization payoff
Insert a control pointEverything passes through the layer, so the layer can log, cache, authorize, throttleReverse proxies, API gateways, virtual memory page tables, ORMs
Share one thing safelyMany holders, one referent, with the layer managing the aliasingPointers, copy-on-write, interned strings, virtual memory (again)

Two notes worth pinning:

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:

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:

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:

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:

  1. 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.
  2. 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 grep stops working the moment a name gets resolved dynamically.
  3. 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:

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.