COBOL’s Innovative English Mimicry

“In my opinion, it excels at that, even better than modern programming languages.”

Years ago, I took a college course on the COBOL programming language while studying computer science.[1]  The version of COBOL being taught in the course was from the 1960s or 1970s.  Having already learned some Pascal and FORTRAN, I was disappointed with what COBOL apparently lacked.  While COBOL had what might best be referred to as “subroutines,” the subroutines in our programs did not have have parameters, return values, or even local variables.  Yes, all data was global, a situation that has been blamed for at least a few problems in faulty software.  I don’t recall whether such features were absent from the version of COBOL we used, or if they simply did not fit into the scope of that one-semester course.  Regardless, even that old version of COBOL had a quality I found very impressive then, and even more so now.

Before getting to the main point, it might be worth mentioning some of the many conveniences of COBOL.  A numeric variable could be declared with a specific display width and number of decimal places, so you knew up front how its value would be displayed.  The same thing could be done with thousands separators.  If you wanted a zero value to show up as blank, you could indicate that quite easily, without the obligatory If statement often needed in other languages.  When copying all the parts of one composite variable to another, simply use MOVE CORRESPONDING.  Modern object-oriented languages, on the other hand, often require the parts to be copied individually – you have to write your own Copy code and refer to each part.

Conveniences aside, COBOL was designed for code to be easily understood by just about anyone, even people who don’t use computers.  In my opinion, it excels at that, even better than modern programming languages.  The designers of the language did an excellent job of making COBOL source code look like plain English, sometimes to a fault.  As intended, a business person could easily understand the code or even write their own programs.

While some people may find math intimidating, COBOL makes it easier to understand. For example, adding two numbers and storing the result in variable X, looked like the following in the version I used:

ADD 3.53 TO 16.78 GIVING X.

Subtraction looked like this:

SUBTRACT A FROM B GIVING C.

Other basic math operations like multiplication or division were similar.  If that became too cumbersome, an expression with math symbols could be computed with COMPUTE.  Even then, the symbolic operators we expect today like “+” or “-” could be optionally replaced with more verbose versions like PLUS or MINUS.

Of course, the mimicking of English did not stop with arithmetic. Loops, input, and output are good examples. Furthermore, groups of statements in COBOL are called sentences and end with periods. Sentences are grouped into paragraphs (what else?). And sentences can start one after another in the same line, instead of each starting at the left in a new line. So COBOL sentences can resemble text from a book.

Using plain English to instruct a computer to do simple tasks may not seem as impressive nowadays, now that we have virtual assistants and other voice-operated conveniences. But COBOL was created in 1959, when programming languages – and even computers – were still relatively new.  So the designers did not have the benefit of copying from the variety of programming languages we have today.  What about popular AI languages LISP and PROLOG that  have been so often used for natural language processing?  LISP had only been first implemented that very same year, and PROLOG would not be invented yet until 1972.

So modeling COBOL so closely after English was in fact very innovative for that time.  It is truly amazing that with all the modern hype of natural language processing, COBOL designers were able to make extensive use of English-like input at such an early time. They were successful enough that the language continues to be used, in spite of numerous predictions of its demise.[3] Reuters estimates that 43% of banking systems in use are still using COBOL code.[4] Granted that longevity is due in part to potential costliness of incorrectly reproducing existing critical software. Still, I find the COBOL language very impressive. If I were to try to design a modern user interface based on the English language, I suspect it will would look very much like COBOL.

References

[1] https://en.wikipedia.org/wiki/COBOL

[2] https://en.wikipedia.org/wiki/Timeline_of_programming_languages

[3] https://www.microfocus.com/en-us/what-is/cobol

[4] http://fingfx.thomsonreuters.com/gfx/rngs/USA-BANKS-COBOL/010040KH18J/index.html

(c) Copyright 2022 by Mike Ferrell

Leave a comment