When people mention COBOL, it's usually either met with a snort or groan. I don't know much about COBOL, but I've seen some programs written in it. I can see that it's wordy, and to uninitiated eyes such as mine, unintelligible. But, really, aren't all programming languages complete gibberish to a lay person?

I understand that it works, works well, and is still in widespread use in the industries it was designed for. Aren't those the hallmarks of a good language? What's so bad about COBOL?

COBOL was one of the first languages I learned - if you ignore countless versions of Basic, three or four assembler languages and a variant of Forth, then it was in my first five, and learned concurrently with Pascal. IOW, I'm answering from personal experience using the language.

EDIT I should say ancient experience. I never used the language after the end of the 80s, though I did buy a new book (to replace the old one I threw away in disgust) so that I had something to refer to so my horror stories wouldn't get too distorted. But I have no idea how the language has evolved in at least the last 20 years.

Obviously, for many people, it is just that "old is bad" view that jonsca has already described - and also much more a third-hand pass-me-down attitudes thing. But there are real issues underlying that.

Being too wordy is a real problem - there's too much clutter in the way of understanding the code. This is by far the biggest issue. People who look at the MOVE, ADD and MULTIPLY etc statements in horror have a slightly exaggerated view of this, true - the COMPUTE statement is closer to the assignments in other languages. But there's still a lot of clutter in all those divisions and sections. One of the first things I learned in COBOL was to always start by copying a standard page-of-A4-long SKELETON.COB.

COBOL does have some interesting features, but those features (e.g. the PIC thing) tend to be things that are now more part of the DBMS rather than the programming language, and that seems to me to usually be a better way to separate those responsibilities. Also, some libraries in other languages use something comparable to PIC (e.g. printf and scanf in the C standard library). Arguably, the best has been kept, but the worst dropped.

Also, for every nice feature, there was at least one intolerable one. For example, no matter how trivial a loop is, you have to move the body into a separate procedure. The PERFORM ... UNTIL ... and similar statements are single statements - not block structures. In a sense, COBOL was a taste of structured programming from before structured programming was invented - there was a GO TO, but it's use was discouraged (at least when I used COBOL), but looping in particular just wasn't handled that well.

In fact, the language that I used after COBOL that most reminded me of it was... dBase. As in Ashton-Tate dBase III+. These days, people are more likely to remember all the now-dead-or-dying clones (Clipper, FoxPro etc) that led to the generic name xBase - and there is still a living descendant in xHarbour. The point is that these were database languages, but nothing like SQL.

Even then, where every COBOL program operating on a particular database needs to include a copy of the specification of that database (and the copies could end up inconsistent), that isn't really the case in xBase where the database knows it's own structure.

Taking that into account, then, COBOL is not so terrible if you accept it for what it is. But what it isn't is a language for writing data structures. Which may be why COBOL suffered a lot back in the times of the C vs. Pascal holy wars - both sides could agree that COBOL was no good for reinventing the binary tree yet again.

Oh - and one thing I'll never forget is how my first COBOL textbook didn't describe the SORT command, saying that it was outside the scope of the book - apparently, either the author couldn't cope with the idea of sorting, or considered it to be more than the tiny little minds of COBOL students could cope with [see edit at end]. That kind of thing made it very difficult to take COBOL seriously.

An odd aspect of this was Jackson Structured Programming, which I also was forced to learn at around the same time, and specifically for use with COBOL. Part of this was drawing a structure diagram for the input, then a structure diagram for the output, then drawing the in-between structure diagram for the code. Sorting was clearly expected to be an already-solved problem - you couldn't derive a sorting algorithm in this way. So it was odd to be told by the recommended text-book that the whole concept of sorting was beyond my tiny little mind, while at the same time being taught something like a dozen different sorting algorithms and how to implement them in Pascal.

The problems that JSP can handle are probably a good guide for the things that COBOL can do relatively well. But even then, that doesn't necessarily mean that either JSP or COBOL are good ways to handle those problems.



EDIT on 30th July 2014

I just got a reputation boost from this, reminding me it's here. As it happens, due to some nostalgia-fueled ancient book collecting, I can now correct a point WRT the SORT command.

The book I originally used as the recommended text when learning COBOL was "Methodical Programming in COBOL" by Ray Welland. This doesn't cover COBOL 85 (though there was a later edition "Methodical Programming in COBOL-85" which I've still never seen).

kindall comments below that "You were supposed to sort the input files before reading them, or sort the output file after generating it, using the sort utility that came with the OS". From my reply to that, I missed the "came with the OS" point. Kindall was suggesting something akin to the Unix philosophy AFAICT, with COBOL used for the bits it's good for, OS utilities such as a sort utility used for some other things, and presumably using a batch/scripting/shell language to glue the bits together. This makes much more sense in an ancient world where interactive software was rare to non-existent, so you'd be submitting batches of work (hence "batch language") anyway.

The following is quoted from page 165-166 of "Methodical Programming in COBOL"...


  The use of ordered serial files implies that it is necessary to have
  a means of sorting records within a file into some specified order by
  key. Most larger computer systems have a sort utility which will sort
  a file given the position, type and size of each of the data-items
  forming the key.
  
  There is also a facility for sorting records from within a COBOL
  program but this is beyond the scope of this book for two reasons:
  
  (a) the interface to the operating system is often quite complex and
  varies from system to system,
  
  (b) the sort module is an optional part of ANS '74 COBOL and may not be
  implemented in COBOL systems for smaller computers.
  
  Therefore it will be assumed that facilities exist for sorting files
  into a specified order and the problem of updating such files will be
  considered.


In short, kindall is correct - the assumption was that usually sorting
would be done outside of COBOL. There may even have been a real justification
to excluding sorting from a programming language around 1974 for small computers.

What I said above was basically what you get after around 20 years of not
being able to check facts due to throwing away the book.

I should still point out, though, that I formally studied COBOL from this
recommended book that covered the 1974 standard (not the 1985
standard) in 1988 and 1989. The third edition of "COBOL for Students" (Parkin, Yorke, Barnes) - the first edition covering COBOL 85 - wasn't published until 1990. I'm not certain, but I think the COBOL 85 edition of "Methodical Programming" wasn't published until 1994.

But that doesn't necessarily represent the COBOL world dragging its feet - well, not that much anyway. New standards adoption takes time for any language, even now.
