the two hard things

expression

programming

'There are only two hard things in Computer Science: cache invalidation and naming things.'

The line is attributed to Netscape engineer Phil Karlton, and its endurance comes from being true: both problems are about keeping a name or a copy faithful to a changing reality. The community's favorite corollary adds a third: off-by-one errors. Quote it whenever a stale cache and a misleading variable name conspire in the same incident.

There are only two hard things in computer science: cache invalidation and naming things. The joke is Phil Karlton's, and the popular version adds off-by-one errors as a third item that arrives second, which is a better joke and a worse quotation.

Both halves are serious. Cache invalidation is hard because it demands knowing when something elsewhere changed, which is a distributed knowledge problem wearing a performance optimization's clothes, and almost every caching bug is really a question about whose responsibility it was to say the data was stale. The failures are also the worst kind: intermittent, environment-dependent, and invisible in testing where caches are usually cold or disabled.

Naming is hard for a different and more interesting reason. A name is a compressed description of a decision, so choosing one forces you to know exactly what the thing is, and the difficulty of naming is usually a signal that the concept is not clean. That is the practical value hidden inside the joke: when a name will not come, the problem is often the design rather than the vocabulary.

Also known as: cache invalidation and naming things

All glossary entries