ALGOL 60 - Introduction

In this series of posts we’ll look at ALGOL, one of the foundational languages for modern programming, and the ALGOL 60 implementation on MTS.

The ALGOL family of languages and ALGOL 60

Most programming languages spring from a single person or a company; ALGOL is fairly unique in that it was originally designed by a committee of European and American computer scientists in the mid 1950s. The first version to be widely implemented was ALGOL 60, which is what we will look at here. A large number of improvements to ALGOL 60 were proposed or developed: one, by Niklaus Wirth, became ALGOL W. The next standardised version was ALGOL 68 but this was not widely adopted.

Although it is not in wide use today, ALGOL introduced many influential concepts to programming languages, such as block scoping, so can be considered the ancestor of languages such as Pascal and C.

ALGOL 60 on MTS

The ALGOL compiler provided by IBM for S/360 machines is available on MTS under the name *ALGOL. This follows the ALGOL 60 specification fairly closely. A number of small changes were made to the compiler to make it work under MTS.

There are also ALGOL W and ALGOL 68 compilers on MTS, the former being the most popular version in use at the time of D6.0; I will look at these in later posts.

Prerequisites

No special installation instructions to get ALGOL 60 running - just do the standard D6.0 setup as described in this guide and then sign on as a regular user such as ST01.

Compiling using *ALGOL

*ALGOL will read source from scards (by default *source* ie standard input) and will write object files to spunch. Unlike some other MTS compilers you need to provide a filename for spunch as there is no default.

One gotcha is that *ALGOL will not clear out the file used for writing object code, so you need to run $empty on it before recompiling each time.

Other *ALGOL compilation parameters are listed in MTS Volume 2X.

To run ALGOL 60 programs you need to concatenate the runtime library *ALGOLLIB with the object file. Say your object code is in the file -load then to run it you would do:

# $run -load+*algollib

Hello world

Here’s a simple program to print “Hello, world!” five times.

'BEGIN'
'COMMENT' Hello World program for ALGOL 60;
    'INTEGER' I;
    'FOR' I := 1 'STEP' 1 'UNTIL' 5 'DO'
    'BEGIN'
         OUTSTRING(1, '('Hello, world!')');
         SYSACT(1, 14, 1);
    'END'
'END'

Indentation is not important except to make the program readable. Note the quotation marks around keywords like 'INTEGER' to distinguish them from identifiers: this is known as stropping.

OUTSTRING and SYSACT are not part of ALGOL 60 but are library functions provided by IBM; the SYSACT call here is used to start a new line on the output device.

Here’s a terminal log of how to compile and run the program. This assumes the source code is in file hello.al.

# $run *algol scards=hello.al spunch=-load
 i
  LEVEL 1JUL67                            OS ALGOL F                       DATE  JAN 11 1915
                                       SOURCE PROGRAM                               PAGE 001
   SC     SOURCE STATEMENT
  00000   'BEGIN' 
  00000       'COMMENT' Hello World program for ALGOL 60; 
  00000       'INTEGER' I;
  00001       'FOR' I := 1 'STEP' 1 'UNTIL' 5 'DO'
  00001       'BEGIN'
  00001           OUTSTRING(1, '('Hello, world!  ')');
  00002           SYSACT(1, 14, 1);
  00003       'END'
  00003   'END'
 i
                                       IDENTIFIER TABLE                             PAGE 002
  PBN SC    PBN      NAME   TYPE  DM DSP       NAME   TYPE  DM DSP       NAME   TYPE  DM DSP
            SURR                  PR LN                     PR LN                     PR LN

  001 00000 000      I      I        018
 i
                                   STORAGE REQUIREMENTS (DECIMAL)                   PAGE 003

  OBJECT MODULE SIZE 540 BYTES.
  DATA STORAGE AREA SIZES
    PBN   BYTES       PBN   BYTES       PBN   BYTES       PBN   BYTES       PBN   BYTES
    001      48

# $run -load+*algollib
 Hello, world!
 Hello, world!
 Hello, world!
 Hello, world!
 Hello, world!

 END OF ALGOL PROGRAM EXECUTION

If you change the source file and want to recompile, remember to do %empty -load.

Further information

As always, the Wikipedia page provides a good overview of the language’s history and key features.

There is no MTS Volume on ALGOL 60 (there is one on ALGOL W, however). Some information on the *ALGOL compiler and *ALGOLLIB library can be found in the MTS Volume on obsolete commands.

The original IBM documentation for the compiler can be found at Bitsavers.

Updated 6-Feb-2015 to fix comment syntax.

Comments

comments powered by Disqus