COBOL
COmmon Business-Oriented Language
COBOL is a compiled English-like computer programming language designed for business use. It is an imperative, procedural, and, since 2002, object-oriented language. COBOL is primarily used in business, finance, and administrative systems for companies and governments. COBOL is still widely used in applications deployed on mainframe computers, such as large-scale batch and transaction processing jobs. Many large financial institutions were developing new systems in the language as late as 2006, but most programming in COBOL today is purely to maintain existing applications. Programs are being moved to new platforms, rewritten in modern languages, or replaced with other software.
COBOL statements have prose syntax such as MOVE x TO y, which was designed to be self-documenting and highly readable. However, it is verbose and uses over 300 reserved words compared to the succinct and mathematically inspired syntax of other languages.
The COBOL code is split into four divisions (identification, environment, data, and procedure), containing a rigid hierarchy of sections, paragraphs, and sentences. Lacking a large standard library, the standard specifies 43 statements, 87 functions, and just one class.
The height of COBOL's popularity coincided with the era of keypunch machines and punched cards. The program itself was written onto punched cards, then read in and compiled, and the data fed into the program was sometimes on cards as well.
COBOL can be written in two formats: fixed (the default) or free. In fixed-format, code must be aligned to fit in certain areas (a hold-over from using punched cards). Until COBOL 2002, these were:
I used COBOL professionally in several of my jobs. First was R/M COBOL on CP/M. The Service Bureau I worked for sold an accounting package that we did minor customizations for the customers. This is also where I developed the little file clean up utility in assembler.
The next time was at a University IT Department working on an interactive CICS COBOL utilities that allowed employees to request reprints of their W-2 statements. It handled collecting and validating the employee information and managing the print queues.
The last time I had to work with COBOL was the same R/M COBOL Accounting package on SCO Unix on an NCR 68000 Tower.
Sample Code
It took me even longer to remember how to write a COBOL application. The Microsoft COBOL-80 compiler appears to be ANSI COBOL-74 which does not support free mormatted code.
Here is yet another looped version of the Hello World program.
H>user 1
H>type hello.cob
000100 IDENTIFICATION DIVISION.
000200 PROGRAM-ID. HELLO.
000300 ENVIRONMENT DIVISION.
000400 DATA DIVISION.
000410 WORKING-STORAGE SECTION
000420 01 LINECOUNT PIC 99.
000430 01 DISPCOUNT PIC Z9.
000500 PROCEDURE DIVISION.
000600 00-MAIN.
000700 PERFORM SHOW-MESSAGE VARYING LINECOUNT FROM 1 BY 1
000710 UNTIL LINECOUNT > 10.
000800 STOP RUN.
000900 SHOW-MESSAGE.
000910 MOVE LINECOUNT TO DISPCOUNT.
001000 DISPLAY "Hello World From COBOL, line ", DISPCOUNT.
H>cobol hello,hello=hello/r
Microsoft MS-COBOL
Version 4.65 Copyright 1980,1981,1982 (C) Microsoft
No Errors or Warnings
H>l80 hello/n,hello/e
Link-80 3.44 09-Dec-81 Copyright (c) 1981 Microsoft
Data 4C00 4F56 < 854>
41731 Bytes Free
[4C44 4F56 79]
H>hello
Hello World From COBOL, Line 1
Hello World From COBOL, Line 2
Hello World From COBOL, Line 3
Hello World From COBOL, Line 4
Hello World From COBOL, Line 5
Hello World From COBOL, Line 6
Hello World From COBOL, Line 7
Hello World From COBOL, Line 8
Hello World From COBOL, Line 9
Hello World From COBOL, Line 10
H>
References
This article uses material from the Wikipedia article COBOL which is released under the Creative Commons Attribution-Share-Alike License 4.0.
Comments