Search This Blog

Tuesday, 22 October 2013

COBOL

Common Business-Oriented Language was developed under the impetus of a 1959 Department of Defense initiative to create a common language for developing business applica-tions that centered on the processing of data from files. (The military, after all, was a “business” whose inventory control and accounting needs dwarfed those of all but the largest corporations.) At the time, the principal business-oriented language for mainframe computers was FLOW-MATIC, a language developed by Grace Hopper’s team at Remington-Rand UNIVAC and limited to that company’s computers (see Hopper, Grace Murray). The first COBOL compil-ers became available in 1960, and the American National Standards Institute (ANSI) issued a standard specification for the language in 1968. Expanded standards were issued in 1974 and 1985 (COBOL-74 and COBOL-85) with a new standard issued in 2002.

The committee that outlined the language that would become COBOL focused on making program statements resemble declarative English sentences rather than the mathematical expressions used by FORTRAN for scientific programming. COBOL’s designers hoped that accountants, managers, and other business professionals could quickly master the language, reducing if not removing the need for professional programmers. (This theme of “programming without programmers” would recur with regard to other languages such as RPG, BASIC, and various database sys-tems, always with limited success.)

Program Structure

A COBOL program as a whole resembles a business form in that it is divided into specific sections called divisions, each with required and optional items.

The Identification division simply identifies the pro-grammer and gives some information about the program:

IDENTIFICATION DIVISION.

PROGRAM-ID WEEKLY REPORT. AUTHOR JAMES BRADLEY. DATE-WRITTEN DECEMBER 10, 2000. DATE-COMPILED DECEMBER 12, 2000.

REMARKS THIS IS AN EXAMPLE PROGRAM.

The Environment division contains specifications about the environment (hardware) for which the program will be compiled. In some cases (for example, microcomputer versions of COBOL) it may not be needed. In other cases, it might simply have a Configuration section that specifies the machine to be used:

ENVIRONMENT DIVISION.

CONFIGURATION SECTION.

SOURCE-COMPUTER IBM-370.

OBJECT-COMPUTER IBM-370.

(The reason for the separate source and object computers is that programs were sometimes compiled on one computer for use on another, often smaller, one.)

In some cases, the Environment Division must also include an Input-Output section that specifies devices and files that will be used by the program. For example:

INPUT-OUTPUT SECTION. FILE-CONTROL.

SELECT STUDENT-FILE ASSIGN TO READER SELECT STUDENT-LISTING ASSIGN TO LOCAL-PRINTER

The Data division gives a description of the data records and other items that will be processed by the program. It is roughly comparable to the declarations of variables in languages such as Pascal, C, or BASIC. Since COBOL focuses on the processing of file records and the format-ting of reports, it tends to have fewer data types than many other languages, but it makes it easier to describe the kinds of data structures commonly used in business applications. For example, it is easy to describe records that have fields and subfields by using level numbers to indicate the rela-tionship:

DATA DIVISION.

FILE SECTION.

FD INFILE

LABEL RECORDS ARE OMITTED.

01 STUDENT-DATA.

02 STUDENT-ID PIC 999999.

02 STUDENT-NAME.

03 LAST-NAME PIC X(15).

03 INITIAL PIC X.

03 FIRST-NAME PIC X(10).

02 GPA PIC 9.99

The “PIC” or picture clause specifies the type of data (using 9’s and a decimal point for numbers and X for text) and the length. In addition to specifying the input records, the Data division often includes items that specify the for-mat of the lines of output that are to be printed.

The Procedure division provides the statements that perform the actual data manipulation. Procedures can be organized as subroutines (roughly equivalent to procedures or functions on other languages). Some sample procedure statements are:

READ STUDENT-DATA INTO STUDENT-WORK-RECORD AT END MOVE ‘E’ TO PROC-FLAG-ST

GO TO EXIT-PRINT

ADD 1 TO TOTAL-STUDENT-RECORDS

Mathematical expressions can be computed using a Compute statement:

COMPUTE GPA = TOTAL-GRADES / CLASSES

Branching (if) statements are available, and looping is provided by the Perform statement, for example:

PERFORM 100-PRINT-LINE

UNTIL LINES-FL IS EQUAL TO ‘E’

(As with older versions of BASIC, subroutines are numbered.)

Impact and Prospects

From the 1960s through the 1980s, COBOL became the workhorse language for business applications for main-frame and mid-size computers, and it is still widely used today. (The concerns about possible problems at the end of the century often involved older programs written in COBOL, see y2k problem.) The main line of programming language evolution bypassed COBOL and went through Algol (a contemporary of COBOL) and on into Pascal, C, and other block-structured languages (see also structured programming).

Some modern versions of COBOL have incorporated later developments in structured programming (such as modularization) and even object-oriented design. COBOL has also shown considerable versatility in accommodating modern development frameworks, including Microsoft.NET as well as processing now-ubiquitous XML data. Neverthe-less, usage of COBOL continues to decline slowly as devel-opers increasingly turn to languages such as C++, scripting languages, or database development systems.

No comments:

Post a Comment