ALGOL-68 programming language
index


ALGOL-68

[2022/04,2023/05]

Almost every programming language has been influenced by ALGOL/ALGOL-68.

ALGOL-68 is very orthogonal (a design goal difficult to achieve). Almost any statement/expression can be placed almost anywhere.

    [Algol 68 Genie Manual]
    The conditional-clause can be written wherever a unit is permitted, so:
        IF INT a = read int; a > 0
        THEN print ((a, " is positive"))
        ELSE print ((a, " is negative"))
        FI

C++ is gradually becoming orthogonal, only in a few places. C++17 allows this counterpart:

    if ( D d = f(); d )

ALGOL-68 syntax imitated by C, C++, Python:

    INT j, k            CO declaration CO

    x := y := 0

    a +:= 1

    REAL w;             CO C++: float w = ...; CO
    REF REAL v = w      CO      float& v = w;  CO

    STRUCT (REAL x, REAL y, REAL z) vector
    STRUCT (REAL x, y, z) vector
    C++: struct Vector { fp x, y, z };

    [] CHAR a = "tabula materna combusta est"         CO constant/alias CO
    [1 : 27] CHAR a := "tabula materna combusta est"  CO variable, origin of Python slices CO

ALGOL-68 had user-defined types (types are "modes" in ALGOL vocabulary):

        [Algol 68 Genie Manual]
            MODE VECTOR = STRUCT (REAL x, y, z)
        or
            MODE VECTOR = [1 : 3] REAL
        makes VECTOR a synonym for the mode specification on the right-hand side of the equals symbol,
        and new objects using VECTOR can be declared in the ordinary way:
            VECTOR vec = (1, 2, 3);
            VECTOR vn := vec;
            [10] VECTOR va;

ALGOL-68 GENIE compiler/interpreter

ALGOL-68 GENIE

[2022/04]

"ALGOL-68 GENIE" (programmed by Marcel van der Veer) is a nice implementation of ALGOL-68. GENIE is both an ALGOL-68 compiler and interpreter (both amazing feats), includes ALGOL-68 programming book, can be installed on UNIX with a C compiler. FreeBSD port is available.

Web/URLs

[2022/04]
https://jmvdveer.home.xs4all.nl/en.algol-68-genie.html
https://jmvdveer.home.xs4all.nl/en.download.algol-68-genie-current.html

Experimenting with ALGOL-68 interpreter

From UNIX shell, to send ALGOL expression ("unit" in ALGOL vocabulary) to interpreter (-p is short for -print):

    a68g -p 'ALGOL_EXPR'

A fun command to send to ALGOL-68 interpreter is (try to) compute pi. Numeric precision of ALGOL-68 GENIE is from great up to arbitrary (even without GNU MPFR library, has great precision).

    a68g -p 'long long pi' --precision=100
    a68g -p 'long long pi' --precision=4000