In Metaphors in Computer Science 1, I discussed some metaphors used when thinking about various aspects of computing. This is a continuation of that post.
Metaphor: A program is a list of instructions.
- I discussed this metaphor in detail in the earlier post.
- Note particularly that the instructions can be in a natural or a programming language. (Is that a zeugma?) Many writers would call instructions in a natural language an algorithm.
- I will continue to use “program” in the broader sense.
Metaphor: A programming language is a language.
- This metaphor is a specific conceptual blend that associates the strings of symbols that constitute a program in a computer language with text in a natural language.
- The metaphor is based on some similarities between expressions in a programming language and expressions in a natural language.
- In both, the expressions have a meaning.
- Both natural and programming languages have specific rules for constructing well-formed expressions.
- This way of thinking ignores many deep differences between programming languages and natural languages. In particular, they don’t talk about the same things!
- The metaphor has been powerful in suggesting ways of thinking about computer programs, for example semantics (below) and ambiguity.
Metaphor: A computer program is a list of statements
- A consequence of this metaphor is that a computer program is a list of symbols that can be stored in a computer’s memory.
- This metaphor comes with the assumption that if the program is written in accordance with the language’s rules, a computer can execute the program and perhaps produce an output.
- This is the profound discovery, probably by Alan Turing, that made the computer revolution possible. (You don’t have to have different physical machines to do different things.)
- You may want me to say more in the heading above: “A computer program is a list of statements in a programming language that satisfies the well-formedness requirements of the language.” But the point of the metaphor is only that a program is a list of statements. The metaphor is not intended to define the concept of “program”.
Metaphor: A program in a computer language has meanings.
A program is intended to mean something to a human reader.
- Some languages are designed to be easily read by a human reader: Cobol, Basic, SQL.
- Their instructions look like English.
- The algorithm can nevertheless be difficult to understand.
- Some languages are written in a dense symbolic style.
- In many cases the style is an extension of the style of algebraic formulas: C, Fortran.
- Other languages are written in a notation not based on algebra: Lisp, APL, Forth.
- The boundary between “easily read” and “dense symbolic” is a matter of opinion!
A program is intended to be executed by a computer.
- The execution always involves translation into intermediate languages.
- Most often the execution requires repeated translation into a succession of intermediate languages.
- Each translation requires the preservation of the intended meaning of the program.
- The preservation of intended meaning is what is usually called the semanticsof a programming language.
- In fact, the meaning of the program to a person could be called semantics, too.
- And the human semantics had better correspond in “meaning” to the machine semantics!
- The actual execution of the program requires successive changes in the state of the computer.
- By “state” I mean a list of the form of the electrical charges of each unit of memory in the computer.
- Or you can restrict it to the relevant units of memory, but spelling that out is horrifying to contemplate.
- The resulting state of the machine after the program is run is required to preserve the intended meaning as well as all the intermediate translations.
- Notice that the actual execution is a series of physical events. You can describe the execution in English or in some notation, but that notation is not the actual execution.
References
Conceptual blend (Wikipedia)
Conceptual metaphors (Wikipedia)
Images and Metaphors (article in abstractmath)
Semantics in computer science (Wikipedia)
Send to Kindle
The blending of graph and formula associates each point on the (blue) graph with the value of the formula at the number on the x-axis directly underneath the point.
