How big is a typical 'program'?
I've written/worked on programs varying from 300 lines (a simple 'grab a
record or two and paint a screen') called module in a mainframe online
database application to 8000 lines or so for a monolithic data analysis
program. It normally would be between 1000 and 3000 lines.
If it's the size of a class, then
COBOL's implicit 'global' is really an implicit 'private static';
It doesn't really map that way: A program is either:
- a monolithic single file which would be broken into a set of classes
if it was written in (Java) or a smaller number of C source modules
if it was written in C.
- or it corresponds to a single subroutine or function in Fortran/Pascal/
C terms.
In the COBOL shops I've worked in its been unusual to break a program
into separate compilation units, probably because the language definition
mandates that the compiler includes a copy library. This allows you to
define 'copy units' which contain arbitrarily large chunks of source and
pull them into a program, altering the names of data items and procedure
division labels as needed to avoid conflicts. A copy unit can define
data, such as a record or print line definition, or procedure division
items which can be anything from a single sentence paragraph to an entire
procedure division section.
Terminology clarification: A statement is called a 'sentence', a
'paragraph has a name (label) and contains one or more sentences and a
'section', which also has a name, contains one or more sections. Sections
and paragraphs can be PERFORMed (equivalent to a procedure call) or
referenced in a GO TO statement and yes, you can legally PERFORM and GO
TO the same paragraph from different parts of the same program.
Since (I think) COBOL 85 its been possible to put a set of related
programs into a single source file, somewhat like using nested classes in
Java, but no shop I've worked in has used this ability.
A bit of googling reveals that there are various extensions to COBOL for
things like local variables, thread-locals, making programs recursive or
reentrant, etc. And of course there's an Object COBOL.
The last version I used seriously was MicroFocus COBOL 90, in around 1995
and a bit of Tandem NonStop COBOL a year or two later. I don't recall
seeing any of those features in either COBOL implementation, but then
again neither needed to use them. The Tandem COBOL formed callable
modules embedded in the Pathway application manager (i.e., equivalent to
using JBOSS or Tomcat). The MicroFocus COBOL code ran in another
application framework, but this one was written in C and optimised for
switching financial messages between an ATM network and the accounting
system on a mainframe. The bank-specific logic was defined by writing
callable COBOL modules.
So, whilst it may be true that for most of its life, and for the time
when it was most important, COBOL's programmers talked as much about
global variables as fish do about water, but i doubt that's been true
since, i would guess, 1990.
I don't know, but then I haven't seen or been involved with any newly
written COBOL since about 1983. All the COBOL I've seen since would
probably have dated from the mid/late 1980s since that was when the kit
it ran on (Tandem Guardian NonStop, Stratus fault tolerant and NCR UNIX
boxes) became widely used, and had been modified to suit changing
requirements since then rather than being rewritten.