COBOL basics: what the language is and where it is used

About the COBOL language

COBOL (Common Business-Oriented Language) is one of the oldest programming languages still in daily production use, created in 1959 for business data processing. It runs the banking core systems of the world, payroll, and government records, and it is still the safest language for exact decimal arithmetic at volume.

COBOL is compiled and strongly typed. Every field is declared with a PICTURE clause before the program uses it, the four divisions always come in the same order, and a sentence ends with a period. The code reads almost like English, which is why the same programs have survived for decades with only small changes.

The language is standardized by ISO. IBM Enterprise COBOL and Micro Focus are the commercial compilers on mainframes and big servers, and GnuCOBOL is the free compiler used on this site and in the course.

Where COBOL is used

COBOL runs on mainframes (IBM z/OS), and on Linux, macOS, and Windows through open source compilers like GnuCOBOL. One program can travel between a laptop and a mainframe with almost no changes.

The work is batch and transaction processing: payroll runs, bank account postings, insurance policies, airline reservations, tax records, and the nightly reports that keep a business running. CICS handles the online transactions, JCL schedules the batch jobs, and Db2 and VSAM store the data.

On this site, the 50-lesson COBOL course starts from the first program and ends with two capstone projects. The install guides cover Ubuntu, Rocky Linux, macOS, FreeBSD and Windows 11.

Hello world

A complete COBOL program needs an IDENTIFICATION DIVISION with a PROGRAM-ID and a PROCEDURE DIVISION with the statements. Save this as hello.cob:

IDENTIFICATION DIVISION. PROGRAM-ID. HELLO. PROCEDURE DIVISION. DISPLAY "Hello from COBOL". STOP RUN.

Compile it with GnuCOBOL and run the executable. The -free flag accepts free-format source, and -x builds a program instead of a module:

cobc -x -free -o hello hello.cob

./hello

Hello from COBOL

DISPLAY writes one line to standard output, and STOP RUN ends the run unit. The same five lines, with more data and more verbs, are the shape of every COBOL program in the course.

The course

Ready for more? The COBOL course: zero to hero in 50 lessons takes you from the four divisions to files, tables, SQL, CICS, Db2 and two capstone projects. Every lesson has code that compiles and runs with GnuCOBOL, and the previous and next buttons keep the chain in order.

Article author: Arthur Isaev