tags:

views:

1358

answers:

14

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:

  • Am getting told about how horrible COBOL is
  • See sites making fun of COBOL
  • Hear that I should be happy that I don't have to use COBOL, from older programmers
  • See others make anti-COBOL-ist jokes

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.

  • If you close this question or give me sarcastic, irrelevant answers I'll have to learn COBOL to find it out the hard way. I'm serious.
+3  A: 

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.

duffymo
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
+5  A: 

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
@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
@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
@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
@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
@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
+2  A: 

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 :-)

Dean Harding
+13  A: 

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".)

dan04
On the other hand, I _still_ miss `MOVE CORRESPONDING`.
John Saunders
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
@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
@Chuck: Good point.
TrueWill
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
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
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-SALARYis equivalent to IF SALARY > 9000 OR SALARY > SUPERVISOR-SALARY OR SALARY = PREV-SALARY
Atario
@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
+10  A: 

[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.

Mark
Any language can be written badly, true, but some reward bad practices more than others.
Donal Fellows
Can you write us an example of modern COBOL then (not just Hello World)?
John
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
@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
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 (http://bit.ly/ctNPj9). For modern OO COBOL his example on type safety and generics is an eye-opener (http://bit.ly/98F75c) - for me anyway! Also take a look at Rick Malek's examples for .NET on C#Corner (http://bit.ly/8YiK09) which he's updating to use the latest version of the syntax.HTH
Mark
+16  A: 

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 for the latest Java release. Compare this to the list of obsolete COBOL language elements. 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.

NealB
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
@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
I think the comments on this answer are better answers to the question than any of the actual answers.
Chuck
NealB - hear, hear!
Mark
Earlz
@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
+5  A: 

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!

Josh Stodola
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.
Helper Method
+1  A: 

This reminds me of this blog entry.

Bruno Brant
+1  A: 

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 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.

Dean J
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
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
@NealB: very much agreed. Hearing Djikstra say "get off my lawn" would be perfectly in character.
Dean J
+1  A: 

"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.

Erwin Smout
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  A: 

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 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.

JUST MY correct OPINION
+5  A: 

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.

Joe Zitzelberger
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
Thanks, mate. It was nice reading this. You've just encouraged me to learn Cobol.
AOI Karasu
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
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.
DeadMG
+2  A: 

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

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.

Big Al
A: 

I hate COBOL bcoz 1. Whenever i made changes, i need to compile it. 2. For Adding two numbers it takes 10 lines of coding. Where as in SAS it takes just 3 lines of coding. 3. Whenever i tried to analyze the production program i stuck up somewhere in the middile and i never completes it... :-( 4. Whenever my manager asked me to code a program, i think that why all the difficulties are coming to me..

lobo101