Map

Mean-free path of a language

Wiki conceptlanguage-designcognition โ†ณ show in map Markdown
title
Mean-free path of a language
type
concept
summary
How many lines of code you can write before your mental model and the actual program diverge โ€” borrowed from vacuum-system physics as a language-evaluation metric
tags
language-design, cognition
created
2026-04-30
updated
2026-04-30

In vacuum-system physics, the mean-free path is the average distance a particle travels before colliding with another โ€” a measure of how good the vacuum is. The author of pure-systems-blog borrows the term as a programming-language metric: how many lines of code can you write before your understanding of what the program does diverges from what the program actually does. He calls each divergence a surprise.

A high mean-free path doesn't mean the language is small or simple โ€” it means the semantics are predictable enough that you build the right mental model on the way in and stop hitting cases where it's quietly wrong. Languages with implicit conversions, dispatch rules with non-local resolution, hidden allocations, or "spooky action at a distance" tend to score badly. Zig's "no spooky action" philosophy is an explicit attempt to maximize this metric.

The framing is useful for evaluating tradeoffs that are usually pitched as ergonomics. Implicit typeclass dispatch in Haskell is shorter to write than passing the dictionary by hand, but it adds non-local resolution to the mental model. Whether that's a net win depends on whether the resulting surprise rate is acceptable for your domain.

Related: type-systems-vocabulary makes a similar move on a different axis โ€” picking precise terminology so you stop confusing yourself about what a language actually guarantees.