The Interpreter Pattern

archetype Social RolesObject-Oriented Design

Categories: software-engineeringlinguistics

What It Brings

A human interpreter stands between two parties who don’t share a language, translating meaning across the gap. The GoF Interpreter pattern maps this onto grammar processing: given a language (typically a simple DSL), the pattern defines a class hierarchy that can parse and evaluate sentences in that language. The human interpreter metaphor frames code as a translator of meaning.

Key structural parallels:

Where It Breaks

Expressions

Origin Story

The Interpreter pattern draws on computer science’s deep connection to formal linguistics. Chomsky’s generative grammars, BNF notation, and the parsing theory of the 1960s all treat language as a formal system amenable to mechanical processing. The GoF pattern extends this: if a grammar can be defined formally, it can be represented as a class hierarchy. The human interpreter metaphor entered because “parser” and “evaluator” feel clinical, while “interpreter” suggests something more alive — a mind engaging with meaning. Yet the pattern is arguably the most mechanical in the GoF catalog, implementing recursive descent evaluation over a fixed grammar.

References

Related Mappings