Back to Home

The first high-level programming language - Plancalkul

plancalcule · programming languages

The first high-level programming language - Plancalkul

    Plankalkül is the world's first high-level programming language developed by German engineer Konrad Zuse between
    1942 and 1946 for his Z4 computer (the computer in the picture below, photo taken from Wikipedia).

    Z4

    There was World War II, Tsuse worked in isolation from scientists from other countries, completely independently. During this time, he created not only a programming language,
    but also wrote 49 pages of programs on it to evaluate chess positions. His work was completely published much later, in 1972.

    I would venture to talk about this programming language as an archaeological survey. Moreover, very little is said about this language in Russian.

    Only in 1957 (the work was started in 1954) Fortran appeared  - the language that most consider the first high-level language.

    “Z4” was electro-mechanical, therefore, Planckalkyl compiler or interpreter did not exist, but in 2000 in Svobodny
    The University of Berlin (Freie Universität Berlin) created an interpreter of its
    dialect (runs as a Java applet in a browser).

    The dialect that is being implemented is called Plankalkül-2000 and differs from the original in various simplifications.
    For example, the recording form is simplified, Zuse used a two-dimensional recording -
    the expression itself was written in the first line, and below are some of its arguments (type of variable, indexes, and so on). In addition, the icons of the operations themselves were simplified and
    brought to a more familiar view.

    The language is quite rich, in my opinion, for the forties: there are conditional constructions, two kinds of loops (analogue of while and for), there are arrays and tuples,
    it is possible to describe and call routines (but there is no recursion).

    All variables are divided into four types.
    • «Variablen» ( The Khodnev variables) - this input variables routines, are read-only begin with the letter «V» and numbers.
    • «Zwischenwert» ( W The values in between), are available for reading and writing, designed for intermediate storage of calculated values begin with the «Z» and rooms.
    • “Resultatwerte” ( P result) - in these variables the result of the calculation is returned, starting with “R” and the number.
    • "Indizes" ( And indexes) - loop variables (analogous to for), start with "i", then there may be a number, a number is needed to organize 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 a non-negative integer, the dimension in bits is indicated. 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 of three and four bits, the tuple must have more than one element.
    • An array is written through a point, for example: 4.5.0 - an array of four elements with five bits each, 32. (0, 8.0, 16.0) - 32 tuples, each of which has three variables: one bit, eight and
      sixteen.

    Plankalkyul can clearly be greatly simplified by syntax, but the modern dialect almost exactly copies the record that Zuse used, I believe that such a syntax was born because of the
    need to "debug" the program on paper. However, the language is so simple that I learned it all in about 15 minutes and even wrote a couple of programs on it in several versions.

    One of them calculates the indicated (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
    

    You should start it this way: open the page with the interpreter , copy my program into the window, click “Compile”, a separate
    window with Java applet opens (requires Java to be installed on the computer), in the window that opens, bit-by-bit type the initial value V0 with the mouse (you must click green circles),
    then in the browser window click “Run”, in the red line (R0) you will see the resulting value.

    Launched program on Plancalkul

    Subprograms in the language begin with the letter “P” and a unique number, then comes the name by which it can be called, I have a subprogram called “FactEvgenyStepanischev”, the
    subprogram ends with the keyword “END” (it was not in the original Planalkalkule).

    The subroutine describes the received and returned values, I use one variable for input, 4 bits in size and one for output, 10 in size. The first line is
    assigned the values ​​"zero" and "one" to the intermediate variables Z0 and Z1. The type of variables must be specified each time they are used;
    you cannot convert a variable to another type.

    Below is the “for” loop (W1), since I did not indicate the number of the loop variable (indicated in the first square brackets that are omitted here), the loop variable “i” is used, without a number.
    The number of repetitions is indicated in parentheses, and the body of the cycle in subsequent square brackets. 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 the dialect, for example
    , you can substitute a loop there, but the Run button in the applet did not appear for me, so I limited myself to assignment inside the loop.

    I used a complex assignment here, which is familiar to those who use Pearl, Python or PCP, but it works differently - assignments are performed
    sequentially, 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 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. It does not make sense to describe the elements of the array, the function call, and the while loop separately; they look quite natural within the framework of this syntax.
    All operations supported by the language (there are only a few of them - logical operations, bit operations and four arithmetic operations) look familiar.

    Read Next