COBOL

COBOL (Common Business-Oriented Language) was created in 1959 to process business records. A COBOL program reads almost like English sentences, runs paragraph by paragraph, and handles decimal money exactly. It still moves a large share of the world's banking and insurance transactions.

Paradigm: Linear Programming

What Makes COBOL Special

  • Four divisions. Every program is organized into IDENTIFICATION, ENVIRONMENT, DATA and PROCEDURE divisions, always in that order. The layout is part of the language.
  • Data is described by pictures. PIC 9(5)V99 declares a number with five integer digits and two decimals. Fields, records and file layouts are defined by their exact shape.
  • Exact decimal arithmetic. Numbers are stored as decimal digits, so 0.10 + 0.20 is exactly 0.30. That is essential for money, and binary floating point cannot promise it.
  • Paragraphs and PERFORM. The procedure division is a list of named paragraphs. Control flows from one to the next, and PERFORM runs a paragraph as a subroutine.
  • English-like statements. MULTIPLY HOURS BY RATE GIVING GROSS-PAY is a complete, readable statement. This was meant to let auditors and managers follow the logic.

Example: Gross pay calculation

       IDENTIFICATION DIVISION.
       PROGRAM-ID. PAYROLL.

       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01 HOURS       PIC 99      VALUE 40.
       01 RATE        PIC 99V99   VALUE 15.50.
       01 GROSS-PAY   PIC 9(5)V99.
       01 SHOW-PAY    PIC Z(4)9.99.

       PROCEDURE DIVISION.
       MAIN-PARA.
           MULTIPLY HOURS BY RATE GIVING GROSS-PAY.
           MOVE GROSS-PAY TO SHOW-PAY.
           DISPLAY "Gross pay: " SHOW-PAY.
           STOP RUN.

How It Works

  • The DATA DIVISION declares every variable up front. 01 marks a top-level item and PIC gives its exact format.
  • RATE holds two decimals (99V99; the V is an implied decimal point), so 15.50 is stored exactly.
  • The PROCEDURE DIVISION runs its statements in order: multiply, move to an edited field, display, stop. The result is 620.00.
  • PIC Z(4)9.99 is an edited field: leading zeros are suppressed so the report shows 620.00 instead of 00620.00.
  • Columns matter in fixed-format COBOL: code starts in column 8 and statements end with a period.

History and Where It Is Used

COBOL runs core banking, insurance, payroll, airline and government systems, typically on mainframes, and estimates run to hundreds of billions of lines still in production. Modern implementations include IBM Enterprise COBOL and the free GnuCOBOL, and modernization projects are a real career path.

Learn More