01 — divisions
A COBOL program is paperwork: identity, environment, data, then procedure — structure by bureaucracy.
IDENTIFICATION DIVISION.
ENVIRONMENT DIVISION.
DATA DIVISION.
PROCEDURE DIVISION.§ 02 — Eras · 1959
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.
Every vendor’s machine processed business data differently, and programs were unreadable to management. COBOL standardized both.
Verbosity beyond parody — and it worked so well that billions of lines are still running, long after anyone could fully explain how.
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).
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.
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.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.
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).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).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.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.
MOVE WAGE TO OLD-WAGE.
ADD BONUS TO WAGE.
DISPLAY "NEW WAGE IS" WAGE.installbrew install gnucobol
runcobc -x fact.cob && ./fact
Banks, insurers and governments settle your money through COBOL every single day; the retirement projects have all failed so far.