Oddities in retro style

    Hello again! Somehow, imperceptibly for myself, I took a course not on abnormal programming itself, but on languages ​​that are well suited for abnormal programming. Of course, you can surprise the public with another C ++ program, but I will go the other way. In the 50-70s, programming was just beginning and it was not clear what the ordinary programmer needed and what was dangerous. It was precisely because there was no idea then what the Tru-programming language should be such constructions and such tools often appeared that a modern programmer would choke on food, studying a different manual. So we forget about what you were taught by such masters of the word as Knut and Straustrup and go under the cut!

    Liberty over the edge


    PL / 1 always finds something to throw a wild programmer to. For example, the expression
    9<8<7
    is true ! The logical question is: why? How is this even possible and how did the language developers allow this ??? Well, have to delve into the manuals. To begin with, there are no logical variables in PL / 1, zero is false, and everything else is true. Also, almost any implicit conversion is allowed, this gives about 50% more errors. Consider how the translator parses composite logical expressions.
    The first thing that catches your eye is two identical operations '>', and they have the same priority. Thus, the expression 9 <8 <7 turns into
    (9<8)<7
    9 <8 - a lie, so the brackets disappear and the expression changes before our eyes:
    0<7
    Seven is truly greater than zero, so the truth returns. I will spit on C until the logical variables appear there. Also, this is sufficient justification for the fact that in most high-level languages, logical variables are simply necessary. Otherwise, such problems simply cannot be avoided.
    Here's another curious rake that novice PL / 1 programmers often crippled their feet about. We read the documentation for PL / 1. It says that multiple assignment is allowed. Suppose we have three variables - A, B and C.
    A=5;
    B=6;
    C=B=A; /* Мы хотим, чтобы все три переменные равнялись пяти */

    What do you think the C variable is ??? It is not equal to five at all, it is equal to ... zero! Wait, but the manual says that multiple assignment is allowed, how so? Yes, you probably already guessed - the second equal sign is a logical operation, and multiple assignment looks like this:
    C,B = A;
    All problems of this kind arise because the line between logical and arithmetic operations is blurred. Reader, you are mistaken in believing that this is the height of originality. More strange things are described below.

    Pronouns in Nebula


    Each variable has its own name - this is how we are taught from kindergarten. But in the bearded 60s, not everyone thought so. In attempts to get closer to the real language, monsters such as Kobol or Nebula were spawned. For example, why not write It seems to me not a very natural and useful construction, but the creators of Nebula did not think so. They introduced a pronoun into the language - a pointer to the current value. If you think this is the height of insanity, it’s best not to even read about nameless variables, but go straight to the wilds of syntax.
    Инкрементировать (число);
    Напечатать (его);

    QIH

    Nameless Variables


    A person having played enough with Nebula quickly realizes that it would be nice to refuse names altogether. In POP-2 they did. All variables are declared to VARS operators:
    VARS X Y Z;
    Now we can write something like that.
    X + Y -> Z;
    However, no one bothers us to write simply.
    X + Y;
    Now the sum is stored on the stack, which is used implicitly. This eliminates the need for temporary variable names. Some time after the X + Y command, we can write
    -> Z;
    The number is taken from the stack and placed in a variable. POP-2 should not be confused with languages ​​such as Forth or Factor. In POP-2, the stack is only an auxiliary tool, albeit a very useful one. On the stack, you can store data between procedure calls, which allows you not to think about the lifetime of the variable. These, and many other features of POP-2 allowed him to become a convenient tool for logical programming, but he did not receive wide popularity, it was used only in England.

    Conditional operators crippling the brain


    Currently, in almost all new programming languages ​​(except Python and its derivatives, indents and tabs are used there) the if statement has two clearly limited blocks. On Eifil or on Lua I can write something like this: Each if has its own end and I can say exactly what if the else refers to. Due to this, in the process of broadcasting the program there will not be any questions. But here is a valid entry in PL / 1 (Please note, even before the ELSE you need to put a semicolon, we will talk more about this): The translator is legitimately surprised to what IF ELSE refers to? Because of this ambiguity, it was necessary to introduce a requirement that each conditional statement in its IF should have its own ELSE. Here's how to rewrite this example: Now a person is already surprised.
    if a ...
    if c ...
    else
    ...
    end
    ...
    end


    IF 9<8<7 THEN IF 9>8>7 THEN CALL AAA; ELSE CALL BBB;

    IF 9<8<7 THEN IF 9>8>7 THEN CALL AAA; ELSE; ELSE CALL BBB;

    In ALGOL 60, this problem was solved a little better, but also quite ugly: nested if should be in the begin block ... end: The situation is complicated by the fact that then the programs were entered with punch cards, because of this, people could not issue them with beautiful indents and other benefits of progress, all programs were a bloody mess of symbols piled in a heap. There is one bright spot in this black mess - POP-2. In it, the nested loop can be closed with the close operator: This is much more elegant than the PL / 1 agreement. Here it is necessary to eliminate one ambiguity: there was no operator like case then. case in Algol essentially represented a refined computed goto. Therefore, our ancestors were forced to sculpt a lot of if in one heap.
    if 9<8<7 then begin
    if 9>8>7 then aaa end
    else bbb;


    if b1 then if b2 then S1 close
    else S2 close



    Semicolon cancer


    Once upon a time, programs were introduced with punch cards. All that came into the translator is a continuous stream of characters. Under such conditions, using a semicolon was a real salvation. Currently, this is not so relevant, but in the old days they didn’t think so. The PL / 1 developers understood this too literally, so the semicolon completes everything that is possible, it climbs into all the cracks. We already spoke about the fact that you need to put a semicolon before the else-branch. But this is not all the charms of PL / 1! The semicolon needs to be set even after DO in the DO-block:
    IF 9<8<7 THEN CALL ERROR; ELSE DO; A=5; B=6; END;
    Earlier versions of PL / 1 enjoyed this mess with pleasure.

    Reserved Words


    In Kobol, ~ 300 words cannot be used by a programmer! On the other hand, in Fortran or in PL / 1 there are no reserved words at all, a person is free to do whatever he wants:
    IF IF THEN THEN; ELSE ELSE;
    There’s nothing to say, it’s better not to take it, spit and pass by.

    Conclusion


    As we can see, our ancestors also knew all the subtleties of abnormal programming, often their quick-code is more interesting than ours. Note that I did not, as usual, give links to programming languages, since the Russian Wikipedia has only articles on PL / 1, Algol and Kobol, and the article on Kobol is very incomplete. And to find information about such nuggets as BLISS, CPF, CORAL 66 or Nebula is completely impossible. As for POP-2, I found some information, and there is even no article about POP-11, but an article. In general, these languages ​​have long been dead and no one else uses them. There are exceptions, these are PL / 1 and Kobol, but their death hour is already near. I found all the information in my collection of old books on computer science. In particular, translations of Barron's books served as the main source of knowledge. If interested, search the net for the cover .

    Also popular now: