The Language of Logic
One of the many things that bother me about the field of computer science, is the enigma that surrounds computer programmers. Few people understand who we are, even fewer understand what we do, and practically nobody understands how we do it. The first of these I tackled a while ago, and today I intend to tackle the second. Starting with this quote:
Programming, is like writing an essay in the language of logic.
- Damola Mabogunje
Because to write an essay in any language (be it English or Chinese or Japanese), one must first learn and understand the language. And as anyone who has had to learn a foreign language knows, this is not an easy task.
It is not easy because to learn a language we must not only learn its vocabulary, but also its grammar. And, to understand it, we must understand the culture from which it came. But to master it, we must be able to think in terms of the language, and contextually apply it. All the while accounting for nuances in situation, tone, and pronunciation.
Therein lies the greatest hurdle there is to becoming a programmer. But to further complicate matters is the fact that the audience for our essay is a machine. An object with which we share no similarities, and therefore no common expressions of meaning. For amongst spoken languages, though we say different words, the world we live in provides a common basis for understanding.
To human beings, a difference in language is merely a difference of potayto versus potahto. The Englishman says "person", the Chinese "ren", and the Japanese "hito". Yet the concept they are all referring to is the same! It just sounds different.
With a computer however, the common background that allows us all to relate to the concept of "person" does not exist. It must be explained because it cannot be implicitly understood - and it must be explained in the most basic of terms because references like "human-being", "mammal", and "living thing", are equally alien to it - due to the fact that every machine is only capable of understanding two terms: True, and False - and this is what I call the language of logic.
Now like every other language, over the years this language of logic has evolved to include other logical terms and concepts. Like conditionals (if & else), loops (for & while), conjuctions (and & or) and variables - and at their root of course, still lie the fundamental values of true and false. But for the most part, programmers of today speak in terms of these advanced logical values.
It is these advanced logical values that provide the common basis for understanding between man and machine, and just like there are many spoken languages to describe the material world, there are also many logical languages to describe it as well. It is these logical languages that we refer to as programming languages.
Which brings me to my next point. Programming languages are called thus because they are used to write programs - and as you will find in any dictionary, a program is a set of instructions for a computer. So moving back to our language analogy, if a programming language is our method of communication, then a program must be our communique. That is to say, the program is our essay.
Yet, writing this essay is a skill in itself. Because while any logic-literate person can write an essay, writing a good essay takes skill. Everything from how to structure your argument, to what references to include, down to which words to use when and where, require more than just putting pen to paper or dactyl to keyboard. To write well, we must plan. We must do research. We must consider our audience, and we must design our program with them in mind.
But the ultimate audience for a program is not the computer for whom it is written, but the people who will be using that computer. A third party, makes up our primary audience. So in essence, we must author a good essay for the computer, so that it may have a great discussion with the consumer...
...and this, is what computer scientists learn in school. We first learn to speak the language of logic, and then we learn to apply it effectively.