/

An Introduction to COBOL: The Language Behind Financial Systems

An Introduction to COBOL: The Language Behind Financial Systems

COBOL may be a name you’ve heard before, but it’s not just a relic of the past. In fact, it plays a critical role in the functioning of banks and financial institutions. With over 70% of business transactions relying on COBOL programs, it’s clear that this language is far from obsolete.

Originally designed in 1959, COBOL, an acronym for Common Business-Oriented Language, was created specifically for business applications. While its name may not be the most exciting, it accurately captures its purpose.

The longevity of COBOL is also a testament to its importance. Rather than being rewritten from scratch, these programs have stood the test of time, undergoing maintenance and improvement as needed. This is why COBOL remains a core part of many financial systems.

If you’re interested in trying out COBOL for yourself, you can start by installing the GNU COBOL compiler. On a Mac, you can use Homebrew to install it with the following command:

1
brew install gnu-cobol

Once installed, you’ll have access to the cobc command, which allows you to compile and run COBOL programs. You don’t need an Integrated Development Environment (IDE) to get started; simply write your COBOL programs in a .cob file and compile them using the following command:

1
cobc -x <filename>.cob

Let’s begin by creating a basic “Hello, World!” program in COBOL. Open a new file called hello.cob and add the following code:

1
2
3
4
5
6
HELLO
IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO.
PROCEDURE DIVISION.
DISPLAY "Hello, World!".
STOP RUN.

To compile the program, run the following command in your terminal:

1
cobc -x hello.cob

This will generate a binary file. To run the program, use the following command:

1
./hello

You should see the message “Hello, World!” displayed on your screen.

Next, let’s create a program that sums two numbers entered by the user. Create a new file called sum.cob and add the following code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
HELLO
IDENTIFICATION DIVISION.
PROGRAM-ID. ADDITION.
DATA DIVISION.
WORKING-STORAGE SECTION.
77 NUM_1 PIC 9(4).
77 NUM_2 PIC 9(4).
77 SOLVE_SUM PIC 9(4).
PROCEDURE DIVISION.
PARA.
DISPLAY "First number: ".
ACCEPT NUM_1.
DISPLAY "Second number: ".
ACCEPT NUM_2.
COMPUTE SOLVE_SUM = NUM_1 + NUM_2.
DISPLAY "Sum: " SOLVE_SUM.
STOP RUN.

Compile the program using the same cobc command as before:

1
cobc -x sum.cob

Run the program with:

1
./sum

You’ll be prompted to enter two numbers, and the program will calculate their sum, displaying the result on the screen.

Keep in mind that these examples are a small taste of what COBOL can do. While I may not fully understand the intricacies of these programs, experimenting with them has given me a glimpse into the world of COBOL.

Whether you’re curious about its historical significance or considering a career in financial systems development, exploring COBOL can provide valuable insights. So, the next time you encounter COBOL, you’ll know exactly what to expect.

tags: [“COBOL”, “financial systems”, “programming languages”]