What is computer programming and how does it work?
This post is a follow-up to “What is a computer and how does it work?” where I posted an excerpt from a Playboy interview with Steve Jobs in 1985. I tweeted a link to the post and Emanuel Derman replied: “… Unknowingly, I wrote something very similar on page 111 of My Life as a Quant …”. —@EmanuelDerman
I am just a software developer who has worked in finance and been fascinated with Physics since school days, but I’ve read and enjoyed enjoyed My Life as a Quant: Reflections on Physics and Finance as well as his latest book, Models.Behaving.Badly.: Why Confusing Illusion with Reality Can Lead to Disaster, on Wall Street and in Life very much. I can recommend them to anyone — one need not be a mathematician, a software developer, a physicist or a quant to appreciate his writing.
Emanuel has very kindly allowed this excerpt from My Life as a Quant (Chapter 7: In the Penal Colony, page 111) to be reproduced here.
The quote from Steve’s interview is non-technical explanation of what what a computer is and how it works. This passage is a wonderful description of computer programming in easily understandable language. To me, the latter is a logical extension of the former.
“Meanwhile, in 1981, I attended the computer science courses offered by the Labs and learned the practical art of programming. I was especially entranced by language design and compiler writing, and spent most of my time creating specific little languages that allowed users to solve specialized problems.
In high-level languages like Java, C, or even ancient and despised FORTRAN, you can easily write brief, sophisticated commands that instruct the computer to carry out complex operations. You can program in a style that corresponds rather closely to the way an educated person thinks or talks about mathematics. But a computer’s central processing unit, the primitive brain that actually performs the logical and mathematical operations, is an idiot savant that has been engineered to “understand” and respond only to simple babytalk. It is as though you want to tell a small child who grasps only baby talk (but has a very good memory for long sequences of it) to take the dog for a walk. You cannot just say “Take the dog for a walk!”This assumes too much knowledge of the world. Instead, you must translate that high-level, big-picture command into a corresponding list of very elementary sequential actions, each describable in baby talk. You must say something like:
Fetch the dog;
find the leash;
tie the leash to the dog’s collar;
hold the leash tightly;
open the front door;
follow the dog for five minutes;
if the dog steps off the sidewalk, pull him back using the leash;
. . .
return to the front door;
enter through the door;
unleash the dog.
If you design a high-level language that allows its users to issue sophisticated commands such as “Walk the dog,” you must provide a compiler that translates these commands into the baby talk machine code that the central processing unit can follow. Clearly, one mistake in translation, or just a little lack of specificity, and the dog and child will never return!
When John Backus and his team at IBM invented FORTRAN as a “FORmula TRANslation” language in the late 1950s, they wanted to allow programmers to manipulate complex mathematical formulas. Their compiler had to automatically translate any FORTRAN command into a sequence of the baby talk machine code that the simple logical computer circuits could follow. The compiler had to not only translate reasonable commands into baby talk; it also had to refuse to translate unreasonable or nonsensical ones. It had to to shout “Foul!” if you asked it to compile the command “Dog the! for take walk.” In brief, it had to comprehend grammar.
Grammar is the set of rules that legitimate sentences must satisfy. Adults recognize grammar intuitively, without thinking, but computers must follow rules. Backus developed a mathematical formalism for describing and parsing grammars that facilitated the task of language translation. It worked well for simple programming grammars that are less complex and subtle than those expressing natural languages. Backus’s formalism, called BNF for Backus Normal Form, provided a methodology for creating grammatically consistent computer languages, and paralleled similar discoveries by Noam Chomsky on generative grammars. Working with this formalism, I learned how to design small grammatically consistent computer languages.”
Derman, Emanuel (2007). My Life as a Quant: Reflections on Physics and Finance [Paperback]. Wiley.