Dartmouth Time-sharing System: Algol 60

The Algol family of languages and Algol 60

Algol was originally designed by a committee of European and American computer scientists in the 1950s-60s. The first version to be widely implemented was Algol 60, which is what we will look at here.

Dartmouth had experience of implementing subsets of Algol on its smaller computers before DTSS, and this was the second language to be introduced on DTSS after BASIC in 1964.

/images/dtss/ge225-system.png

An illustration of a GE-225 system from "GE 200 Series Operation Manual", GE, 1966. Source: bitsavers.

Algol 60 on Dartmouth DTSS

One important point when dealing with Algol is different levels or representations of the language: there is one for the spec, one for printed programs and one for the machine implementation. As an example, to raise a to the power b:

  • Spec: a ↑ b
  • Printed: ab
  • Machine - Dartmouth: a ^ b
  • Machine - IBM: a ** b

We'll use the printed form in this article and the Dartmouth machine form for code examples.

Keywords are in bold lower case in the printed form (eg integer). Dartmouth uses upper case (eg INTEGER). (IBM used quotes, eg 'INTEGER', which must have been a pain to type).

Here's an example program that will print Hello World 5 times

10 BEGIN
20 INTEGER I;
30 FOR I := 1 STEP 1 UNTIL 5 DO
40     PRINT("HELLO, WORLD")
50 END PROGRAM

The line numbers are not part of Algol but are needed for the Dartmouth program editor.

Statements are grouped into blocks, separated by semicolons; the last statement in a block does not need a semicolon.

Variables are typed (real, integer, boolean); strings are allowed only as constants.

Algol has no standard I/O - reflecting how different each computer was at that time, it was up to the implementation to add this. Dartmouth Algol uses print much like BASIC for output.

Let's exercise Algol further by implementing the TPK algorithm.

TPK in Algol 60

100 BEGIN
110     COMMENT TPK ALGORITHM IN ALGOL 60;
120 
130     REAL PROCEDURE FN(X);
140     VALUE X;
150     REAL X;
160     BEGIN
170         FN := SQRT(ABS(X)) + 5*X^3
180     END PROCEDURE;
190 
200     COMMENT MAIN PROGRAM;
210     INTEGER N, J;
220     REAL ARRAY A[1:11];
230     N := 11;
240     COMMENT READ NUMBERS FROM DATA;
250     FOR J := 1 STEP 1 UNTIL N DO
260         READATA(SAMPLE, A[J]);
270     PRINT("RESULTS ARE");
280     FOR J := N STEP -1 UNTIL 1 DO
290     BEGIN
300         REAL RESULT;
310         RESULT := FN(A[J]);
320         IF RESULT > 400.0 THEN
330             PRINT("TOO LARGE")
340         ELSE
350             PRINT(RESULT);
360     END LOOP;
370     DATA SAMPLE := 10, -1, 1, 2, 3, 4, 4.3, 4.305, 4.303, 4.302, 4.301;
380 END PROGRAM

The indentation is for readability only and is not required by the language. Contemporary users would probably pack more statements per line so as to use less vertical space on the typewriter output. It's not shown here, but you can also spread out statements over several lines and even include spaces in variable names.

In the procedure definition, note that we declare the input parameter X as having real type and also value class, so it is passed by value; the other option is name which is similar to pass-by-reference.

The main program starts on line 200. Note that variables need to be declared before they are assigned to, and arrays can have arbitrary indices.

The program uses the readata procedure, which is a Dartmouth extension to read items from the matching data statement, similar to BASIC READ and DATA. print is also a Dartmouth extension.

At line 300, note that RESULT is declared in the for block so its scope lasts until the end of the block only; this was an innovation of Algol.

Executing this on the emulator

  • See the quick tour on how to get the emulator running.
  • Download the source file from Github.
  • If you are not on Windows, ensure the file has CR/LF line endings. A simple way to do this:
awk 'sub("$", "\r")' < input_file > output_file
  • Store the file as TPKA (no extension) in the same directory as DTSS.EXE.
  • Start DTSS.
  • Type SYSTEM ALGOL to switch from BASIC to Algol.
  • Type OLD TPKA.
  • Type LIST to confirm the source has been loaded.
  • Type RUN.

Further information

The DTSS zip file contains An Algol Outline.pdf.

The Revised Report on the Algorithmic Language Algol can be considered as the standard definition of the language.

There are some contemporary books on the Internet Archive: Dijkstra's A Primer of Algol 60 Programming is terse but readable; McCracken's A Guide to ALGOL Programming is a more traditional text book.

I wrote an overview of Algol 60 on the IBM S/360 under MTS here, which goes into more detail on the language and how IBM implemented it.

Questions, corrections, comments

I welcome any questions or comments, and also especially any corrections if I have got something wrong. Please email me at rupert@timereshared.com and I will add it here and update the main text.