A simple "Hello, world" program in COBOL
by Timmy Jose
Recently I decided to start learning some COBOL (never had it in university). I’m using the excellent book by Michael Coughlan, “Beginning COBOL for Programmers” - the author’s vast teaching experience shows through in this excellent book.
Beyond COBOL, I plan to start learning about mainframes as well. Why? Well, why not?
In that vein, here is a simple “Hello, world” program in ANS COBOL (I’m using gnucobol
on macOS):
*> Display "Hello, world" on the screen
IDENTIFICATION DIVISION.
PROGRAM-ID. HelloWorld.
AUTHOR. Timmy Jose.
DATE-WRITTEN. 19th APR 2020.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 DisplayMessage PIC X(12) VALUE "Hello, world".
PROCEDURE DIVISION.
BEGIN.
DISPLAY DisplayMessage
STOP RUN.
Running it:
~/dev/playground$ cobc -x HelloWorld.cob && ./HelloWorld
Hello, world