DEV Community

Cover image for COBOL Tutorial Series: Developing Without a Mainframe - Session 1
Duc Nguyen Thanh
Duc Nguyen Thanh

Posted on

COBOL Tutorial Series: Developing Without a Mainframe - Session 1

Hello, I'm Duke

COBOL - a 65-year-old language, yet it is used in large financial and banking systems.

Learning it is relatively difficult because it is little known and is almost as old as a human lifetime. Besides, in the past, we could only program on mainframe systems—something that individual programmers could hardly access.

COBOL

But, today I will guide you on how to program it on personal PCs running Windows 11 operating system, yeah.

To run COBOL code on Windows 11 without the need for a mainframe, you need:

  1. Download and Install the Visual Studio Code here
  2. Install the following extensions: bitlang.cobol-themes, bitlang.cobol, ms-vscode-remote.remote-wsl
  3. Install WSL follow the instructions here
  4. Install Debian on Windows Store here

Debian

Once installed, you need to install and setup a few things

1. Update Debian

sudo apt update
sudo apt upgrade -y
Enter fullscreen mode Exit fullscreen mode

2. Install GnuCOBOL Compiler

sudo apt install gnucobol4 -y
Enter fullscreen mode Exit fullscreen mode

GnuCOBOL

gnucobol4

Okay, we are done with the installation and configuration, now let's get down to writing code and compiling.

Firstly, create a hello.cbl file and then write the following code

       IDENTIFICATION DIVISION.
       PROGRAM-ID. HELLO-WORLD.
       PROCEDURE DIVISION.
           DISPLAY 'Hello, I am Duke!'.
           STOP RUN.
Enter fullscreen mode Exit fullscreen mode

On Visual Studio Code the code will look like this

Source code

Then, open Visual Studio Code terminal and run the following command

cobc -x hello.cbl
Enter fullscreen mode Exit fullscreen mode

The -x flag tells cobc to create an executable.
After running this command, a file named hello will be created.

executable

Now run the command below to execute

./hello
Enter fullscreen mode Exit fullscreen mode

and you will see the text Hello, I am Duke! appear on the terminal window

Repository here

Top comments (0)