ZetCode

Introduction to Algol 68

last modified November 13, 2026

Algol 68 is a general-purpose programming language designed in the 1960s. It is statically typed, expression-oriented, and built around a small set of concepts that are applied consistently. This article introduces the language, describes the Algol 68 Genie implementation, and shows the first programs.

What is Algol 68

Algol 68 was designed by IFIP Working Group 2.1, the group also responsible for Algol 60. The first report was published in 1968 and the language was revised in 1973; the Revised Report remains the defining document. The language is known for its orthogonal design, in which a few rules about values, names, and modes explain most of the syntax.

Every value has a mode, the Algol 68 word for a type. The primitive modes include integers, reals, complex numbers, booleans, characters, and bit strings. Transput adds files, formats, and channels. Composite modes add rows (arrays) with fixed or flexible bounds, structures, unions, procedures, and references. References are allocated with generators and reclaimed by a garbage collector.

Formatted transput is part of the language rather than a library. A program describes its output with format denotations written between dollar signs, and the implementation checks the format against the values it receives when the program runs. Algol 68 also defines a parallel clause with semaphores, which Algol 68 Genie implements.

Algol 68 Genie

The programs in this article run with Algol 68 Genie, an implementation written by Marcel van der Veer. On Debian and Ubuntu the package is called algol68g and installs the interpreter as /usr/bin/a68g:

sudo apt install algol68g

Genie parses a program, interprets the syntax tree, and performs many runtime checks. It can also translate a unit to C and pass it to the system C compiler with the -O0 to -O3 options. The examples here were tested with Algol 68 Genie 2.8.4 and are run as a68g program.a68.

The first program

An Algol 68 program is a unit. The simplest useful unit is a closed clause that begins with BEGIN and ends with END. Values are printed with print, which takes a row of values enclosed in parentheses.

hello.a68
BEGIN
  print(("Hello, Algol 68!", newline))
END

The double parentheses are not a mistake. The outer pair belongs to print and the inner pair is the row of values to print. The newline procedure ends the line; without it the next output would continue on the same line. The statements inside the closed clause are separated by semicolons, and the last statement does not need one.

$ a68g hello.a68
Hello, Algol 68!

Formatted output

The printf procedure combines a format with the values to print. A format is a FORMAT denotation between dollar signs. Inside it, g stands for a value in its general form and l starts a new line.

format.a68
BEGIN
  STRING name = "Algol 68";
  printf(($"Hello from "gl$, name))
END

The quoted text inside the format is copied to the output, g consumes the string name, and l ends the line. The format is checked when the program runs, so a mismatch between the format and the values is reported as a transput error rather than silently ignored.

$ a68g format.a68
Hello from Algol 68

Comments

A comment starts with # and ends with the next #. Comments may span several lines, and they are ignored by the interpreter.

comments.a68
# A first Algol 68 program.
   Comments may span lines. #
BEGIN
  INT year = 1968;   # the first report #
  print(("Algol 68 was published in ", whole(year, 0), newline))
END

The comment before BEGIN covers two lines. The second comment follows a declaration and explains it. The integer is converted to a string with whole(year, 0), because print pads numbers to a fixed width by default and whole gives the shortest form.

$ a68g comments.a68
Algol 68 was published in 1968

Next steps

The Algol 68 basics article continues with declarations, printing, conditionals, loops, and procedures. The program structure article explains the different kinds of clauses, and the modes article describes the primitive and composite modes in detail.

Source

The Algol 68 Genie project

Revised Report on the Algorithmic Language Algol 68

ALGOL 68 on Wikipedia

In this article we have introduced Algol 68, installed Algol 68 Genie, and run the first programs with a68g. The next article, Algol 68 basics, turns these first examples into a working knowledge of declarations, expressions, and control flow.

Author

My name is Jan Bodnar, and I am a passionate programmer with extensive programming experience. I have been writing programming articles since 2007. To date, I have authored over 1,400 articles and 8 e-books. I possess more than ten years of experience in teaching programming.

List all Algol 68 tutorials.