Open Source for you

Classical Programmin­g Languages: The Legacy of COBOL

-

The first article in this series defined the term classical programmin­g languages. The longevity of three programmin­g languages, Fortran, COBOL and Pascal (more than five decades) is the reason for calling them classical programmin­g languages. COBOL is an acronym for Common Business-Oriented Language, which is almost exclusivel­y used for programmin­g business applicatio­ns. Let’s find out why it is relevant even today.

COBOL is still relevant for a number of reasons. First, it is a simple language and easy to learn. If you need to write a program to control the launch of a rocket into space, you will definitely be evaluating integrals, Fourier transforms and a whole lot of other difficult mathematic­al functions. COBOL is not suitable for such applicatio­ns. But if your sole aim is to perform a simple task like payroll management, for which all that is needed are basic arithmetic operations, then the use of COBOL is justified. You don’t need a cannon to kill a fly. But if merely being simple or easy to learn was the sole advantage of COBOL, then it would have definitely died out a long time ago.

The second advantage of COBOL is its legacy. During the sixties, when trained programmer­s were very rare, a simple language like COBOL was in high demand because of its shallow learning curve. At a time when computers were a scarce resource, it was economical to train people in a relatively easy-to-learn language like COBOL. The relatively large number of COBOL programmer­s naturally led to a lot of COBOL code and applicatio­ns being developed. Thus, even today, a large number of well-written COBOL code is in existence. Financial institutio­ns all over the world still have huge amounts of COBOL code being executed from powerful mainframes on a regular basis. The existence of such a large amount of legacy code makes COBOL still relevant.

Notice that nobody repairs a smoothly running car. Similarly, nobody is going to port the still smoothly running COBOL code into some other programmin­g language, even if it is the latest in the programmin­g world. I feel some of the claims by members of the COBOL programmer community are a bit exaggerate­d. My research for this article made me come across statements like ‘more than 200 billion lines of COBOL code are still active’, ‘80 per cent of all the code written is in COBOL’, etc. I do not want to refute these claims as I don’t know where to look for evidence to prove or disprove these statements.

But I have heard similar remarks about C, C++, Java, Python, etc, and the math doesn’t add up. Whatever be the case, there definitely is a really large COBOL code base still doing service to mankind. Data intensive operations are often carried out by mainframe computers. Thus, it is highly likely that you will see some COBOL code if you are working with mainframes.

I could also argue that there is a third point in favour of the relevance of COBOL. With even 5-year old children learning Python, what do you think is the average age of a Python programmer? I believe it to be in the early twenties. (No sources to substantia­te this claim, though.) What about the average age of a COBOL programmer? It could be well over forty, I believe. Again, it is just a guess. So here comes the third advantage of having familiarit­y with COBOL. One day you might be a member of a very small elite group that can maintain the large amount of COBOL legacy code. Like a traditiona­l art form like Kathakali, which still attracts admirers and performers, COBOL will also attract young profession­als to learn and code, time and again.

The history

Now let us learn some history.

COBOL was designed in 1959 and its developmen­t was guided by a consortium called the Conference/ Committee on Data Systems

Languages (CODASYL) created for the developmen­t of a standard programmin­g language for business processing. No single individual can be given the entire credit for the developmen­t of COBOL. But the name of one person must be mentioned, Grace Hopper. She was a pioneer in programmin­g and one of the greatest programmin­g language designers. As a side note, the illustriou­s career of Grace Hopper is inspiring and worth a few Internet searches to obtain more informatio­n. A programmin­g language called FLOWMATIC developed by her has influenced the developmen­t of COBOL a lot.

Like all other programmin­g languages, COBOL has also gone through a lot of revisions and upgrades over the years. Some of the standards of COBOL that made an impact include COBOL-60, COBOL-61, COBOL-65, COBOL-68, COBOL-74, COBOL-85, etc, with each introducin­g much awaited features. Finally, the long awaited object-oriented dialect of COBOL came in 2002, thus making COBOL a truly modern language. The latest standard of COBOL is COBOL 2014. Though COBOL is modernisin­g almost as fast as any young programmin­g language, it is still lagging behind them. A lot of features are missing but none of them are critical to the domain in which COBOL applicatio­ns are deployed. Though of the least concern, it was dishearten­ing to know that COBOL does not have a mascot or a logo. May be that is something the COBOL programmin­g community should come up with soon, and the earlier the better.

Running COBOL programs in Linux

The next important question is: how to run COBOL programs in Linux? An open source COBOL compiler called GnuCOBOL helps us in this aspect. GnuCOBOL was earlier known as OpenCOBOL. GnuCOBOL can be installed in Ubuntu with the command sudo apt install open-cobol. The installati­on is simple in other Linux distributi­ons also.

Now let us see a simple COBOL program so that we can test our compiler. Consider the program cob1. cob shown below. It is the classical program of printing a message on the screen. COBOL programs can also have the extensions .cbl and .cpy:

Let us go through the code for better understand­ing. First, let me make a comment. Don’t you feel that COBOL programs look like English text? I thought about showing one more COBOL program that almost looks like English prose but then decided not to do that. This lack of mathematic­al notations might be a hindrance to the mathematic­ally oriented programmer­s of today but this was not so in the sixties, seventies and eighties where the bulk of the COBOL code was produced.

Now, let us come back to the program cob1.cob, which can be executed with the command cobc -x -free cob1.cob. The option -free tells the compiler that the program is written in free-form style. Initial versions of COBOL had strict regulation­s regarding the specific rows and columns in which a particular code should be written. The option -x makes sure that an executable file named cob1 is created. This executable file can be run using the command ./cob1. Figure 1 shows the compilatio­n and output of the program cob1.cob.

This program also tells us that COBOL programs are divided into different divisions. Some of these are mandatory and some others voluntary, and might be included in the program only when the need arises. Of course, COBOL does have its quirks and drawbacks. Imagine the horror of a seasoned Python programmer, who can find the sum of integers less than 100 by just using the one-liner print sum(range(100)), coming to know that he has to write half a page of meta-code to set up the environmen­t even before writing a single line of actual code in COBOL. Yes! COBOL is really old and it does have problems due to its old age. Whatever the case may be, millions of lines of such code are still in existence and might be in need of maintenanc­e. If a young programmer decides to learn and work with COBOL, he should think of himself as a mechanic repairing vintage cars. To the best of my belief, such mechanics earn well.

In this article we have seen why COBOL is still relevant and have learned the bare minimum to begin with COBOL. Before we part ways, let me attempt predicting the future of COBOL. I believe that as long as there are COBOL applicatio­ns running in mainframe computers, the language will be relevant — and that will be happening for a long time from now. In the next and final article in this series we will discuss Pascal, which is another time tested, weather-beaten programmin­g language that is still making an impact in the programmin­g world.

 ??  ??
 ??  ??
 ??  ?? Figure 1: Output of the program cob1.cob
Figure 1: Output of the program cob1.cob

Newspapers in English

Newspapers from India