← the guideThe Compiler Age

§ 02 — Eras · 1960

ALGOL 60

the language every other language is written in

Left: era context, features, and the 101 hello. Right: 3 core concepts, 3 deeper 201 lessons, the factorial specimen, and where ALGOL 60 lives today — each column scrolls on its own.

creators
International committee, 1960
status
historical · its ideas won completely
lineage
→ BCPL

The problem it solves

Algorithms were published in prose nobody could verify. ALGOL 60 became the universal notation for expressing them precisely.

The problem it carries

No standard input/output, no vendor behind it: adopted by every textbook, deployed by almost no computer.

Key features

the block
begin…end scopes names and variables; structure that nests and reasons.
lexical scope
A name is visible exactly where it was declared — the ancestor of every block-scoped language.
call-by-name
Arguments are expressions, re-evaluated at each use — Jensen’s device, and the mother of lazy evaluation.
a BNF grammar
The syntax defined in Backus–Naur form, so parsers could be generated mechanically.

101 — hello, world

Session one is the smallest program that still counts as speaking ALGOL 60: what every tutorial prints first, in the dialect that mattered when the language arrived (1960).

the first program1960
begin
  outstring (1, "Hello, world")
end

101First contact — hello world and 3 ideas that define how ALGOL 60 reads. 201 — 3 lessons on mechanisms you meet after the factorial specimen: the sharp edges practitioners actually use.

101 — core concepts

3 fragments, each naming a habit of mind in ALGOL 60. Read the note, then the code — together they are the 101 in one sitting.

01 — the block

Names scoped to begin…end — the brace of every C-family language is an ALGOL block.

begin
  integer n;
  n := 5
end

02 — call-by-name

ALGOL’s most famous experiment: pass the expression itself, re-evaluated at each use.

procedure SUM (x, i, n);
  ...  x + x + x  with i changing ...

03 — BNF grammar

The first language defined by a formal grammar — syntax became mathematics.

<digit> ::= 0 | 1 | 2 | 3 | ... | 9

201 — going deeper

The 201 assumes you have read the 101 and the specimen. Each lesson is one mechanism — what it is for, how it looks in code, and the trap or payoff that makes ALGOL 60 distinctive at scale.

  1. call-by-name versus call-by-value
  2. own variables
  3. co-routines and formal procedures

call-by-name versus call-by-value

ALGOL had both, and the difference is subtle enough to have kept implementers busy for thirty years — the famous “Jensen’s device” exploits call-by-name to iterate an array in place.

procedure p (x, i, n);
begin
  x := x + x     ! re-evaluated on every use of x
end

own variables

An own variable belongs to a procedure instance rather than a call, persisting across calls — the ancestor of static and class variables.

procedure counter;
  integer own n;   ! survives between calls
  begin n := n + 1; write(n) end

co-routines and formal procedures

Co-routines suspend and resume each other, and parameters can themselves be procedures — two features that took until the 1960s to reappear elsewhere.

The specimen — factorial

The block: nested scopes, declared names, structure you can prove things about — and a grammar defined in BNF. Every C-family language since is a dialect of this argument.

the block1960
begin
  integer n;
  n := 5
end

Run it today

installbrew install marst

runmarst fact.a -o fact.c && cc fact.c -lmarst -lm -o fact && ./fact

Where it is now

Nowhere directly; everywhere indirectly. Pascal, C, Java, JavaScript and Rust are all dialects of the ALGOL argument.