Programming as a secondary language
Recently, a friend asked what languages I spoke. Dutch, English, a passable amount of German. “And programming languages!”, she remarked. I was quick to respond that I didn’t see it that way, since virtually every programming language I work with consists at least for a big part out of English words.
Thinking about it, however, programming languages do have quite some commonalities with natural – spoken – languages:
Like a natural language, each programming language has a grammar. You might not think about it that way, since we usually refer only to syntax while taking about the structure of a programming language, but syntax is of course part of grammar.
The difference between the grammar of a natural language and a programming language is that programming languages can be seen as more strict. Whereas the grammar of a natural language allows you to express a certain sentiment in a lot of different ways, in most programming languages, such a statement can usually only be expressed in a very limited amount of ways.
Just like natural languages constantly change to adjust to its users and usage, so do programming languages. Although this process is usually more structured – programming languages often have version numbers that show what features of the language are available in that particular version – this process is also fuelled by its users, who often will propose changes that might be incorporated in later versions of the programming language.
There are also some differences in how we tend to think about writing in programming as opposed to natural language. Natural language allows, and often even celebrates or stimulates creativity, or finding your own way of saying things, having your own tone of voice. In programming however, consistency is often far more valued than creativity.
The reason for this is manifold, but two reasons that spring to mind:
- Written code is never finished, and often needs to be worked on by multiple people over the course of writing it. It will also often be reused. Natural language however is more final in many of its uses: in spoken language, as soon as the information that it contains has been transferred, the words used for that transfer aren’t of any importance anymore. In written works that we view as art, the words are of importance, but as something to learn from or try to understand, not as something that can be further developed or reshaped for another use.
- Programming code is often very dense, containing only logic statements, without any nuance. Therefore, consistency plays a big role in making this logic easily readable and interpretable.