COBOL

From Computer History Wiki
(Redirected from Cobol)
Jump to: navigation, search

COBOL (the acronym name stands for 'Common Business Oriented Language) is a programming language invented principally for use, as the name says, to build applications in business and administrative areas. It was created to improve portability of such application from one vendor's machines to another, as it was at that time beginning to be recognized that software required a very large investment (even if it was not yet plain how long the lifetime of much software would be) - an observation that was not yet acute, in an age when the cost of computing hardware was enormous.

It is one of three programming language invented in the 1950s still in wide use today (albeit all much-modified from their original forms), along with FORTRAN and LISP - although in the cases of COBOL and FORTRAN, not a great deal of new applications are being written in them. COBOL is primarily found in mainframe environments, and is used in business batch processing.

It uses English-sounding syntax (which was supposedly easier for 'average' people), rather than the mathematics-based syntax of FORTRAN. The intent was also that COBOL programs would be self-documenting, and easy to read. As a result, though, COBOL programs are verbose.

A COBOL program contains four main 'divisions':

  • identification
  • environment
  • data
  • procedure

each of which may contain a fixed hierarchy of 'sections', 'paragraphs' and 'sentences'. As is perhaps understandable, given its intended problem domain, the semantics of the language is mostly focused on input/output, and supports few types. It has poor support for large-scale structuring, so large COBOL programs, although easy to read at a statement level, may be hard to understand at a high level.

Examples

Here's Hello World in COBOL.

      IDENTIFICATION DIVISION.
      PROGRAM-ID.    HELLOWORLD.
      ENVIRONMENT DIVISION.
      DATA DIVISION.
      PROCEDURE DIVISION.
          DISPLAY 'HELLO WORLD! ' .
          GOBACK.

Another variant, specifically for the RM/1 COBOL compiler:

      IDENTIFICATION DIVISION.
      PROGRAM-ID.     HELLOWORLD.

      ENVIRONMENT DIVISION.
      CONFIGURATION SECTION.
      SOURCE-COMPUTER. RM-COBOL.
      OBJECT-COMPUTER. RM-COBOL.

      DATA DIVISION.
      FILE SECTION.

      PROCEDURE DIVISION.
      
      MAIN-LOGIC SECTION.
      BEGIN.
          DISPLAY " " LINE 1 POSITION 1 ERASE EOS.
          DISPLAY "Hello world!" LINE 15 POSITION 10.
          STOP RUN.
      MAIN-LOGIC-EXIT.
      EXIT.

External links