Hey there! π
I'm currently learning COBOL β yes, that old programming language from the 1960s! I know it looks outdated, but itβs still used in critical systems like banks, airlines, and government software.
I decided to document my learning journey here, in the simplest and shortest way possible, in case it helps someone else out there who's just getting started like me.
π 1. What is COBOL?
COBOL stands for Common Business-Oriented Language
It was created in 1959 to process business data (e.g., invoices, reports)
Still used today in huge legacy systems
Super readable (like plain English), but very strict in structure
π§± 2. Structure of a COBOL Program
COBOL programs are divided into four main divisions, always in this order:
IDENTIFICATION : Metadata like name, author, etc.
ENVIRONMENT : System configuration (often skipped by beginners)
DATA : Variable declarations
PROCEDURE: The actual logic β your code goes here!
π§Ύ Example Program
IDENTIFICATION DIVISION.
PROGRAM-ID. HelloWorld.
ENVIRONMENT DIVISION.
DATA DIVISION.
PROCEDURE DIVISION.
DISPLAY "Hello, World!".
STOP RUN.
π 3. COBOL Columns (Important!)
COBOL was made for punch cards, so it has strict rules about where you write your code:
1 β 6 : Sequence numbers (optional, can ignore)
7 : * for comments, - for line continuation
8β72 : Actual code goes here (indentation often starts at column 8)
73β80 : Ignored by compiler
π 4. Declaring Variables (DATA DIVISION)
DATA DIVISION.
WORKING-STORAGE SECTION.
01 Name PIC A(20).
01 Age PIC 99.
Explanation:
PIC = Picture Clause, defines the variable type
A(20) = 20 alphabetic characters
99 = 2-digit number
π§Ύ 5. Input and Output
DISPLAY "Enter your name: ".
ACCEPT Name.
DISPLAY "Hello, " Name.
DISPLAY shows a message
ACCEPT takes input from the user
π 6. IF Conditions
IF Age > 18
DISPLAY "You are an adult."
ELSE
DISPLAY "You are a minor."
Pretty readable, right?
π 7. Loops with PERFORM
WORKING-STORAGE SECTION.
01 I PIC 9 VALUE 1.
PROCEDURE DIVISION.
PERFORM VARYING I FROM 1 BY 1 UNTIL I > 5
DISPLAY "Count: " I
END-PERFORM.
Prints:
Count: 1
Count: 2
Count: 3
Count: 4
Count: 5
Thatβs what Iβve learned so far!
This post is meant to be a beginner-to-beginner guide, Iβll keep sharing more as I go deeper into COBOL.
If youβre also learning COBOL or just curious about it, feel free to follow along! Letβs bring a bit of life into this powerful (but old-school) language.
Top comments (0)