The COBOL Programming Language
From modern, high development velocity scripting languages for a startup like JavaScript to machine learning undefeated king Python, from newborn Go to cooperate staple like Java, C++, or even C. However, recently, one programming language suddenly took my notice, that one is COBOL.
A Brief History
COBOL, which stands for “Common Business Oriented Language,” is a programming language designed in 1959 by a group of programmers for business use. As a high-level programming language, programs written in COBOL can be run on more than one manufacturer’s computer instead of other contemporary machine-specific counterparts.
Interestingly, COBOL started as research from the US Department of Defense to create a programming language that is portable and human-friendly for data processing. It soon gained attention from government agencies and private companies, which found it a great option to write software that maintains payrolls, tracks property, calculates budgets, and other aspects of conventional business processing. Since then, it has been widely adopted and even became dominant for many decades. Millions of banking transactions were handled by programs written in this language. COBOL, along with FORTRAN, has started the rise of common programming languages and the emergence of the independent software industry from its hardware brethren.
Why Use COBOL, Benefits, and Downsides
COBOL, unlike other programming languages of its time, was designed to be portable and machine-independent. Programs are written in COBOL also have English-like syntax. These are the two main reasons why COBOL was so attractive for business purposes. Even people who worked on finance-related jobs with less programming experience could learn COBOL much easier than low-level machine languages. Also, their programs didn’t need to be modified to work on other computers when the firms updated their infrastructure. This significantly reduces the cost to rewrite programs every couple of years, not to mention the massive risk behind it. For business and financial services like banking, nothing is more important than stability and security. And COBOL is an excellent option to achieve them.
Another advantage of COBOL is that it is heavily backed by the Department of Defense and the banking industry. Because of that, more and more programmers wanted to learn COBOL, and in turn, it’s much easier to hire engineers who know this language. All these reasons combined helped COBOL to out-live many other languages that came even after it.
Despite having many advantages, COBOL is not without its downsides. Though being English-like, COBOL syntax is wordy and rigid. The initial intent was to make COBOL code self-explaining, making the maintenance easier. Also, they hoped that people without programming experience like accountants or managers would find COBOL easy to read. However, this made programmers, the primary users of COBOL, struggle with its incomprehensible syntax.
A program written in COBOL also takes more time to compile, at least compared to other contemporary machine languages.
Later COBOL also received critics due to its lack of structure, which many later programming languages like Pascal and C have fixed. Because of this, programs written in COBOL are usually wordy and hard to read and understand. Some preeminent computer scientists even used to term spaghetti code to refer to COBOL. One notable example is the use of the “GO TO” statement to implement looping.
Programs written in COBOL were infamously lacking modularization or, in other words: being monolithic. Although there were many attempts to fix this issue, most of them were unsuitable for large mainframe systems. Data is shared among procedures without being passed to the argument list is another drawback. This makes COBOL programs unmaintainable. A single change to a small section of code could completely break its logic since it might be used by another piece of code, thus making maintaining COBOL code costly and risky.
Another limitation, ironically, is its compatibility. Although COBOL was designed to be crossed-platform, the reality is far from that. With hundreds of different versions developed over time, many of them are not even compatible with each other, causing a real headache. This also significantly increases the cost to implement and maintain systems written in COBOL. As time passed, companies and organizations realized that there are less costly options to replace COBOL.
Perhaps COBOL’s worst downside is its focus on business and finance purposes but not a scientific one. This isolation prevented it from being standardized sooner. This sort of isolation also reduced the quantity of material written for COBOL. In 1985, half as many books on COBOL as on FORTRAN, a language that even came before COBOL. Universities at that time preferred to teach more “modern” languages instead of COBOL. This eventually led to the shrink of the COBOL community.
The final nail to COBOL’s coffin was its lack of general-purpose. This weakness proved crucial as later other programming languages rose and took over the programming world.
Nowadays, COBOL is a mere shadow of its former glory. Only legacy government and banking systems are still running on this once dominated programing language. As its market shrinks to nearly non-existent, it’s tough to hire software programmers that are still familiar with the language.
Although we may see COBOL come to an end in a not-so-distant future as the legacy systems and programs written in it finally phrased out. COBOL still leaves behind its most significant legacy: its influence on other programming languages.
Who Used COBOL
COBOL had its glory days. Back in the day when it was heavily used by the Department of Defense and big banks. I soon became the industry standard alongside with few other programming languages like Fortran and ALGOL.
Unlike many programming languages before it, COBOL was very user-friendly, even to the untrained eyes. Anyone can learn it in a matter of weeks. It also introduced a unique capability unheard at that time. A program written in COBOL can be re-used time after time with other mainframes. COBOL once dominated the banking system and government agencies, both at the state and federal levels.
After being standardized in the late 60s and under subsequent updates over the following decades, COBOL finally supported Object Oriented Programming in 2000. After half a century, COBOL, despite its age, remains at the heart of the countless business system.
Even today, as I’m writing these words, there are still hundreds of billion lines of COBOL code currently in use, according to research. Nearly half of the banking system is built on it. Even more shocking, 95 percent of ATM swipes cannot function without COBOL code.
With the pandemic rampaging the country, COBOL, once again, proves itself despite being called a dead language 20 years ago. The sheer amount of COVID cases now overloads many state systems designed half a century ago based on COBOL and old generation mainframes. They even called out for people who know COBOL to maintain their systems that still run on ancient mainframes. As the pool of talents is reduced to nearly non-existent, the situation looks hopeless. Some states cooperate in developing a new welfare system, but it would take several years to complete. You might not be aware or even heard of it, but COBOL still plays an essential role in our daily life.
Get Started with COBOL
Being one of the first high-level portable programming languages, COBOL shares many fundamental concepts like branching, looping, etc. However, the similarities quickly end here. As mentioned above, COBOL syntax is wordy and rigid. Each program is divided into four divisions: identification, environment, data, and procedure.
- identification division: must be the first division in every COBOL program. It includes the name of the program and optionally the date it was written and other documentary information about that COBOL program
- Environment division: this one includes two parts: Configuration and Input-Output. Since this division is optional, you need not specify it.
- Data division: this one includes four parts: File, Working-Storage, Local-Storage, and Linkage. This division is where you define variables and arguments. Similar to the Environment division, the Data division is also optional.
- Procedure division: arguably the most crucial division. This one contains the statements of the program.
Here a simple program with loop and conditional branching written in COBOL. The original code can be found in this blog.
IDENTIFICATION DIVISION.PROGRAM-ID. HELLO.DATA DIVISION.WORKING-STORAGE SECTION.01 WS-NUM1 PIC 9(9).01 WS-NUM2 PIC 9(9).PROCEDURE DIVISION.IF WS-NUM1 > WS-NUM2 THENA-PARA.DISPLAY 'Hello World'.END-PERFORM.PERFORM C-PARA THRU E-PARASTOP RUN.
The Future of COBOL
There is no doubt that COBOL is in decline. Its application is now minimal. Later, more modern general-purpose programming languages have replaced COBOL even in its once dominated territory: banking and financial systems. As the year passes, fewer and fewer programmers with deep knowledge about COBOL remain active. Only ancient and legacy government systems and some private firms are still running on COBOL in their decades-old mainframes. The state of New Jersey even called for volunteers who know COBOL to maintain its systems amid of COVID-19 pandemic to deal with an unprecedented surge of unemployment benefit applications.
It’s not only the language syntax itself that caused the drop of interest but also the deep knowledge about the mainframes used to operate these programs. Most of these mainframes were manufactured by IBM based on the CICS database system and transaction management. These technologies are no longer developed or even maintained, and it is nearly impossible to find the increasingly rare expertise.
However, out of nowhere, COBOL is receiving a massive surge in interest amid the COVID-19 pandemic. The reason? Due to an unprecedented number of unemployment benefits claims, many states call for people who know this half-century-old programming language to maintain their systems that still run on ancient mainframes. As the pool of talents is reduced to nearly non-existent, the situation looks hopeless. Some states cooperate in developing a new welfare system, but it would take several years to complete. Suddenly, the once-considered dead language is now alive than ever.
Takeaway on COBOL
COBOL pioneered high-level portable programing languages that once dominated the banking and financial industry and gave rise to later modern languages to replace the machine-specific ones. Although having many advantages, its heavy focus on business purpose, wordy syntax, and the dependence on ancient technologies finally led to the irreversible decline of COBOL. However, at least in the next couple of decades, COBOL still plays an essential role in our daily life due to the legacy systems written in it.