COBOL
From Wikipedia, the free encyclopedia
| Paradigm | procedural, object-oriented |
|---|---|
| Appeared in | 1959 |
| Designed by | Grace Hopper, William Selden, Gertrude Tierney, Howard Bromberg, Howard Discount, Vernon Reeves, Jean E. Sammet |
| Typing discipline | strong, static |
| Major implementations | OpenCobol.org, MicroFocus.com |
| Dialects | HP3000 COBOL/II, COBOL/2, IBM OS/VS COBOL, IBM COBOL/II, IBM COBOL SAA, IBM Enterprise COBOL, IBM COBOL/400, IBM ILE COBOL, Unix COBOL X/Open, Micro Focus COBOL, Microsoft COBOL, Ryan McFarland RM/COBOL, Ryan McFarland RM/COBOL-85, DOSVS COBOL, UNIVAC COBOL, Realia COBOL, Fujitsu COBOL, ACUCOBOL-GT, DEC VAX COBOL, Wang VS COBOL, Visual COBOL |
| Influenced by | FLOW-MATIC, COMTRAN, FACT |
| Influenced | PL/I, CobolScript, ABAP |
COBOL (pronounced /ˈkoʊbɒl/) is one of the oldest programming languages still in active use. Its name is an acronym for COmmon Business-Oriented Language, defining its primary domain in business, finance, and administrative systems for companies and governments.
The COBOL 2002 standard includes support for object-oriented programming and other modern language features.[1]
Contents |
[edit] History and specification
A specification of COBOL was initially created during the second half of 1959. The scene was set on April 8 at a meeting of computer manufacturers, users and university people at the University of Pennsylvania Computing Center and subsequently the United States Department of Defense agreed to sponsor and oversee the next activities. A meeting was held at the Pentagon on May 28 and 29 (exactly one year after the Zürich ALGOL 58 meeting), chaired by Charles A. Phillips. There it was decided to set up three committees, short, intermediate and long range (the last one was actually never formed). It was the Short Range Committee, chaired by Joseph Wegstein of the US National Bureau of Standards, that during the next months would create a description of the first version of COBOL.[2] The committee was formed to recommend a short range approach to a common business language. The committee was made up of members representing six computer manufacturers and three government agencies. The six computer manufacturers were Burroughs Corporation, IBM, Minneapolis-Honeywell (Honeywell Labs), RCA, Sperry Rand, and Sylvania Electric Products. The three government agencies were the US Air Force, the David Taylor Model Basin, and the National Bureau of Standards (now National Institute of Standards and Technology). The intermediate-range committee was formed but never became operational. In the end a sub-committee of the Short Range Committee developed the specifications of the COBOL language. This sub-committee was made up of six individuals:
- William Selden and Gertrude Tierney of IBM
- Howard Bromberg and Howard Discount of RCA
- Vernon Reeves and Jean E. Sammet of Sylvania Electric Products[3]
This subcommittee completed the specifications for COBOL in December 1959. The specifications were to a great extent inspired by the FLOW-MATIC language invented by Grace Hopper, commonly referred to as "the mother of the COBOL language", the IBM COMTRAN language invented by Bob Bemer, and the FACT language from Honeywell.
The name COBOL was decided upon at a meeting of the committee held on 18 Sept. 1959.
The first compilers for COBOL were subsequently implemented during the year 1960 and on 6 and 7 Dec. essentially the same COBOL program was run on two different makes of computers, an RCA computer and a Remington-Rand Univac computer, demonstrating that compatibility could be achieved.
Since 1959 COBOL has undergone several modifications and improvements. In an attempt to overcome the problem of incompatibility between different versions of COBOL, the American National Standards Institute (ANSI) developed a standard form of the language in 1968. This version was known as American National Standard (ANS) COBOL. In 1974, ANSI published a revised version of (ANS) COBOL, containing a number of features that were not in the 1968 version. In 1985, ANSI published still another revised version that had new features not in the 1974 standard. The language continues to evolve today. Object-oriented COBOL is a subset of COBOL 97, which is the fourth edition in the continuing evolution of ANSI/ISO standard COBOL. COBOL 97 includes conventional improvements as well as object-oriented features. Like the C++ programming language, object-oriented COBOL compilers are available even as the language moves toward standardization.
[edit] History of COBOL standards
The specifications approved by the full Short Range Committee were approved by the Executive Committee on January 3, 1960, and sent to the government printing office, which edited and printed these specifications as Cobol 60.
The American National Standards Institute (ANSI) has since produced several revisions of the COBOL standard, including:
From 2002, the ISO standard is also available to the public coded as ISO/IEC 1989.
[edit] Legacy
COBOL programs are in use globally in governmental and military agencies, in commercial enterprises, and on operating systems such as IBM's z/OS, Microsoft's Windows, and the POSIX families (Unix/Linux etc.). In 1997, the Gartner Group reported that 80% of the world's business ran on COBOL with over 200 billion lines of code in existence and with an estimated 5 billion lines of new code annually.[4]
Near the end of the twentieth century the year 2000 problem was the focus of significant COBOL programming effort, sometimes by the same programmers who had designed the systems decades before. The particular level of effort required for COBOL code has been attributed both to the large amount of business-oriented COBOL, as COBOL is by design a business language and business applications use dates heavily, and to constructs of the COBOL language such as the PICTURE clause, which can be used to define fixed-length numeric fields, including two-digit fields for years.
[edit] COBOL 2002 and object-oriented COBOL
The COBOL2002 standard supports Unicode, XML generation and parsing, calling conventions to and from non-COBOL languages such as C, and support for execution within framework environments such as Microsoft's .NET and Java (including COBOL instantiated as Enterprise JavaBeans). Fujitsu and Micro Focus currently supports object oriented COBOL compilers targeting the .NET framework.[5]
[edit] Features
COBOL as defined in the original specification included a PICTURE clause for detailed field specification. It did not support local variables, recursion, dynamic memory allocation, or structured programming constructs. Support for some or all of these features has been added in later editions of the COBOL standard.
COBOL has many reserved words (over 400), called keywords. The original COBOL specification supported self-modifying code via the infamous "ALTER X TO PROCEED TO Y" statement. This capability has since been removed.
[edit] Syntactic features
COBOL provides an update-in-place syntax, for example
ADD YEARS TO AGE.
The equivalent construct in many procedural languages would be
age = age + years
This syntax is similar to the compound assignment operator later adopted by C:
age += years
The abbreviated conditional expression
IF SALARY > 9000 OR SUPERVISOR-SALARY OR = PREV-SALARY
is equivalent to
IF SALARY > 9000
OR SALARY > SUPERVISOR-SALARY
OR SALARY = PREV-SALARY
COBOL provides "named conditions" (so-called 88-levels). These are declared as sub-items of another item (the conditional variable). The named condition can be used in an IF statement, and tests whether the conditional variable is equal to any of the values given in the named condition's VALUE clause. The SET statement can be used to make a named condition TRUE (by assigning the first of its values to the conditional variable).
COBOL allows identifiers to be up to 30 characters long. When COBOL was introduced, much shorter lengths (e.g., 6 characters for FORTRAN) were prevalent.
The concept of copybooks was introduced by COBOL; these are chunks of text which can be inserted into a program's code. This is done with the COPY statement, which also allows parts of the copybook's text to be replaced with other text (using the REPLACING ... BY ... clause).
[edit] Data types
Standard COBOL provides the following data types:
| Data type | Sample declaration | Notes |
|---|---|---|
| Character | PIC X(20) |
Alphanumeric and alphabetic-only Single-byte character set (SBCS) |
| Edited character | PIC X99BAXX |
Formatted and inserted characters |
| Numeric fixed-point binary | PIC S999V99or BINARY |
Binary 16, 32, or 64 bits (2, 4, or 8 bytes) Signed or unsigned. Conforming compilers limit the maximum value of variables based on the picture clause and not the number of bits reserved for storage. |
| Numeric fixed-point packed decimal | PIC S999V99 |
1 to 18 decimal digits (1 to 10 bytes) Signed or unsigned |
| Numeric fixed-point zoned decimal | PIC S999V99 |
1 to 18 decimal digits (1 to 18 bytes) Signed or unsigned |
| Numeric floating-point | PIC S9V999ES99 |
Binary floating-point |
| Edited numeric | PIC +Z,ZZ9.99 |
Formatted characters and digits |
| Group (record) | 01 CUST-NAME. |
Aggregated elements |
| Table (array) | OCCURS 12 TIMES |
Fixed-size array, row-major order Up to 7 dimensions |
| Variable-length table | OCCURS 0 to 12 TIMES |
Variable-sized array, row-major order Up to 7 dimensions |
| Renames (variant or union data) | 66 RAW-RECORD |
Character data overlaying other variables |
| Condition name | 88 IS-RETIRED-AGE |
Boolean value dependent upon another variable |
| Array index | USAGE INDEX |
Array subscript |
Most vendors provide additional types, such as:
| Data type | Sample declaration | Notes |
|---|---|---|
| Numeric fixed-point binary in native byte order |
PIC S999V99 |
Binary 16, 32, or 64 bits (2, 4, or 8 bytes) Signed or unsigned |
| Numeric fixed-point binary in big-endian byte order |
PIC S999V99 |
Binary 16, 32, or 64 bits (2, 4, or 8 bytes) Signed or unsigned |
| Wide character | PIC G(20) |
Alphanumeric Double-byte character set (DBCS) |
| Edited wide character | PIC G99BGGG |
Formatted and inserted wide characters |
| Edited floating-point | PIC +9.9(6)E+99 |
Formatted characters and decimal digits |
| Data pointer | USAGE POINTER |
Data memory address |
| Code pointer | USAGE PROCEDURE-POINTER |
Code memory address |
[edit] Hello, world
An example of the "Hello, world" program in COBOL:
IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO-WORLD.
PROCEDURE DIVISION.
MAIN.
DISPLAY 'Hello, world.'.
STOP RUN.
[edit] Criticism
Critics have argued that COBOL's syntax serves mainly to increase the size of programs, at the expense of developing the thinking process needed for software development. In his letter to an editor in 1975 titled "How do we tell truths that might hurt?", computer scientist and Turing Award recipient Edsger Dijkstra remarked that "The use of COBOL cripples the mind; its teaching should, therefore, be regarded as a criminal offense."[6]
COBOL 85 was not compatible with earlier versions, resulting in the "cesarean birth of COBOL 85". Joseph T. Brophy, CIO, Travelers Insurance, spearheaded an effort to inform users of COBOL of the heavy reprogramming costs of implementing the new standard. As a result the ANSI COBOL Committee received more than 3,200 letters from the public, mostly negative, requiring the committee to make changes.[7]
Older versions of COBOL lack local variables and so cannot truly support structured programming.
Others[who?] criticize the ad hoc incorporation of features on a language that was meant to be a short term solution to interoperability in 1959. Coupled with the perceived archaic syntax, they argue that it tries to fill a niche for which better tools have already been designed and developed.
[edit] Defense
The COBOL specification has also been revised over the years to incorporate developments in computing theory and practice .
As with any language, COBOL code can be made more verbose than necessary. For example, one of the roots of the quadratic equation ax2 + bx + c = 0, which are:
can be coded in COBOL using the "compute" verb as:
COMPUTE X = (-B + SQRT(B ** 2 - (4 * A * C))) / (2 * A)
The same formula could also be written less concisely as:
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.
Which form to use is a matter of style. In some cases the less concise form may be easier to read. For example:
ADD YEARS TO AGE.
MULTIPLY PRICE BY QUANTITY GIVING COST.
SUBTRACT DISCOUNT FROM COST GIVING FINAL-COST.
Older versions of COBOL supported local variables via embedded programs (scope-delimited by the keywords PROGRAM-ID and END-PROGRAM). Variables declared within the embedded program are invisible outside its scope. Also, local variables could be accomplished via separately compiled sub-programs. Newer COBOL compilers support the LOCAL-STORAGE section for local variables.
[edit] Aphorisms and humor about COBOL
It has been said of languages like C, C++, and Java that the only way to modify legacy code is to rewrite it - write once and write once again; or write once and throw away. On the other hand, it has been said of COBOL that there actually is one original COBOL program, and it has only been copied and modified millions of times.
The name "ADD 1 TO COBOL GIVING COBOL" has been suggested for a hypothetical object-oriented dialect of COBOL, as a play on the name C++. While this is meant to suggest that COBOL is inherently verbose, the form given is more verbose than COBOL actually requires; the succinct form would be "ADD 1 TO COBOL".
Another suggested name is "POSTINCREMENT COBOL BY 1", which not only reflects the verbose nature of COBOL statements, but also highlights the tendency for COBOL features to require their own dedicated reserved keywords (standard COBOL employs over 400 reserved words), this example being the case for a hypothetical new POSTINCREMENT operator.
[edit] See also
- Alphabetical list of programming languages
- Burroughs B2000
- CODASYL
- Comparison of programming languages
[edit] Other third-generation programming languages
|
[edit] References
- ^ Oliveira, Rui (2006). The Power of Cobol. City: BookSurge Publishing. ISBN 0620346523.
- ^ Garfunkel, Jerome (1987). The Cobol 85 Example Book. New York: Wiley. ISBN 0471804614.
- ^ Wexelblat, Richard (1981). History of Programming Languages. Boston: Academic Press. ISBN 0127450408.
- ^ "Future of COBOL" (PDF) 5. LegacyJ Corporation (2003). Retrieved on 2006-11-08.
- ^ NetCOBOL for .NET supports COBOL migration and software development in the .NET environment
- ^ Dijkstra (2006). "E. W. Dijkstra Archive: How do we tell truths that might hurt? (EWD498)". University of Texas at Austin. Retrieved on August 29, 2007.
- ^ (The COBOL 85 Example Book)
[edit] Sources
- Ebbinkhuijsen, Wim B.C., COBOL Alphen aan den Rijn/Diegem: Samson Bedrijfsinformatie bv, 1990. ISBN 90-14-04560-3. (Dutch)
[edit] External links
| Wikibooks has more on the topic of |
- COBOL-Standard Committee
- COBOLware
- COBOL Tutorial
- COBOL Virtual Machine
- IBM COBOL compilers
- IBM COBOL documentation (iSeries Information Center)
- IBM ILE COBOL reference manualPDF (3.9 MB)
- Mainframe COBOL Community
- OpenCOBOL: Open-source COBOL compiler
- Add1tocobol: COBOL advocacy project
- Micro Focus COBOL
- Wildcat Cobol - Open-source .NET compiler
- Description from another wiki
- Solution for COBOL to serialize and de-serialize XML
- Cobol User's Group has an extensive collection of links
- Article "Cobol: Not Dead Yet" by Robert Mitchell
- Article "Cobol Coders: Going, Going, Gone?" by Gary Anthes


