COBOL

COBOL Strikes Back

COBOL

COBOL Strikes Back

During the Covid-19 crisis days world saw the latest development in New Jersey City Software Systems that power unemployment benefits, powered by 60-year-old programming language COBOL. Namely, city need COBOL developers for the maintenance of their systems, based on big mainframe computers.

So, what is this COBOL?

You maybe wonder what is COBOL anyway and why it is important these days ? COBOL (short for “Common Business Oriented Language”) is an old programming language developed 60 years ago withing US Department of Defense. It was partly based on previous programming language design work by Grace Hopper, commonly referred to as “the (grand)mother of COBOL”. COBOL was massively used for decades in development of financial applications and enterprise projects in 70s and 80s.

I personally feel a strong connection to it, so I decided to write about, as I worked for a decade in a company which had more than 20 COBOL programmers and a mainframe computer, learned it at University and the last but not least, my father was COBOL programmer for more than 20 years.

Why is COBOL still used so much?

Someone who is Java or C++ developer today probably doesn’t now anything about it, even though 70% of all world daily business transactions and 95% of ATM swipes relies on it. Researchers at Lero claim that there are more than 200 times more COBOL transactions than Google searches worldwide. Reuters calculates that there’s still 220 billion lines of COBOL code currently being used in production today, and that every day, COBOL systems handle $3 trillion in commerce. The code base itself is growing 1.5 billion lines per year, although it is noted as No.1 dead or dying computer language.

Why haven’t we replaced COBOL?

Replacing billions of lines of COBOL that exist is not an easy task. A lot of those programs contains sensitive information such as banking information of health-care records. As many as 75% of all rewrite projects until now resulted in failure. Some code has run effectively for decades, making it hard to convince business the return on investment required to transition to something modern. Also, the code is old, multi-layered and poorly documented, so it would be hard to get the business logic so easily. COBOL has been used reliably for high-volume transaction processing for so long that the cost of moving to newer languages has simply outweighed the benefits.

Newer languages also have not had chance to stand test of time, so no one knows how robust they will be in the following years. So for many, COBOL is here to stay.

Demand for COBOL skills

COBOL programmers are starting to retire and young programmers show no interest for it, however all of the production code needs to be maintained. Market will need to fix this by drawing more software engineerings into learning this language, as COBOL isn’t particulary complex language to learn. An average age of COBOL programmer is still 55-years-old.

Some big organizations like IBM and MicroFocus started programs to promote COBOL to young generations. IBM has developed curricula in association with more than 80 universities and still offer mainframe systems that are compatible with COBOL.

We can also see some job posting for COBOL, even here in Serbia.

Why is COBOL still dominant?

Robert L. Glass explains that COBOL does the 4 essential business tasks better than most modern languages today:

  • The capability for heterogeneous “record-structure” data.
  • The capability for decimal arithmetic.
  • The capability for convenient report generation.
  • The capability for accessing and manipulating masses of data (typically made up of heterogeneous data structure).

Its actually very good in all of these categories except for ui and database access and have unique capability to carry out well massive batch processes. COBOL is intuitive and easy to learn because of its English-like structural components and it has been ported to virtually every hardware platform. It even runs in modern IDEs - Visual Studio (Code) and Eclipse.

What is the future of COBOL?

As COBOL will stay for many years to come, thats for sure, so the question is it the right time to learn it ? For some learning COBOL would be a sensible career move. It offer a plentiful of work and thanks to a shortage in supply, COBOL programmers should be able to be payed well.

The downside of taking this path is even though you get a lot of job security, it could be a boring path, as it is used often by unglamorous and rather staid organizations. It doesn’t have all the new and fancy features of modern languages.

What could be a good balance is trend of integrating COBOL applications into newer mobile and Web applications, done in C# or Java and you can actually do TDD in COBOL or run it on the Web. You can even put it to Docker or run in a cloud-native way by leveraging Kubernetes cluster.

Why COBOL modernization should be a priority

Modernization of software systems and processes should be a priority since business continuously grow an evolve, along with requirements change, so critical applications need to be modernized in order to keep pace with new demands. We can achieve that by leveraging some of the following:

  • Faster deployment of mainframe applications, using DevOps techniques, as teams need to work distribution and in the cloud.

  • Visual tools for COBOL can offer programmers a superior development experience.

  • Providing tools for accessing COBOL data files.

  • Integrating mainframe systems with Cloud applications.

Conclusion

So what is the solution the to “COBOL problem”? Its obviously not only COBOL problem but wider technical problem and it is too complex to have a single solution for it. Rewriting everything is obviously not possible solution, but getting there little by little is probably a good start. Similar software, with the same business logic and in the same areas will come and it will replace some of those systems, for sure.

However, what are some lessons we can learn from all of this? Even if we transitioned all the code to Java or C#, will a future generations need to do the same transition from Java or C# to a newer language and companies have a once again to go through another expensive and time-consuming transition? Are we going to hit the same crisis next time issues happens?

There are some questions for which we still doesn’t have answers. One thing we can say for sure is that we need to be careful what technology we choose, as it going to work probably for decades. The technology doesn’t need to be the latest and most fancy one, but instead robust and proved one.

What we as developers can do, is to try to write high-quality code which solve current problems while being accommodating towards future modifications, as probably most of the code we write will outlive us. This means to write code that is readable, modular, reusable and maintainable. In order to do that, we need to write clean code, to use Test-Driven Development, source code version-control systems, automated code review tools, continuous integration, to properly document software and many more techniques available today, that were not available 30, 40 or 50 years ago.

Appendix: Writing COBOL programs

In order to start experimenting with COBOL, we can do following:

You can compile and run program with:

cobc -x -o hello hello.cbl

./hello

How COBOL works actually, it read files, perform some actions on data and then create reports and store data.

Here is the Hello World example written in COBOL

COBOL programs have four main divisions:

  • Identification Division (name of the program, dates).
  • Environment Division (what kind of system its being built on, what compiler, etc.).
  • Data Division (used to defined file fields).
  • Procedure Division (main code).

Declaring Variable

In the example below we show how to declare and print variables. Variables are defined in the Data devision and we print them in the Procedure division. They are defined with PIC, which stands for picture and use functions of the form type(elements), so 9(5) would correspond to having enough room in memory for storing number with 5 values. 9 means numeric, A alphabetic and V decimal.

Common verbs

Some of the COBOL common verbs are: compute - used to do arithmetic, divide, multiply, add, initialize, used to reset variable after its been set, etc.

Conditionals

In the next example we show if/else statements:

Looping

The following figure shows a looping logic in COBOL. Here we can see that we can some parts of procedure division, which can be used as functions in other programming languages.

Files

Files are organized inside COBOL like a table. There are sequential, indexed and relative files. The main difference here is the order in which data is entered in a file. Here is the example of dealing with sequential files. It consists of records and each record consists of fields. The file type needs to be specified in INPUT-OUTPUT section and then what kind of records are in a file. Then we need to create such record with the same structure.

Learning COBOL

How you can learn COBOL? There are some resources, such as this Udemy course or several books on Kindle, like Beginning COBOL for Programmers by Michael Coughlan.

Thanks for reading!

Avatar
Dr Milan Milanović
Chief Technology Officer

Building great products, building great teams!