Chapter 4. Cobol

Together with Fortran and Lisp, Cobol (COmmon Business Oriented Language) is one of the oldest programming languages. It was defined in 1960 at the DoD sponsored Conference on Data System Languages (CODASYL). The first ANSI standard came out in 1968 with further updates in 1974 (Cobol74) and 1985 (Cobol85). A new version (with significant new features including Object-Cobol) is on its way.

Without doubt, Cobol remains the most important language for business applications. There are a few hundred billion lines of Cobol code in production and about five billion lines are still added every year. Many reasons to have a closer look.

4.1. Software and Installation

Since Cobol is all about "real business", free Cobol compilers are rare. Among those, Tiny Cobol seems to be the most mature. For this chapter, we use version 0.60 on a Linux system. To installation from the source uses the standard configure, make, make install sequence.

Tiny Cobol is a preprocessor which translates Cobol code to C. The installation comes with a large number of examples (in the test.code directory) which can be used as templates for the code samples below. Compiling and running the "Hello world" program program then looks like this.

ahohmann@kermit:~/programming/cobol/book/hello$ make
htcobol -c  -P -D -I/home/ahohmann/opt/share/htcobol/copybooks -I. example.cob
gcc -g -o example example.o  -L/usr/local/lib -L/usr/lib -L/home/ahohmann/opt/lib -lhtcobol -lm -lncurses
ahohmann@kermit:~/programming/cobol/book/hello$ example
Hello World!

Bibliography

I'm not a Cobol expert, but considering the number of copies I found in American bookstores, Stern & Stern [STERN00]> seems to be the book used to teach Cobol. It is indeed a very readable introduction to Cobol.

Nancy B. Stern and Robert A. Stern, 0-471-31881-7, John Wiley and Sons, 2000, Structured Cobol Programming: For the Year 2000 and Beyond.