COBOL - the Programming Language Content from the guide to life, the universe and everything

COBOL - the Programming Language

4 Conversations

COBOL, Common Business Oriented Language, was developed in 1960 by a joint committee to meet the needs of the commercial world that other languages of that time, Fortran or Assembler, for instance, failed to do.

Contrary to popular belief, COBOL is not extinct today as one might guess, but it has a very outdated flavour due to the fact that its main use is on mainframes. Therefore, programming in COBOL or even knowing COBOL cannot be publicly admitted without the risk of being ridiculed1.

Let's compare COBOL with a popular, more modern programming language like C. A fictional small C program that would look like this,

Shoot yourself in the foot.

would look like this when programmed in COBOL2:


Some Trivia

  • The current standard is COBOL-85, often referred to as COBOL-2. The previous one was COBOL-74, which has just recently been replaced on older mainframes because of Y2K issues. The next standard COBOL-0x3 is currently in revision by the respective ANSI and ISO committees. The main issue of the revision is reportedly the inclusion of Object Oriented concepts.

  • A lot of COBOL programs are contaminated with hundreds of GOTOs. This is largely due to the fact that these programs (and their creators) are following the older COBOL-74 standard which lacked many of the control structures needed to avoid them. Progress is very slow within the COBOL community.

  • COBOL programs have line numbers, like earlier versions of BASIC. In fact, a COBOL program usually has to be coded in a fixed format that derives from punch cards, which allows only 80 characters per line. Only a given area could be used for 'real code' (position 12 to 72), the rest is used for line numbers, indicators and comments.

  • COBOL is a rather verbose programming language, as seen in the example given at the top of this entry. It was initially designed for business applications, and the similarity with the English language was implemented deliberately for easier learning by non-IT personnel4. There are a lot of filler words that aren't necessary and could just as well have been left out.

  • It isn't necessary to capitalise everything in a COBOL program (at least on PC and UNIX platforms) but many programmers do so in commemoration of the good old days of mainframe programming where lower case letters were automatically converted to upper case ones.

  • For business applications on mainframes, COBOL is still the language of choice in most cases. However, much of program development/debugging/testing is done on a PC nowadays; the source code is then transferred to the mainframe where it is compiled and the program is executed. Most vendors of COBOL development environments for the PC thus support cross-platform development by offering emulators for the mainframe environment.

  • In the public mind, the millennium bug is often synonymous with old COBOL programs (often referred to as 'legacy code') running on outdated mainframes that incompetent IT management failed to replace with modern technology. What is true, however, is that most COBOL programs originally stored dates with just two digits for the year, which is why billions of lines of code had to be revised worldwide to avert the big disaster on New Year's Day 2000.

What COBOL Is Good For

  • Programming on a mainframe - On mainframes, COBOL is the standard programming environment, and is typically very well integrated into the infrastructure of systems such as databases, transaction systems, etc.

  • Processing large amounts of data - Processing without much user interference is one thing mainframes are specifically designed and optimised for. Think of generating and printing 100,000 and more invoices, payslips or suchlike out of a multi-gigabyte database within two hours.

  • Database handling - COBOL has built-in routines for handling indexed files5 that are the same on every system they might be used on. In most other programming environments you have to fall back upon external routines and libraries for database handling which are not necessarily available for every possible machine or operating system.

  • Generating print output - Using COBOL to insert decimal points, currency signs and replace leading zeroes (for example) is easy and effective.

  • Multiple platform development - Due to the quite restrictive standards regarding the compiler core as well as runtime environment, COBOL programs can be ported reasonably well to other platforms. There are, however, machine-dependent data formats which could make the migration of existing data a bit more difficult.

Don't Use COBOL if...

... you aren't in a situation mentioned above, for example, if you want a graphical front end. Although most COBOL compilers have toolkits for generating graphical user interfaces, these are far better created with other programming environments. Also, more low-level applications like file compression tools, for instance, are surely not meant to be programmed in COBOL, and will be dramatically slower than the same application written in C.

1So perhaps you ought to stop reading now.2For the non-programmers it should be stressed that this example is neither real C code nor real COBOL code.3This name has changed from COBOL-9x; a due-date hasn't been announced yet.4This objective was never achieved, though.5A sort of database, admittedly a bit basic in its functionality.

Bookmark on your Personal Space

Edited Entry


Infinite Improbability Drive

Infinite Improbability Drive

Read a random Edited Entry

Categorised In:

Written by

Write an Entry

"The Hitchhiker's Guide to the Galaxy is a wholly remarkable book. It has been compiled and recompiled many times and under many different editorships. It contains contributions from countless numbers of travellers and researchers."

Write an entry
Read more