Law of Leaky Abstractions
All non-trivial abstractions, to some degree, are leaky.
Tiny Summary
Law of Leaky Abstractions: "All non-trivial abstractions are leaky." Perfect abstractions don't exist—underlying details eventually leak through. You can't completely hide complexity.
The Law
Joel Spolsky (2002): "All non-trivial abstractions, to some degree, are leaky." You can never fully hide implementation details. Abstractions fail in edge cases.
Examples
ORM: Abstraction says "just use objects, ignore SQL" → Reality: N+1 query problem. Must understand SQL joins to fix. Abstraction leaked.
HTTP Requests: Abstraction says "just await response" → Reality: Timeouts, retries, status codes, CORS. Must understand HTTP to handle errors. Abstraction leaked.
High-level languages: Abstraction says "strings just work" → Reality: Encoding issues (UTF-8, ASCII, Latin-1). Must understand character encodings eventually. Abstraction leaked.
Why Abstractions Leak
Complexity can't be eliminated, only moved: Abstractions hide complexity, but it still exists. Edge cases reveal hidden details.
Performance matters: Abstraction adds overhead. Sometimes need to optimize. Requires understanding what's underneath.
Failure modes differ: Abstracted and underlying systems fail differently. Must understand both to debug.
Implications
You still need to learn the underlying system: Can't use ORMs without knowing SQL. Can't use frameworks without understanding HTTP. Can't use libraries without reading docs.
Abstractions help, but aren't magic: Start with abstraction (higher productivity). Learn underlying details as needed. Be ready to drop down a level.
Leaky abstractions compound: Framework on library on protocol. Each layer leaks. Debugging requires understanding all layers.
Examples by Layer
Network: TCP provides reliable stream (abstraction) → Head-of-line blocking, slow start algorithm (leak)
Database: SQL abstracts storage (abstraction) → Query plans, indexes, table scans matter (leak)
Memory: Garbage collection manages memory (abstraction) → GC pauses, memory leaks, heap exhaustion (leak)
Cloud: "Serverless" means no servers (abstraction) → Cold starts, execution limits, pricing models (leak)
Living With Leaky Abstractions
Start high-level: Use abstractions to move fast. Learn incrementally: Encounter leak → Learn underlying layer. Know when to drop down: Performance problem → Profile, optimize. Strange bug → Understand abstraction internals. Good abstractions leak less, but all non-trivial abstractions leak eventually.
Key Insights
Perfect abstractions are impossible. All abstractions eventually leak their internals. Can't avoid learning underlying systems. Abstractions help productivity but aren't magic. When things break, you need to understand what's underneath.