originally MA198-11 Lesson M2

corrected 12sep16


As you have seen playing with DPgraph, this simple drawing program, despite its merits, is difficult to program. While you exerted great ingenuity to construct an interesting animation with it, better tools are needed. We need a better programmable graphics tool, with a versatile programming language.

Levels of a language

Historically, computers were first programmed in machine language (ml). (Depending on context, ML can be "machine language" or "markup language", which is a very different thing.) The first level above ml is assembly language (al) which a program called an assembler translates into ml. Peter Braunfeld, a senior colleague, recalls fondly how an early assembler for the PLATO system at Illinois greatly eased his work by allowing him to use decimal numbers and roman letters instead of strings of hexadecimals. In 1952, Grace Hopper wrote the first compiler. A compiler translates a program written in a programming language into ml. The early compiled languages, John Backus’s FORTRAN and John McCarthy’s LISP, are still in use today.

An unsophisticated way of defining the level of a programming language is to say that the closer it is to common speech the higher the language. Machine language is the lowest and anything easier to write is higher. This is inadequate, because common speech is imprecise and heavily dependent on context to avoid ambiguity. It helps a bit say that a high level language is close to the mathematical or other scientific jargon it is designed to encode. [Note, "jargon" also has the non-pejorative meaning of a vocabular and its use which is typical of a particular specialized field of knowledge.]

In theoretical computer science there is an even better definition in terms of abstraction. By comparison, consider human writing: ideogrammatic (hieroglyphs, Chinese characters), syllabic, and alphabetical. An ideogram packs a great deal of meaning into a single symbol, one that can take very many letters of an alphabet to express.

In choosing a language for drawing mathematically meaningful pictures we should also consider the level at which we want to work on. The more the language is a means to an end, the higher level it should be. We want ready made features and shortcuts, which enable us to arrange prebuilt objects and processes to our liking. Stephen Wolfram’s Mathematica is the best example of such a language for mathematical purposes.

However, an ideogrammatic language has, to be of any use, an enormous vocabulary. This requires vast dictionaries and extensive documentation. The socalled learning curve of such languages is always very "long", it may be "steep" at the beginning, or "shallow", depending how long you want to take to get to the first level of competence. So the learning gradient is always a consideration. It is also limited by the imagination of its designers. They have to foresee what the beneficiaries of their efforts, their users, will be content with. So a more alphabetical language might actually be more useful.

Taxonomy of computer languages

We have already seen the distinction of high-level and low-level languages. Without the tools of theoretical computer science to analyse and compare two (let alone more) languages it is more of an "impressionistic" distinction. All computer languages must be able to accept input and control the computer to produce output. How data is entered is the subject of the next distinction.

An interpeted language is one that takes its data from the keyboard, in real time, on the commandline. You are familiar with wordprocessors, which take their input in this fashion. But only very few can produce formatted output, including mathematical symbols and figures or tables, in real time. This is an issue for mathematical textprocessors, such as TeX, which is treated in a separate lesson. So a second requirement of an interpreted language is that is executes the commands entered on the command line immediately after the enter key is pressed.

Some of you remember BASIC, which once was the most familiar interpreted language. Today, Python is the most important one, and it deserves a separate lesson as well. A command line shell, such as the Bourne shell (bash) for Unix and Mac, and the Command shell (cmd or dos) for Windows, is the quinessential interpreter. Based on the command line input, the shell controls the computer itself.

What we have just described in the immediate mode of an interpreted language. To be useful, the language must also have a deferred mode. This means, that text files containing the keystrokes you can enter on the command line also serve as input and output. This feature is so important that the immediate mode of Python is generally ignored by tutorials and expositions of the language. We shall not ignore it, and the immediate mode of Python is worth a few hours. The principal application of your learning some Python is the package VPython. It is intended to be used in deferred mode, and has additional tools to reduce the overhead repeated rewriting and testing the programs (aka editing and executing the codes) you work with.

Topics to be added