With that said, the real COBOL code is probably much more horrifying, when you consider, just how much uglier real-world code is compared to small tutorials and review articles. I would really like to read a series of “COBOL War-Time Stories”.
With that said, the real COBOL code is probably much more horrifying, when you consider, just how much uglier real-world code is compared to small tutorials and review articles. I would really like to read a series of “COBOL War-Time Stories”.
how much uglier real-world code is
One of my first projects in COBOL was to complete a rewrite, using structured programming, of a report writer that dated back into the 1960s. If you think COBOL is hard to follow, imagine COBOL code laden with gotos and older than the 1968 standard. IDENTIFICATION DIVISION.
PROGRAM-ID. WELCOME-TO-COBOL.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 MAKES-PROGRAMMING-FUN PIC 9(9).
01 ALL-VARIABLES-ARE-GLOBAL PIC 9(9).
PROCEDURE DIVISION.
A000-FIRST-PARA.
MOVE 0 TO MAKES-PROGRAMMING-FUN.
MOVE 1 TO ALL-VARIABLES-ARE-GLOBAL.
IF ALL-VARIABLES-ARE-GLOBAL = MAKES-PROGRAMMING-FUN THEN
DISPLAY '20 LINES OF CODE TO SAY ENJOY COBOL!'
ELSE
DISPLAY 'USE A BETTER LANGUAGE'
END-IF.
STOP RUN.That’s because it was written by somebody who just learned it. It looks fine when you just learn it, until you actually try to solve real problems with it, and then the weakness of its simplicity become very painfully obvious.
One of the big drawbacks we had though, and this may have changed since, was that COBOL wanted every variable and structure to be fixed length and defined up at the top of the program. So it was not really a good fit for the modern world of the web, JSON, etc. where you don't always know the length or structure of your input in advance. The versions of COBOL we used wouldn't have been able to process a blob of JSON and pull out a particular key for example without having the full JSON structure defined beforehand.
I always joke w/my colleagues that my copy of "COBOL For Dummies" on my bookshelf is as good as my 401k as a retirement plan.
Haha, same here! I owe Y2K my first paid programming job.
> It was a fun language
Nope. You lost me there.
COBOL still gives me nightmares. It was the most profoundly unfun language I've ever had the misfortune to be forced to work with.