← the guideThe Compiler Age

§ 02 — Eras · 1959

COBOL

business English that never retired

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

creators
CODASYL committee (from Grace Hopper’s FLOW-MATIC), 1959
status
alive (very) · an estimated 800 billion lines still run

The problem it solves

Every vendor’s machine processed business data differently, and programs were unreadable to management. COBOL standardized both.

The problem it carries

Verbosity beyond parody — and it worked so well that billions of lines are still running, long after anyone could fully explain how.

Key features

the record
Fixed-layout fields described with PICTURE clauses — data specified before the logic that uses it.
english-like verbs
MOVE, ADD, DISPLAY: a hundred English words that read like a procedure in a manual.
divisions
Identification, environment, data, procedure — a program organized like a bound document.
the portability mandate
One standard enforced across vendors by the DoD — the reason it outlived every rival.

101 — hello, world

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

the first program1959
IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO.
PROCEDURE DIVISION.
  DISPLAY "Hello, world".
  STOP RUN.

101First contact — hello world and 3 ideas that define how COBOL 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 COBOL. Read the note, then the code — together they are the 101 in one sitting.

01 — divisions

A COBOL program is paperwork: identity, environment, data, then procedure — structure by bureaucracy.

IDENTIFICATION DIVISION.
ENVIRONMENT DIVISION.
DATA DIVISION.
PROCEDURE DIVISION.

02 — PICTURE clauses

Data is described by picture: seven digits, implied decimal point — layouts as types.

01  WAGE      PIC 9(7)V99.
01  EMPLOYEE  PIC X(20).

03 — the verbs

Four hundred English words; a manager can almost read the payroll run.

MOVE WAGE TO OLD-WAGE.
ADD BONUS TO WAGE.
DISPLAY "NEW: " WAGE.

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 COBOL distinctive at scale.

  1. copybooks and the linkage section
  2. tables and OCCURS
  3. intrinsics and string handling

copybooks and the linkage section

Record layouts live in copybooks shared across programs, and the linkage section passes them between units — an interface discipline that predates most languages.

*> crew.cpy
01  CREW-RECORD.
    05  CREW-ID       PIC 9(6).
    05  CREW-NAME     PIC X(20).

tables and OCCURS

Fixed and variable-length tables, indexed like arrays, with OCCURS DEPENDING ON sizing the table to the record count.

01  PORT-CALLS OCCURS 50 TIMES
          DEPENDING ON CREW-COUNT.
    05  PORT-NAME     PIC X(10).

intrinsics and string handling

INSPECT, UNSTRING and STRING provide the text surgery that made COBOL the language of reports — heavy machinery for light work.

INSPECT CREW-NAME TALLYING ALPHA FOR CHARACTERS
  BEFORE INITIAL "A" AFTER INITIAL "Z".
UNSTRING CREW-NAME DELIMITED BY SPACE INTO FIRST-NAME REST.

The specimen — factorial

Data first: the record — named fields, pictures of their format — so a payroll program could read like the payroll office talks. Verbs for managers, structure for the machine.

the record1959
MOVE WAGE TO OLD-WAGE.
ADD BONUS TO WAGE.
DISPLAY "NEW WAGE IS" WAGE.

Run it today

installbrew install gnucobol

runcobc -x fact.cob && ./fact

Where it is now

Banks, insurers and governments settle your money through COBOL every single day; the retirement projects have all failed so far.