I received so much positive feedback on
COBOL vs. Perl that I figured Monks who have never worked on legacy systems may appreciate a discussion of why languages like Perl are superior to dinosaurs like COBOL.
Why is it a problem that legacy COBOL code still exists? Because in the 60s, CPU cycles and storage were tremendously more expensive than the programmer, relative to today. Thus, development was geared towards putting the burden of the work on the programmer. The computer was asked to do as little as possible, thereby ensuring that the bulk of the tedious work was handled by the relatively inexpensive programmer.
For example, COBOL (at least on IBM mainframes) can't create a new file. Instead, you have a FILE SECTION that would describe the new file. It might look like this:
FD O-NEWFILE
RECORDING MODE IS F
BLOCK CONTAINS 0 RECORDS
RECORD CONTAINS 80 CHARACTERS
LABEL RECORDS ARE STANDARD
DATA RECORD IS O-NEWFILE-REC.
01 O-NEWFILE-REC PIC X(80).
That doesn't create the file. Job Control Language, or JCL, opens the file (think of JCL as a primitive scripting language). In another portion of the program,
O-NEWFILE is linked to the JCL filename (well, sort of) and the JCL then attempts to create the file. The JCL that actually opens the file might be something like:
//NEWFILE DD DSN=B7707O.DDA50010.APDATA,
// DISP=(NEW,CATLG,DELETE),
// UNIT=DASD,
// SPACE=(CYL,(150,150),RLSE),
// DCB=(RECFM=FB,LRECL=80,BLKSIZE=6400)
Note the lack of spaces. JCL is so intolerant that errant white space will cause the job to fail. Try to debug that.
After you've compiled and linked the program, you execute the JCL which will execute the COBOL program and then try to open the file. Without going through a COBOL or JCL tutorial, suffice it to say that with modern languages, such as Perl, many of the things that you had to tell a mainframe to do are handled behind the scenes. If you find the aforementioned example mind-boggling, just consider that I have greatly simplified them.
Compare that to Perl:
open (MYFILE, "> $file") || die "Couldn't open $file: $!\n";
In the modern world, where we need to get things done, Perl reigns. Perl's not always the best language for the job (try writing the setiathome screensaver in Perl), but when you need to get things done and done fast, Perl can't be beat. The dinosaurs are going to be around for a long time, but they
have to die.