The Bewildering Longevity of COBOL
Back in the dim recesses of time a programming language named COBOL was born. It was a strange creature, built on ancient notions that, in the harsh light of the twenty-first century, seem as quaint and obsolete as those squat space-age concept houses that sprouted up in the sixties, all glass and metal and odd angles and strange layered roofs.
COBOL’s big idea was this: a computer language should resemble as much as possible human language, so that “managers and grocery clerks” could read it and write it. Pursuant to this dubious and quixotic goal, it uses “paragraphs” and “verbs” instead of “blocks” and “keywords”, and expresses itself in a bastardized approximation of English sentences. The result is a sort of clipped robot-speak syntax:
IF X EQUALS 3 OR 4
ADD 1 TO X
MULTIPLY Y BY 2
MOVE SPACES TO S.
This syntax also happens to be ridiculously verbose, at least compared to modern-day languages. In Python, if you want to multiply two numbers and assign the product to a couple of variables, you’d do this:
foo = bar = 10 * 3.1415
Easy to read, not too difficult to understand. Here’s COBOL’s approach:
MULTIPLY 10 BY 3.1415 GIVING foo
MOVE foo TO bar
Hmmm. Pretty easy to read, I guess, and sort of English-y. But when I look at this, I don’t think hey, cool, easy to read! I think, hey, shit, hard to type! My carpal tunnel flares up just thinking about writing all that. This may be a godsend to programmers who get paid by the word, but otherwise it’s all purple prose and overwrought diction.
If C++ came up to COBOL to asked for direction to the nearest bathroom, the conversation would go something like this:
C++: me.hello(you)
COBOL: Greetings. How are you. It is a pleasure to make your acquaintance on this most auspicious of days, the day on which I have made your acquaintance. Hello.
C++: me.bathroom.directions = you.bathroom.directions
COBOL: It has come to my attention that you, C++, are seeking directions to the bathroom. The bathroom is where you wish to go. Extrapolating, I further speculate that a piss is what you wish to take in the bathroom to which you want to go.
C++: break
COBOL: An interrupt has occurred in C++’s request for a bathroom in which the piss that C++ wishes to take is to occur. The information that was previously requested will now be assigned to a global variable and kept in abeyance until such time as C++ …
C++: exit()
COBOL: … is ready to use the information which was previously requested on the subject of bathrooms in which various bodily effluvia may or may not be extruded via certain excretory apparatuses …
Of all the misguided efforts over the past several decades to make software easier to write, this notion that computer languages should be more like actual language is perhaps the silliest. Human language serves the human brian, a massive unkempt ganglionic supercomputer that is possibly the most complex entity in the universe — so complex that it doesn’t even understand itself. It can handle the maddening unspecificity, the sprawling chaos of our spoken languages — untangling idioms, parsing grammatical ambiguities, registering implicit connotations. English words can have many different and unrelated meanings, accreted over centuries of use. Our brains have to tease out the appropriate definition based entirely on abstruse factors like context and connotation and a priori knowledge of the speaker’s speech patterns. And even they don’t always get it right. This is not a good model for a computer language, which demands rigor and cannot bear ambiguity. We have a hard enough time getting programs right without having to worry about connotation and inference.
Ok. Fine. COBOL is easy to mock. We in the post-FORTRAN world are pretty much conditioned to mock COBOL. It’s domain-specific and verbose and overwrought, it’s antiquated and obsolete, it’s a shambling brontosaurus in a world of skittering raptors, blah blah blah. But the funny thing is … people are still writing COBOL. Lots of it. There are about 50 billion lines of COBOL floating around out there, with more added each year. It’s still happening. This says something about what passes for conventional wisdom in our industry, and about the danger of discounting the tried and true even in an field where every new advance has the lifespan of a fruitfly. But still, this just blows my mind. It’s sort of equivalent to hacking your way to the heart of a dark rainforest and finding not a small isolated tribe of men and women still using stone-age technology and listening to disco, but an entire civilization in this state. It’s the kind of thing that makes you question your basic assumptions about the universe.
7 Comments