3 open source projects keeping COBOL alive and well

3 open source projects for modern COBOL development

COBOL programming language
Image by : 

opensource.com

An iconic figure of the early history of computing, Grace Hopper is the grandmother of the COBOL programming language. Of her many claims to fame, she invented the first compiler and helped spread the adoption of machine-independent programming languages. Today her legacy lives on in many ways, including the Grace Hopper Celebration of Women in Computing.

While Hopper contributions to computing are remembered, celebrated, and built upon by her successors, COBOL itself is often dismissed as a relic of earlier era of computing. To a certain extent, that is true. Most of the COBOL being written today is for maintaining legacy code, not starting new projects. However, the language is still being updated with COBOL 2014 being the most recent standard for the language, and there are still plenty of opportunities to apply for jobs that require COBOL experience.

Thankfully, using COBOL in modern times does not require tracking down legacy hardware. There are several tools available that make using COBOL on modern computers as straightforward as using other programming languages. Below, I take a look at three open source projects that help you code, compile, and use COBOL on a Mac, Linux, or Windows computer. So grab a book on COBOL programming, (if you need one, Beginning COBOL for Programmers by Michael Coughlan is an excellent choice), and start exploring the world of COBOL. No punch cards required.

GnuCOBOL

GnuCOBOL (formerly known as OpenCOBOL) is a modern, open source, COBOL compiler. It works by translating COBOL code into C and compiling the code using GCC. While the project does not claim standards compliance, it passes most of the tests in the COBOL 85 test suite from the National Institute of Standards and Technology. Other compilers might be more standards compliant or contain the same quirks as their historical antecedents, but GnuCOBOL is the compiler used by the other two projects I cover below.

To install GnuCOBOL on Fedora:

sudo dnf install open-cobol

Installing under most other Linux distributions and other UNIX-style systems is just as simple. For Debian-based distributions, just replace "dnf" with "apt-get". Mac users can use homebrew to install GnuCOBOL. Installing on Windows is a little more complicated, but instructions are available for those interested in trying GnuCOBOL on Windows.

To compile source code in a file name 'PROGRAM.cob' into an executable file run:

cobc -x PROGRAM.cob

There are many other compilation options, which are listed when running "cobc -h". The GnuCOBOL FAQ is very extensive and provides a large amount of information about using GnuCOBOL.

OpenCobolIDE

You can write COBOL using the text editor of your choice, but integrated development environments make life easier. OpenCobolIDE is a specialized IDE designed for working with COBOL. It provides code completion, code folding, syntax highlighting, and a navigation tree, all of which aid in working with COBOL code. It also has a wide variety of color schemes, both light and dark, so most users should be able to find a theme they are comfortable with using.

OpenCobolIDE is a well designed program and is very nice to work with. It is, as noted above, a very specialized IDE that only work with one programming language, but it works with that language quite well. The interface is simple and should not require too much effort to get used to, but should a user need help, the OpenCobolIDE documentation provides a good overview of the IDE.

OpenCobolIDE

To install OpenCobolIDE on Fedora you will need to install a few prerequisites first. Install them by running:

sudo dnf install open-cobol python3-qt5

Then install OpenCobolIDE by running:

sudo pip3 install OpenCobolIDE

Installation for other distributions is similar (just replace "dnf" with the appropriate command and install your distribution's equivalent of the open-cobol and python3-qt5 packages). Some distributions do have OpenCobolIDE available as a package in their repositories, so check to see if it available before install via "pip". Windows and Mac users can download OpenCobolIDE installers and use those instead of using "pip".

COBOL bridge for Node.js

Maybe you would like to combine some COBOL code with a more modern development technology? If that is the case, you are in luck. COBOL bridge for Node.js allows you to use COBOL code in Node.js projects.

Node-cobol requires GnuCOBOL, so install that using the instructions above and then run:

npm install cobol

According to the developer, the project is production ready, but honestly it is such an oddity that it unlikely that it is actually being (or will ever be) used in production. Maybe some enterprising reader will come up with a practical use for Node-cobol and share the story of their project with us?

Topics

About the author

Joshua Allen Holm
Joshua Allen Holm - Joshua Allen Holm is a Grand Rapids, Michigan, based writer and technology consultant. As one of Opensource.com's community moderators, he writes articles about open access, open education, and open source software. You can find Joshua on GitHub and Zotero, or email him at: holmja@opensource.com.