# Mean-free path of a language

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.
