Live data from Hacker News

Don't hate COBOL until you've tried it

opensource.com

11–20 of 139 posts

Re: Don't hate COBOL until you've tried it

#11

Oh my God. I wasted a year of my life on a COBOL project. It is easily the worst language I have ever used. There is a reason that COBOL is a linguistic dead-end! Functions? Sensible limited variable scope? A decent approach to handling whitespace so that complex, nested branches make sense? COBOL doesn't even have these basics. Want to declare a variable? You're gonna have to type weird stuff like this: `07 GreatVar…

>>Functions? Sensible limited variable scope? A decent approach to handling whitespace so that complex, nested branches make sense? COBOL doesn't even have these basics.

>>Want to declare a variable? You're gonna have to type weird stuff like this: `07 GreatVariableName PIC X(10).`

I am experiencing this hateful pain and suffering right now. And the previous maintainers hated it too and cut and paste stuff in and out and the files are ~10k lines long and trying to track where a variable has changed, only to find that it depends on another two or more variables, and then trying to track those...

Don't do it folks.

Re: Don't hate COBOL until you've tried it

#13
Once in a while I decide I want to play with COBOL, so I install GNU COBOL, dig out my old test code and try to use it to do something interesting.

So, most recently I wanted to simply read a file, do some simple processing and then write an output file. Very basic, right?

Not so much with COBOL.

First you have to statically declare the files you want to use. Let's say you want to read from "foo.txt":

  environment division.
  input-output section.
  file-control.
      select foo0 assign to "foo.txt"
      organization is sequential
      access mode is sequential
      file status is fs0.
You then need to declare (statically again, of course) the structure of the records in the file. You can think of this as global variables that gets filled in when reading from the file:

  data division.
  file section.
  fd foo0.
  01 foo0-rec.
      02 foo-name     pic x(40).
      02 foo-value    pic x(20).
You also need to declare the "fs0" variable:

  working-storage section.
  01 fs0              pic 99.
Then, you need to open the file. That's not too hard:

  open input foo0.
Then you want to read from it. You can do that using the command:

  read foo0.
After the read, the variable "fs0" will be 0 when you've reached the end of the file, so you need a loop that, I presume (I never got this part to work right), would look something like:

  perform with test before until fs0 = 0
    read foo0
    * foo-name and foo-value now contains data from the file
  end-perform
After all of this, I decided I wanted to do something different. I wanted to call a web service to load some information over HTTP. I dropped that project really quickly once I realised that the only way to do that was to use libcurl and directly access it using FFI. The FFI that is provided by GNU COBOL isn't really easy to work with, as evidenced by this discussion: https://stackoverflow.com/questions/26367026/how-to-make-htt...

If you look at the code that is linked from that page, you'll rather quickly realise why COBOL is not such a great idea for general purpose computing.

Re: Don't hate COBOL until you've tried it

#14
post #8

It's surprisingly well adapted to web development too http://www.coboloncogs.org/

If you have an existing COBOL app you can convert it to a web app and develop using a simpler syntax with more features through SystemZ from Zortec Intl. I've worked with them personally and they were super-duper. COBOL isn't so bad when you use a modern variant that purposefully deals with many of the complaints surrounding it.

Yes, thanks for missing the joke.

Re: Don't hate COBOL until you've tried it

#15
I never tried it, but a friend of mine who wrote COBOL for a bank was offered a huge bonus for postponing his retirement for a year, and he refused because he was so sick of the language (he still likes programming, by the way).

So I don't hate COBOL, but I'm not particularly interested in trying it either.

Re: Don't hate COBOL until you've tried it

#16
I have regualr talks with people who were using COBOL a while ago. There are things were cobol is good :

1/ COBOL run in closed environments. This allows these to be rock solid. (no such thing as a dependency nightmare). You don’t have such a thing as different version of Java on your testing and production environment.

2/ COBOL forces you to mix concerns : DB access, file I/O, business logic. This is sometimes useful to get a complete picture of what’s going on in a program. In Java, you have to wander through your DAO, data model, business logic, etc. which are spread everywhere.

3/ Code resue is hard to acheve so there is some copy/paste. That is sometimes good in the sense that if you fix a program, you won’t accidentally introduce a bug in a copy of that program. (many of us will scream at reading this, but consider it).

4/ Of course COBOL programmers are good too and they use these old practices in a sensible way

5/ COBOL technologies don’t change often. So there’s no discussion about changing your framework. When you write software that must last for at least 10 years, this makes choices easier.

Re: Don't hate COBOL until you've tried it

#18
post #4

Oh my God. I wasted a year of my life on a COBOL project. It is easily the worst language I have ever used. There is a reason that COBOL is a linguistic dead-end! Functions? Sensible limited variable scope? A decent approach to handling whitespace so that complex, nested branches make sense? COBOL doesn't even have these basics. Want to declare a variable? You're gonna have to type weird stuff like this: `07 GreatVar…

The last time I touched it was in undergrad. I remember a professor in my assembly class was showing us old punch cards. They were made with the fancier machines where it printed the line of code on the bottom of the card. I look at the lines in the stack and was like, "Wait, is this ... is this COBOL?" I have to agree. Even back in 2001, I found COBOL awful. I recently moved to a new city after having worked Scala j…

That’s actually quite readable

Re: Don't hate COBOL until you've tried it

#19
One thing I don’t understand with these very old languages is that I thought the reason they are still around is because of some programs written in the 70s to early 90s are still around and needs to be maintained.

But how complex can these programs be? Surely anything written before 1992-ish can’t involve that much code just because of the limitation of the machines they were designed to run on. What makes it that expensive that no one wants to rewrite them in a modern language?

Re: Don't hate COBOL until you've tried it

#20
post #19

One thing I don’t understand with these very old languages is that I thought the reason they are still around is because of some programs written in the 70s to early 90s are still around and needs to be maintained. But how complex can these programs be? Surely anything written before 1992-ish can’t involve that much code just because of the limitation of the machines they were designed to run on. What makes it that e…

I don’t know about cobol specifically , but I do know about technical debt: Liability and cost of switching. Who will take responsibility for any outages (or much, much worse) if it goes wrong? Who will pay for all the safeguards and processes to prevent that from happening? Easier to keep paying the (predictable, consistent, piece meal) upkeep fee than to spend an unknown chunk of money to take a huge risk for a very low immediate gain.

It’s in a local maximum. Just like all technical debt. And as far as I hear, cobol is used for things that put that risk and liability factor on steroids. I know I wouldn’t touch it without some serious budget to set up massive amounts of redundancy and fail safes.

Post reply on HN