The COmmon Business-Oriented Language (COBOL) is a compiled programming language first introduced in 1959. COBOL is not a language you would reach for when building new software however it is still used by many systems today. These are huge systems that keep the world running. Think of systems that handle banking transactions for example. Banking itself has such complex business logic that rewriting the COBOL code to a "modern" language would be a huge undertaking.
So why learn COBOL? COBOL isn't exactly the language taught or sought after today. If you look at today's landscape, you'll find C++, Javascript, Rust, and many other "modern" languages. The number of COBOL developers is decreasing but there are systems that still need to be maintained. Being a COBOL developer could be a very lucrative job.
Let's now take a look at COBOL at a high level.
COBOL versions
The COBOL language has 3 main versions:
- COBOL-85
- COBOL-2002
- COBOL-2014
As a COBOL developer, you can expect most of your development will be done in COBOL-85.
GnuCOBOL
GnuCOBOL is one of the more popular COBOL compilers.
Installing on Windows
Follow the instructions on GnuCOBOL's SourceForge page.
Installing on Ubuntu
sudo apt-install gnucobol
Installing on MacOS
We will be using Homebrew to install GnuCOBOL.
brew install gnu-cobol
File extensions
COBOL programs can have the following file extensions:
.cobc
.cbl
.cob
.cpy
The extensions used will depend on the coding practices set by the project.
Hello world!
Let's create a new file called hello-world.cbl
.
IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO-WORLD.
PROCEDURE DIVISION.
DISPLAY 'Hello, world'.
STOP RUN.
We've written our first COBOL program! Let's compile and run it now. In a terminal, do the following:
cobc -x -F hello-world.cbl # Creates an executable called hello-world
./hello-world # Runs the executable
> Hello, world
That's it for now. In future posts we'll take a deeper look in how to write COBOL.
Top comments (0)