share
Stack OverflowWhat makes COBOL such a hated language?
[+67] [17] cable
[2010-03-30 23:26:19]
[ cobol ]
[ http://stackoverflow.com/questions/2549399/what-makes-cobol-such-a-hated-language ] [DELETED]

What makes COBOL such a hated language?

I'm rather young and so I haven't experienced the times when COBOL was still in use and even going mainstream, maybe you can help me out.

Everywhere I go and surf I:

I don't know much about COBOL, except that it is still used everywhere as many old systems haven't got refactored and that it is even still developed and managed. I have also looked at some COBOL code examples but it seems like they are as rare and expensive as unicorn blood.

(12) If by asking a question and having it be closed is the only way to motivate you to learn a language and take your own perspective on it, so be it. - Anthony Forloney
(14) While this might be subjective, I think it's an interesting question (and it's probably not really all that argumentative). +1 and a reopen vote... - Michael Burr
Since I can't add an actual answer, I'll see if I can add a comment instead. COBOL was/is hated because of the constraints. You have to program into a system. An IBM Reference --hope that worked-- of how to write COBOL code. If you can figure out what that page means then you can either learn to hate COBOL or you can learn to love it. PS: that's a snapshot of the site, browse the whole thing. Mostly it's just a reminder of things that are old and clunky. We like shiny and new. - jcolebrand
I think this is a reasonable question. It isn't "Why does COBOL suck?" It's "Why is COBOL the butt of so many jokes?" I think even COBOL lovers would admit that a lot of programmers do look back on it less than fondly (I mean, FP advocates admit that their chosen style of code scares a lot of people), and this question is asking why that is. - Chuck
(2) @John Saunders. The question is in the title. Cable has probably heard plenty of anti-COBOL statements from people who cannot articulate exactly why they hold those opinions. I see plenty of anti-COBOL cracks here on SO, often made by people who don't know what they are talking about. This question is just asking for a bit of reasoned thought on the subject. As such it should probably be tagged wiki. - NealB
(1) I was required to learn COBOL in college, and I learned a lot from it. I personally do not like the language, but I have a sincere appreciation for its history in computing evolution. There is a good reason why it is still be being actively used/developed with to this day. - Josh Stodola
When I saw this question title pop on my google search, I know it was to be closed for some reason, - user457015
My grandmother: very old, cannot do things properly and independently. My mother: also old, going my grandmother's way. Does not mean that I should hate either of them, or that they have been useless persons. Today I can do things easily that neither of them ever could even imagine to do. COBOL is an old language, was THE NUMBER ONE language at one time, had excellent features in the path of evolution of programming. Newer languages came later, with better features, and therfore COBOL is no longer preferred. But does not deserve to be hated. - Pradyumn
[+58] [2010-03-31 15:27:15] NealB

Reasons to hate COBOL

If you need to parse or manipulate text (eg. HTML) then COBOL is going to be really irritating. Support for text manipulation is probably the weakest, most miserable, part of the language. Web developers will all hate COBOL for this reason alone (and justifiably so).

If CPU cycles and memory are not limiting factors, then you will find contemporary languages and frameworks can be a lot more productive.

Your job is to maintain a 30 year old application. You are going to hate this almost by definition. Since the only surviving 30 year old applications are probably written in COBOL, you will hate COBOL.

You are attracted to "shiny new things". COBOL isn't shiny or new - and not for you.

Reasons to like COBOL

The core business of the organization you work for is not developing or delivering computer related services/products (ie. you live on the liability side of the corporate balance sheet). Then COBOL is good because it is very stable and probably delivers the lowest cost per transaction in the industry.

The transaction load you have to process is huge. Non-dynamic, non-object oriented languages (read classic COBOL) are better equipped to build high performance, low memory usage transaction processors. This is largely due to a fairly direct correspondence between a COBOL verb and the generated machine instruction set needed to implement it.

You want to build applications that will be operational 30 years from now. COBOL is an evolving language but has a tradition of hanging onto all of its baggage. This is a double edged sword - avoids forced and/or costly upgrades (good), but can contribute to some awful code (not so good - but you can't have it both ways).

Maintenance. Old COBOL code can be (almost always is) ugly but it can be deciphered and maintained. COBOL is a write/read language (as opposed to write once then re-write). Given the heavy emphasis on leveraging frameworks today, I question whether the resulting code will be "readable" once the underlying framework is abandoned for the next shiny new thing. If you question this statement, consider the list of depreciated elements [1] for the latest Java release. Compare this to the list of obsolete COBOL language elements [2]. The relative sizes of these lists do not speak well for long term Java application maintainability. I use Java as an example only - the same observation applies to all recently developed languages and frameworks (yes, I know Java is "old school" to many of you but it is recent when compared to COBOL).

COBOL is not a Swiss Army Knife

COBOL was originally designed for Business Oriented applications. At that time it meant things like accounting, inventory management and other forms of records management. COBOL is sill largely suited for these applications. If your business is heavily weighted on the processing side of the equation as opposed to the presentation side, then COBOL is a very reasonable language to be using.

A lot of "bad press" COBOL gets is from people who work in application domains for which COBOL is not suited and from those who have never tried to really understand the language (many of whom are academics with a bias for shiny new things).

And by the way, COBOL is still very much alive and in use. We just don't make a lot of "noise" about it.

[1] http://java.sun.com/javase/7/docs/api/deprecated-list.html
[2] http://pic.dhe.ibm.com/infocenter/pdthelp/v1r1/index.jsp?topic=%2Fcom.ibm.entcobol.doc_4.2%2FPGandLR%2Frlpreobs.htm

(16) The basic feature is that COBOL is well suited to a certain problem domain that is, in my opinion, extremely dull. I wouldn't want to write or maintain those applications in any language. That also gives COBOL certain apparent advantages. It's readable because nobody did or does anything particularly complicated with it. It's maintainable in the future for the same reason: COBOL programs do not generally do what those frameworks you mention do. If they did, the features that enabled that would be subject to just as much feature rot. - David Thornley
(29) @David Thornley. COBOL is extremely dull, no doubt about that. And not being subject to "feature rot" is what keeps it relevant. When it comes to processing your pay-cheque and balancing your bank account, dull isn't the issue. Getting it done on time and reliably are all that really count. COBOL is largely about doing dull things efficiently. Kind of like the sewer and water infrastructure every city has to develop - dull, out of sight, out of mind, but essential to everyday life. Understand it and take it for what it is: Relevant, domain specific, efficient, and very dull. Not bad. - NealB
(1) I think the comments on this answer are better answers to the question than any of the actual answers. - Chuck
NealB - hear, hear! - Mark
C is pretty old now and what is obsolete in it? (Other than K&R oddity syntax being considered "bad-practice" in new code) - Earlz
(2) @Earlz: C is significantly younger than COBOL. C appeared in 1972, while COBOL appeared in 1959 (dates from Wikipedia). That thirteen years is much more important than they appear to be, since a whole lot of basic work on computer language design was done around that time. Of languages of similar age, Lisp and Algol have evolved considerably (Algol 60's descendents have had other names, not as much for Lisp 1.5's) and FORTRAN slowly struggled forwards, Fortran 77 not having a full range of control structures. - David Thornley
Excellent answer and comments! - j_random_hacker
(1) Actually i use Cobol on a daily basis and I live cobol. I find that working with the language is easy and once you get the hang of it like any language it is easy to develop programs in. It is fast, and now there is a visual language that comes with it now that I have just started using. Cobol works just like any other programming language. I am now using the new Visual Cobol language and have found it just as easy to use as VB or C# or Java. - Doug Hauf
(1) The "operational 30 years from now" is the cause of the saying "Java is the new COBOL". It is not unlikely that Java backend applications written this decade can live that long. - Thorbjørn Ravn Andersen
"Web developers will all hate COBOL for this reason alone (and justifiably so)." So am I justified in hating PHP (I don't hate PHP just using it as an example) because I cannot build banking systems, payroll systems or device drivers using the language. Every language has a specific field where it is used, Cobol is not a web development language and no they are justified in hating the language. And remember hate and dislike are two different things. - ALXGTV
1
[+41] [2010-03-31 02:48:43] dan04

A big gripe people have with COBOL is the syntax. It was invented by people with the (false) belief that programming languages are easier the more they look like English. Whereas C-based languages have code like:

tax = rate * subtotal;
count--;

COBOL has

MULTIPLY RATE BY SUBTOTAL GIVING TAX.
ADD -1 TO COUNT.

(The COBOL programmers I know really do write "ADD -1" all the time: It's shorter than "SUBTRACT".)


(11) On the other hand, I still miss MOVE CORRESPONDING. - John Saunders
(23) I think this is the real problem. The idea of "natural-language-like" syntax, which seemed so promising in the 50's, just ended up making things worse because it created false analogies that confused programmers---not to mention it's a little condescending! I think time has shown that formal languages should stay formal; it helps programmers learn by forcing them not to rely on (false) analogies to natural language. - Derrick Turk
@Derrick: Although there's a lot of interest in DSLs now... - TrueWill
(5) @TrueWill: The key part of a DSL is that it's domain-specific — that is, it's a close fit to the domain, not a bad imitation of natural human language in general. - Chuck
(1) @Chuck: Good point. - TrueWill
(2) To developers that started programming with a C-based language COBOL may seem odd. But COBOL developers looking at C code for the first time will probably also not like what they see. - Kwebble
(11) If you want that first line to be a bit closer to your C example, you can use the 'Compute' verb: COMPUTE TAX = RATE * SUBTOTAL - AgentConundrum
(2) There is one feature of COBOL I genuinely wish was available in other languages, and that's abbreviated conditional expressions. Example stolen from Wikipedia: The abbreviated conditional expression <br> IF SALARY > 9000 OR SUPERVISOR-SALARY OR = PREV-SALARY is equivalent to IF SALARY > 9000 OR SALARY > SUPERVISOR-SALARY OR SALARY = PREV-SALARY - Atario
(2) @Atario: That wouldn't work in languages that have a Boolean data type. But I do wish more languages supported x in (a, b) or a < x < b. - dan04
-1 for being 4 decades out of date on your Cobol verbs AND for introducing a optimization myth re add -1 verses subtract 1 -- true for a single, long obsolete platform. You could just write: "Compute tax = rate * subtotal" and "compute count = count - 1" - Joe Zitzelberger
(4) @Joe: I DIDN'T introduce an optimization myth. "ADD -1" is SHORTER than "SUBTRACT 1" (by 4 characters), NOT FASTER. - dan04
(1) @Dan -- there was some hardware that had a faster ADD instruction...I think it was 1 early model of the 360, but I don't recall. I've been hearing people for decades say "Always use Add -1 instead of subtract, the instruction timing is faster" based upon that. Sorry if I misunderstood. - Joe Zitzelberger
(6) Excpet in Java this would be written as : BigDecimal bd_subtotal = new BigDecimal(subtotal); BigDecimal TaxPercent = new BigDecimal("0.080"); BigDecimal salesTax = TaxPercent.multiply(bd_Subtotal); - James Anderson
@James +1 for the Java BigDecimal reference. Without using BigDecimal you may even get an incorrect answer to tax = rate * subtotal. - DuncanKinnear
Basically, the intent was to make a language that managers could use. Which meant, of course, that it could not be "logical". - Hot Licks
2
[+28] [2010-03-31 12:12:16] Mark

[disclosure - I work for a COBOL vendor]

I think a lot of the issue you describe (there being a lot of anti-COBOL content on the web) is really down to a few things -

  1. There's a general negative feeling in the computer-geekosphere about anything "old." For these people the latest scripting language is the place to be and anyone doing anything else is out of touch (you'll probably find a good number of Ruby or Groovy programmers saying Java is too old fashioned, COBOL isn't the only language that gets bad PR). I would suggest that the people that are most active in the blogo- & twitter-sphere fall into this group. Whereas the people making good money out of COBOL or those that are actively moving it forward are much less noisy - they have a good living to make!

  2. Posters making the negative comments are not up to date with what modern COBOL is like. You'll hear a lot of comments about a) how verbose the language is, b) how it needs to be formally structured, c) how it encourages bad practise. Every one of these are untrue: a) I don't think there are many languages which can be more consise than COBOL's display "hello world". (yes that is the complete program), b) this hasn't been true for 15 years, c) any language can be written badly.

  3. COBOL proponents & vendors haven't done a great job of keeping the world informed of the changes that have been going on and how vibrant and important the COBOL community & application base is. I'd include myself & my company in this group and we're actively trying to do better.


(3) Any language can be written badly, true, but some reward bad practices more than others. - Donal Fellows
(14) Can you write us an example of modern COBOL then (not just Hello World)? - Mr. Boy
(3) I would add a point 3.b) Companies using COBOL are often insisting on last millenium's versions of COBOL, instead of using the newer ones. - Lars
(3) @Lars: A tremendous amount of COBOL code is legacy code, written in last millenium's versions. New codebases tend to be written in something other than COBOL. This means that the modern versions tend not to be used. - David Thornley
(4) Hi John, Perhaps it's best if I point you in the direction of some - Alex Turner has some great articles on Nerds Central you might like to peruse. For a "modern traditional" COBOL program his latest article is great (bit.ly/ctNPj9). For modern OO COBOL his example on type safety and generics is an eye-opener (bit.ly/98F75c) - for me anyway! Also take a look at Rick Malek's examples for .NET on C#Corner (bit.ly/8YiK09) which he's updating to use the latest version of the syntax. HTH - Mark
print "hello world" #A whole 2 characters less in Python - Chuu
@Mark - the Nerds Central links you posted have disappeared now, shame. - Dave Griffiths
3
[+21] [2010-06-08 07:31:13] Joe Zitzelberger

Am getting told about how horrible COBOL is

People love to bash the unknown. Few programmers want to learn Cobol, even though it is one of the most common languages in use, it just ins't sexy. Not like that "C" language that is almost as old as Cobol.

(BTW, the "COBOL" acronym has been a pronounceable word for over half a century (like Scuba, Radar and Laser), can we stop capitalizing it and just say "Cobol"? Please.)

Pretty much any transaction you have that involves money will be processed through Cobol systems at some point. Most of the "data" that government or corporations house about you and your accounts will be processed through Cobol systems.

See sites making fun of COBOL

People love to ridicule what they don't understand. In this thread I have seen some overtly silly claims about Cobol by people who obviously don't know what they are talking about -- but they will say it because it was that way in disk-memory-and-cpu constrained 1974, so it must still be that way, right?

Lets take some common misunderstandings:

  • Cobol is "Wordy" or "Verbose": Only if you make it so. Cobol allows a lot of whitespace words that mean nothing, but can be there for 'readability'. In practice, nobody ever uses them, so while some haters will silly examples of verbosity, in practice, you will see all the noise crap removed and simple, understandable, terse statements.

  • Cobol is "Old", all the apps were written 30 years ago and the source code is lost, and the programmers are dying: This is just bullshit that Accenture made up to sell y2k contracting hours. For all practical purposes, Cobol is the language of financial transactions. The transaction may be accepted by a javascript web page, a java point of sale, a C++ cash register, but it will be processed, presented and cleared by Cobol systems. They are under active development and there are plenty of programmers around the world writing new apps every day. But they are not sexy -- given the choice between balancing the worlds collective checkbook and writing OpenGL code for the hottest new massively-multiplayer-dougeon, what is the average 20-something geek going to pick?

  • In Cobol, everything is Global: Only if you are stuck in a time-warp to 1966. Cobol has always supported the idea of modules -- separate compile units with isolated storage. It also has a facility to declare storage items explicitly globally accessible to all compile units, but only as an option (BTW, C also has this option). In Cobol-85 the concept of "nested programs" was added -- this is identical to a function or procedure in C or pascal -- a stack frame invocation with its own local storage and some set of parameters passed to it.

  • In Cobol, you use punch cards and green-bar print: Obviously someone who hasn't used Cobol since the 1970s -- back then, you did the same for Pascal, C, LISP, macroized C-With-Classes (later called C++), et al.

  • Cobol loves the GOTO verb: So does C, so does VB, lots of languages allow this abuse to exist. Just because it was used widely in the 70s when that was the only control structure available, does not mean it is being widely used in the tweens(?). Cobol-85 introduced a rich set of control structures that made the GOTO (and its evil twin the Altered GOTO) obsolete.

  • One mis-placed period can ruin your life: Not for the last quarter of a century. Periods for control notation have been made obsolete by the ubiquitous END-* construct.

  • Every line of functional code starts in column 12 or above. So to add a new line, you must first type at least 12 spaces: True in the punch card days -- not true for a long time. Most compilers have a compatibility mode for older files, but can run free-form text as well.

  • Native programmers are mostly brainwashed and incapable of understanding OOP concepts: Object oriented Cobol is alive and well in several flavors. There is native support for objects in the Cobol-2002 standard. Also, for decades before that, most (all) manufacturers of Cobol compilers integrated object support. MicroFocus built their own style of OOP, IBM did too, but also allows for Cobol to interact seamlessly with Java objects, Fujitsu did some other things. Again, this is a case of someone unwilling to learn new stuff after 1974, not a real, valid point.

  • [Cobol] is older than Jesus Christ himself: Cobol and C are both well into middle age. They have more in common with each other than they do with young teenage punks like Perl and Java or tweens like .NET, Python and PHP. Why do you hate on one old, fat, balding, middle-aged computer language like Cobol and give C a free pass?

Hear that I should be happy that I don't have to use COBOL, from older programmers

Cobol is actually a very nice language for some things. It is perhaps the richest AND easiest data definition approach of any language -- you get to lay out every byte exactly as you want it, with exactly the type you want that byte to have. There is a down side to this -- you get to lay out every byte exactly as you want it, with exactly the type you want that byte to have. Super-flexible or super-easy. Pick one.

FWIW, I know and use a dozen languages on a routine basis and I rather like Cobol for many things. Some things are not a good fit, but anything you can do in C (except bit-twiddling) you can do in Cobol easier and with less pain.

See others make anti-COBOL-ist jokes

Well, learning Cobol does seem to be a great form of birth control...

In conclusion:

Seriously, you should learn Cobol. It is an excellent language to know even if you don't use it ofter (or at all). As Alan Kay (father of SmallTalk) once said "A language that doesn't change the way you think is not worth knowing" (or something like that). Cobol's best feature IMNSHO is the data description flexibility. But it is an all around good general purpose language and worth adding to your toolbox. If you decide you hate it after you learn it, you will know your reasons. But I suspect you will find it to be an easy and flexible tool that you will use from time to time.


(5) I keep seeing this "Cobol programmers command huge salaries"??? WTF? That is just silly. Cobol programmers are some of the lowest paid out there. They are employed by financial institutions that treat them like a commodity which is way different from the way a technology firm treats its programmers. And "Modern Cobol", scare quotes and all, is only a keystroke away from formatting as you like it (if you are using Eclipse for your development, Cntl-Shift-F), you can properly case, remove noise words, et al -- just like you can do with badly formatted C and Java code in any modern IDE. - Joe Zitzelberger
(2) Thanks, mate. It was nice reading this. You've just encouraged me to learn Cobol. - Aoi Karasu
(4) As one who used COBOL into the late 1980s, and on time-sharing systems, I can't recommend it. As of my last use, it had very little that other languages I was familiar with lacked (except decimal arithmetic), and missed a lot of what they had. I'm not impressed with an age comparison to C, since in 1959 we knew almost nothing about language design, and in 1972 we knew a lot. COBOL's main contribution to changing the way I think was as a very bad example. - David Thornley
(3) I just want to say that I really, really hate C. "Why do you hate on one old, fat, balding, middle-aged computer language like Cobol and give C a free pass?" I seriously don't. - Puppy
@DavidThornley -- so you actually say that Cobol has the same things as other languages you use, plus it has native decimal, which your other languages do not have, yet you dismiss it. If the languages share the same features, why hate on Cobol? As to age comparisons, would you take seriously a suggestion that C is over 40 years old...by your logic C should be replaced with the new, more modernly designed, LOLCODE? Language design primarily helps compiler writers, not compiler users. Yes, Cobol is tough to write a compiler for, but it is easy to use a compiler for it... - Joe Zitzelberger
(1) @Joe Zitzelberger: No, I didn't say COBOL had the same things as other languages. I said it didn't have extra features over most languages (except decimal arithmetic), and lacked features other languages had. I missed having actual functions bad. Nor do I dislike other languages of its period. I like Lisp a lot, and don't mind Fortran. Almost all of us use Algol descendants and like some of them. However, I hate COBOL and learned very little from it. - David Thornley
What fundamental difference do you see between a "function" and a "nested program"? They both have well defined interfaces, isolate storage, accept parameters, return values, et al. In what way is a nested program not a function? - Joe Zitzelberger
4
[+14] [2011-01-31 07:44:21] user122299

I still remember some of the things we'd put in our programs 35 years ago when I studied COBOL

Professor Stern would see things like this:

 DIVIDE STERN INTO MANY-PIECES GIVING JOY-TO-STUDENTS.

I also liked

 PERFORM IMMORAL-ACT UNTIL POLICE-ARRIVE

(1) These examples are almost as good as what can be done in the Shakespere Programming Language. Very creative. - NealB
5
[+12] [2012-03-08 03:43:34] DuncanKinnear

Before I give my (late) answer in response to some of the other answers, I'll give you a little summary of my background.

I learned various languages (mostly C, but no Cobol) at Edinburgh University in the mid-80s, including a look at OO programming with SmallTalk. Came to NZ in 1990 and got a job at my present company programming C and Cobol (which I had to learn). As a young punk fresh out of university, I thought Cobol was a bit 'beneath me' at the time, but soon settled into full-time Cobol programming. In 1999 I was given the job of rewriting the present system in the OO 4GL 'Forte TOOL'. That lasted a couple of years before Sun bought out Forte and killed it. After a few more years of Cobol we started the present project of rewriting the system in Java, using Spring, Hibernate, EJB3, etc.

If I had a choice out of all the programming languages I've used, I would use Cobol. In the 20-odd years I've been programming in Cobol there has never been a time that I've had to say. "No, I can't do that in Cobol". In fact, here in this office we have a tongue-in-cheek saying: "You can do anything in Cobol".

Our present system contains almost 4 millions lines of modularised Cobol code and is used by our Customers (meat processing plants or abattoirs) to track every aspect of their production from the buying of animals on farms, through slaughter and tracking of individual Carcases, to the packing/labelling/shipping of boxes of meat cuts.

Over the years, in Cobol, we've written software which:

  • is client-server
  • is multi-threaded
  • is GUI
  • talks HTTP to web-services
  • uses sockets to communicate with dozens of different devices such as label-printers, weigh scales, PLCs, meat probes, barcode scanners, etc.
  • is 'real-time' (some production processes require split-second timings)
  • interfaces with many third-party systems
  • has 'Cobol-CGI' web modules used to display Cobol data in a browser

The latest Java project that I've been working on in the past 6 years has shown me that modern languages are not the silver bullet they are made out to be. So far we have only rewritten about a 5% equivalent portion of the old Cobol system and it's taken us 6 years (about 40% of the time it took us to write our whole Cobol system!). So far we've written over 3 million lines of Java code.

Moving from Cobol to Java literally felt like getting back down on my hands and knees and crawling. That's despite the extensive use of complex tools and frameworks like NetBeans, Maven, Spring, Hibernate, Felix, etc. to do a lot of the 'work' for us.

In Cobol, if one of our almost 3,500 modules has a bug in it, we can patch that module, ship it to a customer site (only a few kb), copy it over the top of the existing one and the bug is fixed instantly. Most times the user doesn't even need to log out. Try doing the same thing with a patched Java Class definition in an EAR or WAR! Some of our Customers operate 24/7 with 99.99% up-time. We simply cannot tell them they need to log everyone off, shut down the server, install the new EAR/WAR and then restart the server. Have you ever had several hundred big, hairy meat-workers, who get paid according to production throughput, standing around with sharp knives waiting for your software to restart?

So why are we rewriting? Mainly because young upstart IT managers from prospective Customers take one look at our 'green-screens' and mentally switch off. Because of the perception of Cobol as an old, crap programming language, we have to bring ourselves 'up-to-date'.

We're also aware that the remaining Cobol vendors are now in a cannibalistic phase of consolidation as their market shrinks, and it won't be long until they're all dead, along with the last of the Cobol-trained programmers.


(2) I come from a similar background/career path and share many of your experiences. One thing we are doing more of is having COBOL run the back end and let Java do the "pretty" GUI screens. But... whenever I see a real user opeating a hybrid system that combines both "green screen" and GUI displays I make a point of asking which of the two they perfer. Oddly enough, the answer is frequenlty "green screen" because once a user gets to know their way around a system they find "green screen" navagation and data entry are generally more efficient. Shiny new looks may not always be the best approach. - NealB
No need to totally rewrite your system -- just write the UI in Java and keep the Cobol back end. - Demi
(1) Well, actually, we've sort of ended up doing that as a transition plan. We found a product which gives us JDBC access to the Cobol Vision Indexed files as if they were database tables. We've just built JPA Entities on top of those 'tables' and the rest of our Java Framework then sits on top, including the UI. This allows the Java and Cobol systems to co-exist while we slowly rewrite the old system in Java. Eventually, no Cobol software will access the files and we'll migrate the data into our Postgres database. - DuncanKinnear
6
[+11] [2010-03-31 18:52:23] Josh Stodola

I hate COBOL because...

  • There is no variable scoping, everything is global
  • It has a GO TO statement that everybody seems to love
  • Formatting data (dates, dollar amounts) to be displayed is never fun
  • One mis-placed period can ruin your life
  • Nobody writes a new program from scratch, they copy a production one and change accordingly
  • Every line of functional code starts in column 12 or above. So to add a new line, you must first type at least 12 spaces.
  • Native programmers are mostly brainwashed and incapable of understanding OOP concepts
  • It is older than Jesus Christ himself

Regardless of all these negative things, COBOL is probably the most mature programming language of all time, and it has proven itself in the business world to be extremely reliable. Sometimes I find myself changing a COBOL program that was written 30 years ago, and I wonder if somebody else will be doing the same to my ASP.NET web applications 30 years from now. Somehow I doubt it!


(4) That made me cry and laugh at the same time, because all the things you mentioned were done at the company I was working 6 years ago. The code was sprinkled with GO TO statements, and as I asked the senior programmer why we use GO TOs and if that isn't bad (just started coding then), he said: "Loops are compiled to gotos anywhy, so they're okay :D." Probably the most stupid sentence I've heard to this day. - helpermethod
(3) When using a modern COBOL compiler you are able to code in a free format mode (no 12 spaces), the use of storage divisions is implied/optional, variables can be scoped to local-storage, thread-storage, static class or instance class.. pretty much the same as most languages but I do agree most COBOL programmers are either not interested in OOP concepts or just too busy maintaining existing code. Interesting you have been able to create COBOL asp.net web applications for quite some time now... not sure how popular this is but it is used! - Stephen Gennard
(3) -1 for being 4 decades out of date on your information. Cobol has always had module scope. Goto has been superfluous since 74. Picture clause data description for formatting is richer than most (all) other languages. Periods have been superfluous since 74. Your inability to write a program from scratch is hardly an indictment of the language. Free format source is widely available and long supported. Newer Cobol dialects support OOP. Jesus Christ is a myth, thus, has no age. - Joe Zitzelberger
(4) @Joe Yeah, yeah, I really don't care what has been superfluous since when. That's completely irrelevant. They can make a million improvements to any compiler and that does nothing to the stockpile of COBOL code that already works. I've stared at a LOT of production COBOL code, and it looks nothing like what I was taught in college. It's nice to preach about all the fancy stuff and the "right way" to write COBOL to new developers, but it's truly impractical. Why? Because the "wrong way" already works. You're just setting them up for disappointment when they see their first real program. - Josh Stodola
I spend lots of time with lots of production code. The stockpile isn't all that bad. In the world I'm in, z/OS, the last vendor supported 74 compiler, VS COBOL II support has been gone since the 90s. Those object modules will work forever, but any source changes are going to require at least some superficial updates to get to a Cobol 85 level -- fix linkage & blls; remove service reloads; etc. - Joe Zitzelberger
@spgennard, this implies that those features haven't been turned off due to Native programmers. - Ape-inago
7
[+11] [2011-08-26 03:03:28] James Anderson

Well COBOL isnt such a bad language for something put together by a committee in 1959.

However there are some deeply serious shortcommings:

  1. No function calls. There were recently a number of functions added to the language. But there is no way to easily define your own function calls, and, if a function is not supplied with the compiler then its just not there.

  2. No type checking on subroutine calls. While COBOL is strongly typed within a single module there this is no type checking on parameters passed from one module to another. This causes so many problems that I have seen coding standards that more or less ban modular programming.

  3. No standard libraries. If its not a build in language verb then you write it yourself.

  4. While the language has crawled slowly into the twenty first century, most of its practitioners have not. So criticisms about 1970s COBOL still apply to current programs even though there are now better cleaner ways to write COBOL.

There are however many "negatives" made in this thread that are misleading or untrue.

  • It's verbose : While MOVE X TO Y may take a few more characters than Y = X the structure and file definitions are quite succinct, and things like automatic type conversion etc. make it much less verbose and easier to read than Java or even C++.

  • No multi-threading : true there is no built in language support for threads, but, this is mostly because it was never required. Multi-threading and multi-tasking has always been handled by application containers like CICS and IMS/TM, there was never any need for it within the language itself.

  • String Manipulation -- Cobol's STRING, UNSTRING and INSPECT verbs are pretty useful and at least as good as Visual Basic hodge podge collections of string functions. The TRANSFORM verb was really nifty but is now depreciated or unavailable.

  • Bit manipulation -- is actually supported in several/most dialects of COBOL either natively as a "PIC" type or with built-in functions.

Additionally there are several areas where COBOL shines and is markedly better than many, most or all other languages.

  • Decimal arithmetic. Decimal arithmetic is built into the language. Fortran, C, C++ and Java cannot native types cannot due decimal calculations correctly according to accounting and tax regulations. (VB can!).

  • Database Integration. It may implemented as a "pre-compiler" but its easier to code up SQL and manipulate results in COBOL/DB2 than in anything else (Pro C excepted). Its just so much simpler and easier than any ORM or ADO to code.

  • File handling. You see a lot of posts complaining about "COBOL" files. There is no such thing, they just happen to be files that can be read and manipulated by a COBOL program. I have never yet come across a file format that could not be handled by the standard COBOL file definitions and verbs.

  • XML integration. Built into the latest compilers and implemented simply and elegantly.

  • Screen Handling (Nearly forgot this one!). Cobol's screen handling is just superb. Simple elegant and clear. Compare and contrast with the "ncurses" library.


I would take issue with the "No Function Calls" -- a nested subprogram is functionally identical to a function, regardless of what you call it. Not being type checked is, however, a big deal. - Joe Zitzelberger
(1) @joe -- the difference between a function call and calling a subroutine is that you can place a function call in the middle of an expression, and pass the result of an expression in as a parameter. COBOL subroutine calls must be passed references to variables and can only return results in one of the references passed. You can argue that the result is the same -- but the coding is much clumsier and ambiguous. And I would repeat my biggest bug bear -- no standard libraries -- I cannot begin to count the number of erroneous date calculations I have seen implemented in COBOL. - James Anderson
8
[+9] [2010-06-08 07:43:31] Big Al

I'll quote Robert Glass from Facts and Fallacies of Software Engineering [1]..

COBOL is a very bad language, but all the others (for business data processing) are so much worse.

He goes on to explain its benefits (has most of the language features that a business programmer might need like fixed format data structures, penny accurate calculations, etc.) and its faults (mostly syntatic) and ends with an interesting statistic...

Each year, practitioner surveys show that COBOL usage will be considerably lowered the following year. And each year, COBOL is found to be the language with the largest increase in usage.

Take that with a grain of salt, the book was published in 2002.

I think most of the hate stems from the syntax, and because distaste for it has become an easy way to spark conversation among fellow programmers.

[1] http://rads.stackoverflow.com/amzn/click/0321117425

9
[+8] [2010-03-31 02:05:18] TrueWill

Some of the stigma comes from Old School COBOL, which was truly painful. I had to write COBOL on punchcards for a course years ago. We had terminals and more modern languages like PASCAL, but this legacy horror still existed:

  1. Write program out on big sheets of green paper, with character-sized grids, one character to a cell. This was particularly painful, as COBOL was terribly verbose.
  2. Drop off paper at data center.
  3. Come back later and pick up stack of cards (your program typed up by the kindly keypunch operators).
  4. Check cards for typos.
  5. Use a keypunch machine to redo any cards with errors.
  6. Drop batch of cards off at data center.
  7. Come back later and pick up stack of printout, usually errors.
  8. Debug errors by inspection.
  9. Use a keypunch machine to fix cards with bugs.
  10. Go to step 6.

This certainly wasn't all COBOL's fault. More modern COBOL compilers have improved some of the faults of the language, or so I've heard. But after that experience, I have no desire to go anywhere near it.


@TrueWill: your problem was that you had "kindly keypunch operators". You'd have written better code if you'd had to do the keypunch yourself. - John Saunders
@John: the keypunch operators were actually quite accurate, as I recall (although it's been about 25 years). - TrueWill
(6) @TrueWill" Yup. been there, done that. Actually, you left out the step where you "Drop cards - spend two hours putting them back in order" :-) - nzpcmad
(2) @nzpcmad. You never learned to put magic marker stripes across the edge of your card decks? That way you could sort out the dropped deck just by aligning the edge marks again. Been there, done that. - NealB
(2) @NealB: I've also done the rough equivalent of cut-and-paste by moving cards within the deck, since reusing the cards was much easier than punching new ones. At that point, the stripe is less useful. - David Thornley
(1) @David Thornley After "editing" I just put a new stripe on the deck using a different colour. After a few "edits" the deck begins to look like a wrapped Christmas present (lots of pretty colours). The real trick is to remember what colour the last stripe was. - NealB
Despite David Thornley's valid objection I LOVE the idea of the "stripe". So simple! - j_random_hacker
(3) None of the steps above were specific to Cobol. I did them with 370 assembler, pascal and C as well. The fact that your data center was too cheap to invest in terminals is hardly a valid indictment of a language that continues to feed millions of people in the 21st century. - Joe Zitzelberger
10
[+8] [2010-03-31 02:42:47] Dean Harding

I hated it because COBOL programmers tended to write emails IN CAPS BECAUSE THEY FORGOT TO TURN OFF THE CAPS LOCK KEY, AND COULDN'T BE BOTHERED AFTER THEY'D TYPED IN HALF THEIR EMAIL ALREADY ANYWAY.

At least I don't have to worry about being shouted at in email any more now that I've moved on :-)


(3) -1 for a useless generalisation that has nothing to do with the original question - DuncanKinnear
(1) Odd, I don't remember that the 029s even had "caps lock". - Hot Licks
11
[+6] [2010-03-30 23:32:41] duffymo

COBOL, Lisp, and FORTRAN are the oldest higher level languages. COBOL is generally associated with legacy mainframe applications.

It's possible to write clean (and spaghetti) code in any language.

I believe COBOL has subroutines, so it's possible to write it in a well-decomposed, top down, modular style. COBOL that is written using a copy and paste style can be voluminous and hard to understand.

But COBOL's not a joke. It powers a lot of software that runs large companies.

People that write COBOL live in a mainframe world and don't deal with distributed, object-oriented ideas that you take for granted in more modern languages. Maybe that's why people say you should feel lucky to not write it.

I've never written COBOL; can't read it, either. No desire to learn.


(5) Back when I used COBOL, there were FORTRAN-type subroutines, but not functions. That cramped my style a lot. To call one, you'd load up the input variables (MOVE x TO y.), call the subroutines, and then proceed based on the output variables. - David Thornley
I'm mystified as to why this answer is being downvoted 4.5 years later. - duffymo
Just write another program. Or pre-process. I've seen programs just SQL wrappers of 5-10 statements. called 20 million times a day. ...and pre-processors to expand "functions" or verbose boilerplate. - mckenzm
12
[+5] [2010-04-14 20:41:01] Dean J

COBOL predates a lot of things that modern programmers - who have only learned more recent langauges - take for granted.

Largely, the programs were written by people who don't think like you do. They were never exposed to OOP, for example, and design patterns weren't formalized until the late 80's/early 90's. I compare it to watching a C++ girl talk to a VB guy. They don't have much shared basis for technical discussion, although they both produce fine code at the end of the day.

As one commenter reminds me, COBOL was largely insulated from the good ideas in programming as early as 1970.

Djikstra had a real zinger of a quote [1] that's worth reading again. I'm fairly sure, stretching my previous analogy, that he'd feel the same about VB.

As a general summary, if you want a steady job in the financial industry, absolutely learn Cobol. Your job will be in a large, incredibly structured organization, probably one that favors following tried-and-true process instead of empowering developers, for what it's worth. The benefits will be good, the pay will be average, and the hours will be 40. You will be employed until you're ready to retire, as long as you're any good. You will not learn anything new while you're at it, unfortunately; once you have the swing of things, that's what you've got to work with for 20-40 years.

If you do not want an incredibly stable job working for a bank, and especially if that job description makes you scquickly, Cobol sucks.

[1] http://www.cs.virginia.edu/~evans/cs655/readings/ewd498.html

(4) OOP? Design patterns? Early Fortran and COBOL programmers didn't know about the stuff that was coming in around 1970, largely imported from Algol. Procedural programming was new stuff when COBOL was already ensconced. - David Thornley
@David Thornley: Okay, +1 on the comment. :-) - Dean J
(5) The sad thing about Djiksrtas' "zinger of a quote" is that he was taking a swipe at just about every existing computer related technology of that time (1975). He offered no constructive alternatives. Also, his predictions of doom for businesses that use COBOL doesn't seem to have a come anywhere near true - unless 30 years is too short of a time horizon for his prophecy. A brilliant mind, but with the attitude of a gurmpy old man. - NealB
(2) @NealB: very much agreed. Hearing Djikstra say "get off my lawn" would be perfectly in character. - Dean J
(2) It is worth noting that Djikstra panned all the other popular languages of the time. He was not so much bitching about Cobol (and PL/I, Basic, Fortran, et al) as complaining that he didn't have a language that could satisfy the vision in his mind. Yet. - Joe Zitzelberger
(1) @NealB Djikstra wrote: "Many companies that have made themselves dependent on IBM-equipment (and in doing so have sold their soul to the devil) will collapse under the sheer weight of the unmastered complexity of their data processing systems." - it mentions IBM and unmastered complexity, nothing about doom for businesses that use Cobol - F. Malina
13
[+4] [2010-06-06 14:58:06] JUST MY correct OPINION

I can give you a personal outlook only given what I did with COBOL and what I did after COBOL. I hate COBOL because it is incredibly verbose while being at the same time incredibly inexpressive. Any one of those two things is tolerable (albeit not desirable) in a programming language. Having both together in the same language is deadly. Working with COBOL after seeing better languages always made me feel very much like I should be using an axe to program the system.

Mark's answer [1] on this has a lot of truth to it. "Modern" COBOL (scare quotes because even the most modern of COBOLs is not a modern language in my view) is vastly superior to the stuff I had to code with. This is largely irrelevant, however, because practically nobody actually codes with modern COBOL. They use modern COBOL compilers to write ancient-style COBOL code much like a lot of "C++ programmers" basically just use it as a slightly better C, so basically you're still using incredibly verbose (and sometimes obtuse) syntax to do simple, mindless tasks because you can't do interesting or challenging tasks with the language unless you're a dedicated madman.

That being said, the few remaining COBOL dinosaurs out there do command huge salaries because of the combination of their rarity and the business value of the software they maintain. (Very few people make software in COBOL anymore!) I just think, in the end, that there are things more important to me than making money.

[1] http://stackoverflow.com/questions/2549399/what-makes-cobol-such-a-hated-language/2552733#2552733

(2) +1 because, while many of the COBOL supports love to remind us that the language has evolved through time, nobody uses those new features. - Bruno Brant
14
[+2] [2010-11-30 17:21:39] ascanio

COBOL is not bad per se, but it is indeed a 1959-born technology dinosaur mainly used for writing dull and uninteresting accounting software.

"The use of COBOL cripples the mind; its teaching should, therefore, be regarded as a criminal offense." E.Djikstra


(3) -1 for ignoring that Cobol has not stood still since 1959. With all regards to Prof. Djikstra and his wisdom, modern Cobol is not what you are talking about. - Joe Zitzelberger
(3) First of all, I know COBOL, I worked with it, and some of the best programmers I know are COBOL programmers. But modern COBOL sounds to me like an oxymoron. COBOL is a language for financial transactions, it has been defined to be easy and human readable even for non-technical people, but the result is a ridiculous syntax. In my opinion, COBOL progresses are mainly useless. It has no sense trying to do modular programming or OOP with it: other languages make it easier, and better. - ascanio
15
[0] [2011-08-25 15:17:08] user912428

What about COBOL lacking the followings:

Resouce allocation/sharing concurently with other processes

No multithreads support

No reference to bits

No logical operations between variables

weak library support


You forgot no way to define a function, and no type checking on subroutine calls. - James Anderson
(1) All the major vendors' Cobols now support all of the above, so this is no longer a valid argument. - DuncanKinnear
(1) @DuncanKinnear, this assumes that those features are enabled in the compiler. Part of the issue isn't just the code itself, but the culture surrounding it. - Ape-inago
@Ape-inago We have done all of the above in our system using Cobol. Besides, this question is talking about the language, not the culture, which is a totally different subject. - DuncanKinnear
(1) @DuncanKinnear The culture surrounding the language is very important though. A strong culture means you get lots of great support and libraries and guidance along the way. The question was about why COBOL is such a hated language... and the culture can be one of the reasons. - Ape-inago
(2) @DuncanKinnear From a purely academic standpoint, COBOL isn't so bad. But you have to consider that many programs (and cultures surrounding them) are locked away inside big business (banks, utility companies) and sometimes the developers started out as logically minded office workers and not programmers who understand OOP, threading, etc. It valid given the context of where COBOL tends to be used. Consider the reason why many people dislike VB6. Sure you can write bad code in any language... but some languages have a heritage of shooting their foot and still limping along to this day. - Ape-inago
16
[-4] [2010-06-06 14:08:53] Erwin Smout

"Djikstra had a real zinger of a quote that's worth reading again."

If it were up to Dijkstra and his crew, the only programming language in the world would still be ALGOL/60 (yes, the number refers to a decade).

And if it were up to Dijkstra all by himself, even that language would be disposed of in favour of (heaven forbid) LISP.

Referring to one of his famous oneliners, half of his writings expose a level of arrogance (and, alas, crappiness as well) that can only originate from the Dutch.

The art with any of his writings is to determine whether it belongs in the "indispensible readings" half rather than in the "angry-and-frustrated scientist's overzealous crap" half.


Dijkstra did more to set back software engineering with his anti-goto hissy fit than did a myriad of COBOL programmers. - JUST MY correct OPINION
(1) "...that can only originate from the Dutch." Wait, what? - Wander Nauta
(3) Dijkstra was #$%&%$$^ brilliant. And his anti-goto missive was spot on. I wonder, though, why everyone thinks it was targeted only at Cobol when EVERY language in 1968 was abusing gotos in spectacular ways. - Joe Zitzelberger
(4) -1 because you didn't supported your answer with facts (you state that Dijkstra is arrogant, prefers ALGOL and LISP but do not supply any info to support that) and offended the dutch, which might be a joke, maybe, but one that appears disconnect and can be offensive. - Bruno Brant
(2) Bruno, if I said that "OO programming is an extremely bad idea that could only have originated in California", would you also downvote me for offending the Californians in a way that is totally disconnect ? - Erwin Smout
// , Careful with assuming that someone, somewhere, out there is offended - Nathan Basanese
17