Cobol .edu



Janice Wu

CIS 24 – COBOL

Professor Kopec

September 25, 2006

INTRODUCTION

The language COBOL (Common Business Oriented Language) came into development at a May 1959 meeting at the Pentagon by CODASYL (Conference of Data Systems Languages), who wanted a common language for programming in business applications. Three groups were assigned a task to help bring the language into existence: Short Range, Intermediate Range, and Long Range committees. By 1960, the Short Range committee had completed the specifications for the language, while the other two committees were never active. Since the specifications were approved by the Executive Committee in 1960 and published by a government printing office as Cobol 60, the ANSI (American National Standards Institute) took over developing new COBOL standards (including: 1968, 1974, 1985, and 2002).

THE LANGUAGE

One of the design goals of the language was to make it possible for non-programmers to understand the code. Out of all the programming languages, it is easiest to read because, “COBOL contains such English-like structural elements as verbs, clauses, sentences, sections and divisions.[1]” Words in COBOL can create meaningful ideas; that is,

In human discourse, a word is meaningful because, at some point in time, this word has been defined and associated with a particular concept or object. In COBOL, a word is meaningful either because the programmer has given it meaning by relating it to a specific quantity, or because it is an inherent, built-in part of the language.[2]

It is not to say that it is free-form English, however; there are rules and limitations just like any written language. There is an extensive reserved word list of over 300 entries in the language.

COBOL is designed for developing business, typically file-oriented applications, and is not designed for systems programming. Applications typically tend to be over 1,000,000 lines of code. Because of the huge investment companies put into building programs of over a million lines of code, the applications cannot be abandoned, and tend to be long-lived. In 1997, a report from the Gartner group found that there are 3000 billion lines of computer code in the world. Of that, an estimated 80% were in COBOL, and the rest in all other computer languages combined. In 1999, they estimated over 50% of mission-critical applications were written in COBOL.[3]

ADVANTAGES

Some of the advantages of COBOL are: simplicity, portability, and maintainability. COBOL does not support pointers, user-defined functions, or user-defined types. COBOL programs can be run on different machines with very little modification because it is a non-proprietary language; that is, its standards do not belong to any particular vendor. It is a self-documenting language, and its readability makes it a language that is easy to maintain:

In COBOL programs all external references, such as to devices, files, command sequences, collating sequences, the currency symbol and the decimal point symbol, are defined in the Environment Division. When a COBOL program is moved to a new machine, or has new peripheral devices attached, or is required to work in a different country; COBOL programmers know that the parts of the program that will have to be altered to accommodate these changes will be isolated in the Environment Division.[4]

Over time when a program is revised, accurate documentation becomes more important for future maintenance. In COBOL, programmers have an easier time because of its self-documenting nature. As an example, COBOL applications were less expensive to fix for the Y2K problem compared to programs in other languages.

It is easier to train individuals in COBOL than in other languages; complicated techniques are only taught to career programmers. In addition, experts who were formerly excluded could now contribute their knowledge into the programming effort. This allows the programmer to focus on defining the problem and analyzing it; as a result, it leads to faster programming as well as reduced programming costs.[5]

DISADVANTAGES

Disadvantages include: wordiness, strict format, and inability to handle scientific applications. While one of the advantages to COBOL is its English-like code, the downside to it is that there are so many lines of code for simple computations that it can be hard to debug. For example, here is code to compute x = (-b ± (√(b2-4ac)))/2a:[6]

MULTIPLY B BY B GIVING B-SQUARED.

MULTIPLY 4 BY A GIVING FOUR-A.

MULTIPLY FOUR-A BY C GIVING FOUR-A-C.

SUBTRACT FOUR-A-C FROM B-SQUARED GIVING RESULT-1.

COMPUTE RESULT-2 = RESULT-1 ** .5.

SUBTRACT B FROM RESULT-2 GIVING NUMERATOR.

MULTIPLY 2 BY A GIVING DENOMINATOR.

DIVIDE NUMERATOR BY DENOMINATOR GIVING X.

It can also be coded in this format, though depending on the compiler or machine, the results may be vary, thus making it unreliable:

COMPUTE X = (-B + (B ** 2 - (4 * A * C)) **.5) / (2 * A)

As shown by this example, simple mathematic calculations take many lines to compute. When doing scientific work, the amount of coding would require much more effort, and in the end is more trouble than it is worth.

FORMAT AND NAMING

When COBOL came into existence, coding forms and card punchers were used to create programs. Even though it is outdated today, COBOL still adheres to some of the rules from the card-punching system. That is, “the first six character positions are reserved for sequence numbers. The seventh character position is reserved for the continuation character, or for an asterisk that denotes a comment line. The actual program text starts in column 8.[7]” As for name construction, all user-defined names must adhere to the following rules:

1. They must contain at least one character, but not more than 30 characters.

2. They must contain at least one alphabetic character.

3. They must not begin or end with a hyphen.

4. They must be constructed from the characters A to Z, the numbers 0 to 9, and the hyphen.

5. They must not contain spaces.

6. Names are not case-sensitive: TotalPay is the same as totalpay, Totalpay or TOTALPAY.

STRUCTURE

COBOL is a highly structured language, with a hierarchal structure consisting of Divisions, Sections, Paragraphs, and Statements. A Division is a block of code containing one or more Sections, and ends at the beginning of the next Division or the end of the program. A Section is a block of code containing one or more Paragraphs, and ends at the beginning of the next Section or the end of the Division. A Section name is followed by the word SECTION and a period. A Paragraph is a block of code made up of one or more sentences; a Paragraph name ends with a period. Finally, a Sentence consists of one or more Statements, and is terminated by a period, and a Statement is made of a COBOL verb and an operand. An example of a Statement:

SUBTRACT Tax FROM GrossPay GIVING NetPay.

Here is an image of the COBOL structure taken from Michael Coughlan’s website:

[pic]

At the top of the COBOL hierarchy are the four divisions, Identification Division, Environment Division, Data Division, and Procedure Division.[8]

Every program starts with an Identification Division, which provides information about the program. Unlike the other three divisions, it does not have Sections. Rather, it contains seven Paragraphs each with its own name from the reserved word list. They are: PROGRAM-ID (official name of the program and the only paragraph that is required), AUTHOR, INSTALLATION, DATE-WRITTEN, DATE-COMPILED, SECURITY, and REMARKS.

The Environment Division describes the Environment in which the program was designed to run. It makes it easy for the programmer to change the program when it has to run on a different computer. The DATA DIVISION provides descriptions of the data-items processed by the program. The PROCEDURE DIVISION contains the code used to manipulate the data described in the DATA DIVISION; the programmer describes his algorithm here.

TODAY

COBOL 2002 is the Object-Oriented version of the language. According to Michael Kasten’s observations of IBM’s Object Oriented COBOL, it’s simplicity compared to C++ is both good and bad. Unlike C++, the programmer is less likely to make mistakes because there are fewer options to consider. However, Object Oriented COBOL cannot effectively define complex classes; the encapsulation is so rigid that it is “self-defeating. The only way to provide any access to private data is to define public methods, which render the data effectively public.[9]”

Works Cited

“COBOL.” Wikipedia, the free encyclopedia. 19 Sept. 2006. 25 Sept. 2006

.

Coughlan, Michael. “Introduction to COBOL.” Cobol Tutorial. Apr. 2002. University of

Limerick. 25 Sept. 2006 .

Jackson, George. COBOL. 1st ed. Blue Ridge Summit, PA: TAB Books Inc., 1982.

Kasten, Michael C. “OO COBOL: Overall Impressions.” Object Oriented COBOL. 1 Feb. 1998.

25 Sept. 2006 .

Li, Jiehong, and Rona Abraham, comps. COBOL. University of Maryland, Baltimore County. 25

Sept. 2006 .

-----------------------

[1] Michael Coughlan, “Introduction to COBOL,” Cobol Tutorial, 25 September 2006, .

[2] George Jackson, COBOL (Blue Ridge Summit, PA: TAB Books Inc., 1982) 1.

[3] Jiehong Li and Rona Abraham, “COBOL”, 25 September 2006, .

[4] Michael Coughlan, “Introduction to COBOL,” Cobol Tutorial, 25 September 2006, .

[5] George Jackson, COBOL (Blue Ridge Summit, PA: TAB Books Inc., 1982) 5-7.

[6] “COBOL”, Wikipedia, the free encyclopedia, 25 September 2006, .

[7] Michael Coughlan, “Introduction to COBOL,” Cobol Tutorial, 25 September 2006, .

[8] Michael Coughlan, “Introduction to COBOL,” Cobol Tutorial, 25 September 2006, .

[9] Michael C. Kasten, “OO COBOL: Overall Impressions”, Object Oriented COBOL, 25 September 2006,

< >.

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download