Leaky abstraction
Description
Every non-trivial abstraction eventually leaks: characteristics of the underlying substrate become visible through the abstraction boundary, exactly when you were hoping you could ignore them. Spolsky’s framing: a TCP socket abstracts the network as a reliable byte stream, but latency, packet loss, and partial reads are all still your problem; an ORM abstracts the database as objects, but query performance and transaction semantics are still your problem. Structurally, the abstraction is a container hiding a substrate; the leak is the inverse direction of the projection that built the container. Since projections are generally non-invertible, the substrate’s structure remains in some way visible through the boundary — even if the abstraction’s API doesn’t acknowledge it. The leak isn’t a bug in any specific abstraction; it’s a structural property of the abstraction-substrate pair.Triggers
User-initiated: User describes an abstraction that “should” hide complexity but is forcing the substrate’s character on them anyway. Vocabulary cues: “leaks,” “implementation detail,” “bleeds through,” “I have to think about [substrate concept] anyway.” Agent-initiated: Agent notices that a system’s documented API doesn’t fully describe the surface the consumer has to design against. Candidate inference: “what substrate property is leaking through; is it benign or load-bearing?” Situation-shape signals: Documentation that says “you usually don’t have to worry about X, but…” Bug reports that only fire at scale or under unusual load. Performance discussions that require understanding multiple layers of the stack.Exclusions
- Trivial abstractions —
let x = 5doesn’t leak; the abstraction is essentially nothing. Spolsky’s framing applies to non-trivial abstractions. - Abstractions designed to expose substrate — debuggers, profilers, observability tools intentionally surface substrate detail; “leak” is the wrong frame because exposure is the point.
- Lossless / invertible projections — rare in software, but where they exist (a perfect cryptographic hash, for equality purposes), the abstraction doesn’t leak in the same structural sense.
Structure
Relationships
- container — leaky-abstraction is container + projection; the container is the abstraction, the projection is what makes the inverse fail.
- seam — leaks happen at seams; the seam between abstraction and substrate is where the projection’s failure surfaces.
- surface — the abstraction has a surface; the leaks are surface anomalies that don’t fit the documented API.
- load-bearing — diagnostic question for leaks: is the leak load-bearing for the consumer (you must design around it) or decorative (you can keep treating the abstraction as-advertised)?
- stack-layer — leaks are stack phenomena; the leak from layer N+1 forces consumers to reason about layer N.
Examples
TCP-as-reliable-byte-stream · computer-science
TCP-as-reliable-byte-stream · computer-science
ORM-as-object-model · computer-science
ORM-as-object-model · computer-science
Brooks (1975), *The Mythical Man-Month* — earlier intuitions about abstractions failing under scale. · computer-science
Brooks (1975), *The Mythical Man-Month* — earlier intuitions about abstractions failing under scale. · computer-science
Garbage collection as memory model · computer-science
Garbage collection as memory model · computer-science
Hyrum's Law ("with sufficient users of an API, it does not matter what you promise in the contract: all observable behaviors of your system will be depended on by somebody") — extends leaky-abstraction to interface-evolution dynamics. · computer-science
Hyrum's Law ("with sufficient users of an API, it does not matter what you promise in the contract: all observable behaviors of your system will be depended on by somebody") — extends leaky-abstraction to interface-evolution dynamics. · computer-science
Joel Spolsky (2002), "The Law of Leaky Abstractions" — the canonical articulation. · computer-science
Joel Spolsky (2002), "The Law of Leaky Abstractions" — the canonical articulation. · computer-science
leaky-abstraction is therefore tightly coupled with stack-layer (you can only have a leaky abstraction if there’s a layer to leak through) and container + projection (a container that purports to contain everything important but whose contents leak via projection back to the underlying medium).LLM-as-deterministic-API · computer-science
LLM-as-deterministic-API · computer-science
REST as resource model · computer-science
REST as resource model · computer-science
Synthetic-fixture testing · computer-science
Synthetic-fixture testing · computer-science