Max Hallinan

Thinking in a Language

I have two ways of knowing a programming language. First, I can know how to write programs in the language. This means knowing the syntax and the semantics. Second, I can think in the language. And this has very little to do with syntax or semantics.

Thinking in a language is a form of practical philosophy. When I think in a language, I adopt a way of relating to problems. This causes me to solve problems in some ways and not in others. The syntax and semantics are secondary. Even the language is secondary, because I can express the same solution in any language that permits the same patterns of thought.

Tagged union types are one example. Several languages support tagged union types. Elm and OCaml call them type but Haskell uses the name data and Standard ML uses datatype. To know how to write programs in those languages, I must know these differences of syntax.

On the other hand, thinking in terms of tagged union types means knowing all four languages at once. The languages support that feature because they share a worldview: my data should closely follow the outline of the problem I am solving. Exposure to that worldview in one language makes me familiar with any language that shares it.

I value knowing syntax and semantics only as much as it enables me to write programs. For example, proficient debugging requires a familiarity with technical trivia because every language is at least a little idiosyncratic. But I don’t treasure this knowledge and I would freely part with it were I never to use the language again.

Learning the syntax and semantics of one language does not give me much advantage in the next language because it does not deepen my understanding of the problems I am trying to solve. Syntax and semantics are the foreign currency left over from a trip abroad. Thinking in the language is a cultural experience that continues to transform my perspective long after I return home. So when I learn a new language, I am most interested in learning how to think in the language.