The latest horror (as of this writing, at least) being inflicted on the American people is Elon Musk’s proclamation that he and his team of skr1pt k1ddi3s are going to rewrite the entire Social Security Administration’s software from COBOL into a “modern” language in a matter of months. Others have written how this is almost certainly a back-door attempt to not merely destabilize the SSA, but also to block/delete Congressionally authorized programs carried out by the SSA that the fascists don’t like by simply not writing the code to support them.
But it also prompts the question: Why is anyone still using COBOL? It’s an ancient language originally designed for computers far less capable than systems we have today. Why wasn’t such conversion performed years ago?
I may have an answer for that…
COBOL dates from the late Pleistocene, digitally speaking. It’s a cumbersome, verbose language, designed to read like plain English sentences. It was designed to be written on punched cards, and has a rigid columnar format (the first six characters of each line, for example, are reserved for sequence numbers — so you can put the cards back in the right order when you drop the deck on the floor — and are ignored by the compiler). A program to add the contents of two variables together and display the result looks like this:
IDENTIFICATION DIVISION.
PROGRAM-ID. 03_ADDING.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 var-num1 PIC 9(10) VALUE zero.
01 var-num2 PIC 9(10) VALUE zero.
01 var-result PIC z(9)9 VALUE zero.
PROCEDURE DIVISION.
DISPLAY "Enter number 1: ".
ACCEPT var-num1.
DISPLAY "Enter number 2: ".
ACCEPT var-num2.
ADD var-num1 TO var-num2 GIVING var-result.
DISPLAY "Result : "var-result.
STOP RUN.
Those of you with experience in more modern programming languages may think that looks deeply unpleasant. So do I. But that (obviously) is not what makes COBOL valuable.
Once upon a time, there was a Naval officer named Grace Hopper who, by fortunate happenstance, managed to find herself at the center of the Navy’s adoption and use of computers in the 1950’s and 60’s. She is credited as the “grandmother” of COBOL, although it’s disputed how much of the language she actually defined.
In 1982, she gave a talk at the National Security Agency. The video recording of that talk was recently declassified, and is available on YouTube (Part 1, Part 2). Toward the tail end of her talk, she describes her experiences speaking with users of the computers of the day, and asking why they were using the computer vendors’ custom tweaked versions of COBOL rather than the standard version. She then asked them how much it would cost to convert their programs when the next version of the computer/compiler came out. She got the answer, “We’ll think about that later.”
She eventually prompted the Government Accounting Office to analyze those costs and, after a year of study, they came back with a staggering $450 million/year, circa late-1960’s. Just to convert the software to work on the latest hardware.
Hopper thought this was dreadful. Amazingly, the Navy agreed, returned her to active duty, and directed her to put together a tiny, unfunded team in the attic of the Pentagon, define standard dialects for COBOL and FORTRAN, and to create a battery of tests that would validate COBOL and FORTRAN compilers, and computers running those programs.
The result of that effort was that, if you wrote your program using standard COBOL, compiled it using a validated compiler, and ran it on a validated platform, that program would run exactly the same. Change hardware? Change compilers? No problem. As long as they were validated, the program’s behavior would be identical.
Even today, this is a hard problem. To get technical for a few moments, numbers inside today’s computer memories follow a fairly predictable format — 8-, 16-, 32-, and 64-bits in width are overwhelmingly common, and they are either in unsigned or twos-complement format (the latter allows you to represent negative numbers very simply). Now, suppose you want to add the numbers 100 and 200. What happens? Well, “obviously” you should get the answer 300, but an 8-bit unsigned integer can only represent values from 0 — 255. So what should happen? Does the result “saturate” at the largest possible value (255)? Does it “wrap around” back through zero, giving you 44? Or does it throw an overflow error, possibly stopping the program? There are compelling arguments to be made for all cases.
If you think that’s weird, computers of Hopper’s era were even weirder, with some having integer bit widths of 4, 9, 12, 18, and even 45 bits. And twos-complement format had competition from string-based, ones-complement, and sign-magnitude machines (where +0 and -0 have different in-memory representations, but are still “equal”) and arithmetic over/underflow resulted in very different results between them.
Hopper’s team was instrumental in defining and standardizing all those edge cases, and many others, so programs could be written expecting, and receiving, the prescribed behaviors.
This, I think, is chief among the reasons for COBOL’s longevity, particularly among government systems, and systems for which consistency and reliability are absolutely paramount (such as banks). It’s one of the reasons FORTRAN likewise remains popular among the scientific community, as its precise specifications for arithmetic behavior make its results consistent and repeatable. Very few languages are standardized to this degree — C isn’t, C++ isn’t, C# isn’t, Python isn’t, Go isn’t, Java isn’t, JavaScript definitely isn’t. (Rust seems to be heading in that general direction, but they’re not there yet.) And while some of these langauges have collections of best-practices and corresponding enforcement tools that you can overlay on top of them, none of them are standard.
Musk, obviously, understands none of this. In all likelihood, he’s cramming millions of lines of COBOL through his LLM-of-the-week to translate it to C++, and will proclaim it “done” the first time the spaghetti code successfully compiles with no errors and only a few thousand warnings. And yes, that should horrify all of you. His only lasting contribution to computing will be the record number of `git revert` commands needing to be run to undo his vandalism.
Grace Hopper retired from the Navy, for the last time, in 1986 with the rank of Rear Admiral. She passed away in 1992 at the age of 85. Her contributions to the industry and science of computing are, ironically, incalculable.