COBOLPRIMER
Run COBOL
Designed by the CODASYL committee, 1959

The Backbone of Global Finance, Demystified.

By the most-quoted industry estimate, COBOL handles around 95% of ATM swipes and trillions of dollars in daily transactions[?]. Designed to read like English, it made exact decimal business math a language feature back when computers filled whole rooms.

HELLO.cbl
FIXED FORMAT

000100 IDENTIFICATION DIVISION.

000200 PROGRAM-ID. HELLOWRLD.

000300 PROCEDURE DIVISION.

000400 DISPLAY 'HELLO ENTERPRISE WORLD!'.

000500 STOP RUN.

Notice periods (.) ending each statement Standard ANSI-74/85

Why Learn COBOL in the 21st Century?

Understanding the timeless philosophy behind mission-critical enterprise computing.

Exact Decimal Math

Floating-point numbers in languages like JS or C can introduce subtle binary rounding bugs (e.g. 0.1 + 0.2 != 0.3). COBOL uses exact decimal/BCD representation (Packed-Decimal / COMP-3), ensuring accurate penny-to-penny ledger balances.

Self-Documenting Syntax

COBOL was designed in 1959 so that managers and non-programmers could read application logic. Instead of cryptically nested symbols, you write:
ADD BONUS TO SALARY GIVING TOTAL-PAY.

Massive Enterprise Footprint

A widely repeated estimate puts active COBOL at 220 billion lines, running airline reservations, Social Security, state unemployment systems, and core banking. As the original generation retires, people who can read it stay in steady demand.

Sixty-plus years of COBOL

COBOL wasn't one person's invention. It came out of a government-and-industry committee trying to stop every vendor from shipping its own incompatible business language.

  1. 1959

    The Pentagon hosts the meeting that forms CODASYL. A short-range committee, including Jean Sammet, designs the language in about six months, borrowing heavily from Grace Hopper's FLOW-MATIC, plus IBM's COMTRAN and Honeywell's FACT.

  2. 1960

    COBOL-60 is published. That December, the same program compiles and runs on two different manufacturers' machines, an early and very public proof of portability.

  3. 1968 & 1974

    ANSI standardizes COBOL-68, then COBOL-74. The US government's requirement that its vendors support COBOL cements it as the default language of business data processing.

  4. 1985

    COBOL-85 brings structured programming: EVALUATE, inline PERFORM, and scope terminators like END-IF. Most code you'll meet today is written in this dialect.

  5. 1999–2000

    Y2K. Decades of PIC 99 year fields, chosen to save expensive storage, trigger the largest remediation effort in software history.

  6. 2002 & 2014

    ISO COBOL 2002 adds object orientation, free-format source, and Unicode support. COBOL 2014 trims features vendors never implemented.

  7. 2020

    Pandemic unemployment claims overwhelm state benefit systems. New Jersey's governor publicly asks for COBOL volunteers, and the language is suddenly front-page news.

  8. 2023

    The latest ISO revision (ISO/IEC 1989:2023) is published, folding in long-standing vendor extensions. The language is still actively standardized.

The Four Fundamental Divisions

Every classic COBOL program is structured hierarchically into 4 distinct divisions, always appearing in this exact order.

The Fixed Column Layout (80 Columns)

Legacy COBOL relies strictly on punch-card column positions. Indentation is not decorative—it is syntactical.

Cols 1 - 6 Sequence Number

Historical line numbering (e.g. 000100) used when punch cards were physically sorted.

Col 7 Indicator Area

An asterisk (*) indicates a comment line. Hyphen (-) indicates continuation.

Cols 8 - 11 Area A

Division names, Section headers, Paragraph names, and 01/77 level variables must begin here.

Cols 12 - 72 Area B

All executable statements (DISPLAY, MOVE, ADD) and subordinated data levels (05, 10) live here.

Column Inspection View
Seq (1-6) Indicator (7) Area A (8-11) Area B (12-72)
1....5 7 8..11 12..................................................72 73..80
000100 IDEN TIFICATION DIVISION. PROG01
000200 * ---- This is an indicator comment line PROG01
000300 PROG RAM-ID. PAYROLL01. PROG01
000400 DATA DIVISION. PROG01
000500 WORK ING-STORAGE SECTION. PROG01
000600 01 WS-EMPLOYEE-NAME PIC X(20) VALUE 'ALAN TURING'. PROG01
000700 PROC EDURE DIVISION. PROG01
000800 DISPLAY 'PROCESSING RECORD: ' WS-EMPLOYEE-NAME. PROG01
000900 STOP RUN. PROG01
💡 COBOL 2002 added free-format source, but the overwhelming majority of production mainframe code still uses this fixed 80-column layout.

Understanding PICTURE (PIC) Clauses

In COBOL, you don't declare vague primitives like int or string. You define exact memory byte layouts using symbols.

9

Numeric Digit

0 through 9 only
X

Alphanumeric

Any ASCII / EBCDIC char
A

Alphabetic

Letters (A-Z, a-z) & spaces
V

Implied Decimal

Virtual decimal point (0 bytes)
S

Operational Sign

Stores positive/negative state

Interactive PIC Memory Visualizer

Test how COBOL pads & truncates values
CLAUSE

E.g., 9(5), X(10), 9(3)V99, S9(4)

// Generated COBOL variable definition

01 WS-TEST-FIELD PIC 9(5) VALUE '123'.

Physical Memory Layout (Byte-by-Byte) Total: 5 Bytes

Interactive Code Breakdown: Payroll Calculator

Click on any highlighted line in the source file below to see an architectural explanation of what COBOL is doing.

PAYROLL.cbl Click any line to inspect
LINE: 000100 STRUCTURE

IDENTIFICATION DIVISION.

The entry requirement for any COBOL compilation unit. It tells the compiler that metadata about this program unit begins here.

Key Takeaway

Headers (divisions, sections, paragraphs) must end with a period (.). Inside logic, a stray or missing period is the classic beginner bug, because a period ends the whole sentence, including any open IF.

Tip: Use the arrow buttons or click code

Check your understanding

Four questions on structure, columns, and PIC clauses.

Question 1 of 4 Score: 0