BBC Home

Explore the BBC

h2g2
30th December 2009
Accessibility help
Text only

Guide ID: A624205 (Edited)

Edited Guide Entry


SEARCH h2g2
Edited Entries only
Search h2g2Advanced Search


New visitors: Create your membership
Returning members: Sign in
BBC Homepage
The Guide to Life, The Universe and Everything.

3. Everything / Languages & Linguistics / Languages / Computer Languages
3. Everything / Maths, Science & Technology / Computers / Computer Languages and Programming

Created: 5th November 2001
COBOL - the Programming Language
Contact Us


Like this page?
Send it to a friend!

 

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:


   USING A COLT-45-HANDGUN,
      AIM GUN AT FOOT OF LEG, THEN
         PLACE FINGER OF HAND OF ARM ON
            TRIGGER OF HANDGUN AND SQUEEZE
            THEN RETURN HANDGUN TO HOLSTER
         END-PLACE
      END-AIM
   END-USING.
   CHECK WHETHER SHOELACE NEEDS TO BE RETIED.

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.


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


Clip/Bookmark this page
This article has not been bookmarked.
ENTRY DATA
Written and Researched by:

SchrEck Inc.

Edited by:

Konrad (1x6^(9-8)x(8-1)=42) (OMFC) (Goo at work, alabaster at home)

Referenced Entries:

The Millennium Bug Crisis
Object-oriented Programming
Operating Systems
The GOTO Statement
C - the Programming Language
Assembly Language
Seven Secrets of Successful Programmers
BASIC - the Programming Language

Related BBC Pages:

Information Technology - ...

Referenced Sites:

The COBOL Portal

Please note that the BBC is not responsible for the content of any external sites listed.


CONVERSATION TOPICS FOR THIS ENTRY:

Start a new conversation

People have been talking about this Guide Entry. Here are the most recent Conversations:

TITLE
LATEST POST
COBOL and line numbersJan 30, 2003
"Shoot yourself in the foot."Jan 27, 2003
QuoteJun 6, 2002
Collective nounNov 6, 2001




Disclaimer

Most of the content on h2g2 is created by h2g2's Researchers, who are members of the public. The views expressed are theirs and unless specifically stated are not those of the BBC. The BBC is not responsible for the content of any external sites referenced. In the event that you consider anything on this page to be in breach of the site's House Rules, please click here. For any other comments, please start a Conversation above.




About the BBC | Help | Terms of Use | Privacy & Cookies Policy