Plankalkül (Plankalkül) is the first high-level programming language in the world, developed by German engineer Konrad Zuse between
1942 and 1946 for his computer "Z4" (the computer in the picture below, the photo was taken from Wikipedia).
It was the Second World War, Zuse worked in isolation from the scientists of other countries, completely independently. During this time, he created not only a programming language,
but also wrote on it 49 pages of programs for evaluating chess positions. Fully his work was published much later, in 1972.
I will risk to tell about this programming language, as archaeological research. Moreover, very little has been said about this language in Russian.
Only in 1957 (the work was begun in 1954) did
Fortran appear, a language that most consider the first high-level language.
')
"Z4" was electro-mechanical, therefore Plankalkyl’s compiler or interpreter did not exist, but in 2000 in Free
the University of Berlin (Freie Universität Berlin) an
interpreter was created
dialect (runs as a Java applet in the browser).
The dialect that is implemented is called Plankalkül-2000 and differs from the original by various simplifications.
For example, the recording form is simplified, Zuse
used a two-dimensional recording -
the first line was the expression itself, and below are some of its arguments (variable type, indices, and so on). In addition, the icons for the operations themselves were simplified,
brought to a more familiar to us with you mind.
The language is quite rich, in my opinion, for the forties: there are conditional constructions, two types of cycles (analogous while and for), there are arrays and tuples,
subroutines can be described and called (but there is no recursion).
All variables are divided into four types.
- “Variablen” ( In input variables) are input variables of subroutines, read-only start with the letter “V” and numbers.
- “Zwischenwert” (Intermediate), available for reading and writing, for storing intermediate calculated values, starting with “Z” and number.
- “Resultatwerte” ( P Result) - the result of the calculation is returned in these variables, starting with “R” and the number.
- "Indizes" ( and ndeksy) - loop variables (analogous for), begin with "i", then there may be a number, the number is necessary for the organization of nested loops.
Three types of variables are available. Despite the fact that "Z4" was able to operate with floating point numbers, the interpreter does not know how.
- For non-negative integer, the dimension in bits is specified. There are two forms of writing “0” - one bit, “n.0” - “n” bits, for example, 8.0 - one byte (8 bits).
- The tuple is indicated in parentheses, for example (3.0, 4.0) - these are two variables in three and four bits, the tuple must have more than one element.
- An array is written through a dot, for example: 4.5.0 - an array of four elements of five bits each, 32. (0, 8.0, 16.0) - 32 tuples, each of which has three variables: one bit, eight, and
sixteen.
Plankalkül can clearly be greatly simplified in syntax, but the modern dialect almost exactly copies the record that Zuse used, I believe that such a syntax was born because
need to "debug" the program on paper. However, the language is simple that I learned it completely in about 15 minutes and even wrote a couple of programs on it in several versions.
One of them calculates the specified (in order)
Fibonacci number :
P0 FactEvgenyStepanischev (V0[:4.0]) => (R0[:10.0]) (0, 1) => (Z0[:10.0], Z1[:10.0]) W1 (V0[:4.0]) [ i > 0 -> (Z0[:10.0] + Z1[:10.0], Z1[:10.0] - Z0[:10.0]) => (Z1[:10.0], Z0[:10.0]) ] Z1[:10.0] => R0[:10.0] END
It should be launched like this: open the
page with the interpreter , copy my program into the window, click “Compile”, open a separate
a window with a Java applet (requires that Java be installed on the computer), in the window that opens, use the mouse to type the initial value V0 bitwise (you must click on the green circles),
then in the browser window, click "Run", in the red line (R0) you will see the resulting value.
Subroutines in the language begin with the symbol “P” and a unique number, then comes the name by which it can be called, my subroutine is called “FactEvgenyStepanischev”, ends
subprogramme with the key word “END” (it was not in the original Plankalkule).
The subprogram describes the accepted and returned values, I use one variable per input, 4 bits in size and one per output, the dimension in 10. The first line
the values “zero” and “one” are assigned to intermediate variables Z0 and Z1. The type of variables you have to specify each time you use them, convert the variable to another
type cannot be.
Below is the cycle “for” (W1), since I did not indicate the number of the cycle variable (indicated in the first square brackets, which are omitted here), the cycle variable “i” is used, without a number.
The number of repetitions is indicated in parentheses, and the cycle body in subsequent squares. Details can be
found in the
description .
The operation “arrow” (“->”) is a conditional construction, the part on the right will be executed if the expression on the left is true. Only the simplest expressions work in a dialect, for example
You can substitute a loop there, but I didn’t have the “Run” button in the applet, so I limited myself to assignment within the loop.
I used complex assignment here, which is well known to those who use Pearl, Python or PCP, but it works differently - assignments are performed
consistently, from left to right, so I can not limit myself to “(Z0 [: 10.0] + Z1 [: 10.0], Z1 [: 10.0]) => (Z1 [: 10.0], Z0 [: 10.0])”, the result will not be the one that is expected.
At the end, I assign an intermediate value to the resulting value of the subroutine.
In addition, there is almost nothing in the language. Appeal to the elements of the array, the function call and the “while” loop does not make sense to describe separately, they look quite natural within the framework of this syntax.
All operations supported by the language (there are few of them - logical operations, bit operations and four arithmetic operations) look familiar.