NOTE

Law of leaky abstractions

#software-engineering (38)#principles (2)

Abstractions promise that you can work at one level and ignore the layers underneath. The promise is never fully kept.

All non-trivial abstractions, to some degree, are leaky.

Joel Spolsky named the pattern in The Law of Leaky Abstractions (2002). A leak is any moment where the hidden layer shows through and you have to reason about it to fix the bug or ship the feature.

TCP is the classic teaching example. The abstraction is a reliable byte stream. Under load or on bad Wi-Fi you still see timeouts and retries. You are not wrong to think in streams. You are wrong to think you will never open Wireshark or read ECONNRESET.

Databases and ORMs leak the same way. SQL is supposed to hide storage layout until you need an index or to debug a lock. ORMs add another layer, where you’ll stay in objects most weeks but once production slows down you have to dive in deeper with EXPLAIN.

Frameworks and hosted platforms compress more surface area (routing, auth, deployment, observability). That compression buys speed until the failure mode lives in configuration, cold starts, IAM, or a dependency version the template never mentioned. The stack trace points through generated code you did not write.

The uncomfortable implication is pedagogical. You cannot learn only the top layer and stay competent when the leak appears. Spolsky’s ASP.NET example was blunt on purpose: if the web request fails, you still need HTTP, HTML, and the network path the page took. The abstraction did not remove that work. At best it deferred it, but more likely it hid the underlying complexity until that complexity mattered too much.

Treat leaks as normal maintenance rather than a failure of the abstraction. When you adopt a tool, ask what layer will surface first when things go wrong (I/O, concurrency, persistence, auth, money). Keep a shallow working model of that layer before you get paged. The abstraction still earns its keep on the happy path. It just does not let you skip the floor below forever.