Every day I wake up at 3am. If it’s a weekend, however, I go to sleep at 3am. I brush my teeth, go for a run, browse Reddit and listen to Eminem. Some elderly people from nearby residences often join me for their morning walk. To ensure that I keep myself socially distant, I minutely change my trajectory as long as I’m within a few feet of them.
What you read was a simple paragraph. Yet, it contained the semantics of a basic programming language. If you stare at it hard enough, you’ll discover simple recursions, conditionals and even data types such as arrays of strings. No wonder why High-Level Programming Languages attempt to resemble English. For English itself, kinda imperfectly, can be spoken very declaratively. And in case you were wondering, nope, the first paragraph isn’t an accurate description of my life.
One might say that spoken languages simply consist of strings. That is true, given that we rarely employ methods to completely segregate parts of sentences, but even if you observe this very sentence, you’ll appreciate clauses which bring order into relatively chaotic statements.
You won’t find a literal dictionary in English (and I use English as a representative, it might as well be any spoken language), however, arrays and variables are quite abundant. Every time someone mentions a list of things all segregated by commas or ‘ors’ and ‘ands’, they are, in a very loose way. A lot of the words in English are used as variables which momentarily refer to the part of the information we are interested in. ‘This’ and ‘that’ and the pronouns all turn out to be variables in that sense.
Logical Operations and Conditionals
Is this sentence true? This sentence is true. Well, I don’t know for sure, but that initial ‘is’ is doing a lot of work here. Single-handedly by jumping from the first (programmers read zeroth) place to the third (programmers read second), it turned the sentence from an interrogative into a declaration.
Similarly in our speech, we are time and again using conditionals with such operators. From “if it rains” to “if I succeed”, these operations may not always be logical but surely approximates an enquiry into nature followed by conditional statements. With ‘ifs’ and ‘thans’ we have developed a pretty well-equipped arsenal of conditionals and operators that
You can say, I was bla years old when the millennium turned and that day I took a bath, next day I took a bath, next I took a bath, next I took a bath, next I took a bath…, or you might just say I have taken a bath daily since the turn of the millennia. Recursions and been easily encoded in a sentence with just a single word like ‘every’ or ‘none’. With multi-word combos like “keeps on” we get an even better taste of recursive properties.
‘Function’ is a verb, literally but all verbs are functions, figuratively. They might be complex functions which are Russian dolls of subsequent component functions, or they might be very straightforward simple ones. There might be operators which take in a noun as input and modify the meaning.
When you say ‘I will perform’, no one knows what you will perform. To perform, by itself has very little meaning (in contrast with say, to sleep or even to say). If you, however, say ‘I will perform tympanoplasty’, people would immediately appreciate that you are intending to perform a combination of ‘Myringoplasty and Ossiculoplasty’, thus decomposing the complex verb into relatively simpler ones!
What makes natural language natural?
There might be a better answer to this question, but the main reason why natural language triumphs over the ones we code in, is because the computers that parse it, can make incredible connections through intuition and instincts. Like, you might someone and bang on start to talk about how the Spurs defeated the Red Devils. You wouldn’t even have to highlight the game nor the proper names of the teams and people might already have made the connections. No time wasted in
import epl from football, you get direct action!
A better example would be, how you can talk about your job, pause for a second, make a remark on the weather, sneeze hard, say bless me, resume your conversation and the person listening to you will still appreciate what’s being told.
Another more philosophical difference is that natural languages are spoken from person to person. So, when you are listening to someone or reading someone, your brain is personifying the speaker or author with all sorts of extra information it can manage from the surroundings. When you are coding, the compiler or animation engine doesn’t care about you nor about itself. It is just an inanimate piece of electricity powered electronic state encoded on doped silicon.
The last point is that natural languages can have double meanings and such situations are often intended. This, however, is a big no-no for programming. You can have entire paragraphs with underlying sarcastic undertones or euphemisms and if you dare, a double entendre sprinkled somewhere in between and an observant listener will appreciate it without any prior intimation.
Chicken or the Egg
You might argue, high-level programming languages are built to resemble naturally languages. Therefore, it is very circular to simply try to describe natural language in terms of the former. This is a classic chicken and egg problem and for this one, in particular, we are convinced the chicken came first.
So, is this discussion futile?
Maybe so! Afterall speaking to a human in python is just as useless as typing out plain Victorian English to a Python compiler. Often when we are knee-deep into debugging (if we are debuggers) or reading literature (if we are bookworms), we forget how orderly our own speech and thought processes are. Every time we use words like ‘every time’, ‘than’, ‘then’, ‘if’, the conjunctions, the prepositions and in fact any part of speech, we are logically adding some new information to our conversation.
Appreciating these logical constructs in our qualitative languages may not change civilization overnight, but it’ll help us gradually in two fronts. One, it will make you a more observant speaker who possesses the skill to choose the correct word at the correct moment. On the other hand, understanding spoken language in terms of coding language might open up new frontiers in natural language processing.
After all, who wouldn’t just love to have a long and thoughtful conversation with Siri and Alexa instead of being replied with “I searched the web and found these results…” to every spiritual question you ask ’em.