Live data from Hacker News

Don't hate COBOL until you've tried it

opensource.com

131–139 of 139 posts

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

#131

Shouldn't it be possible to convert COBOL to C C++ LLVM IR or even WebASM?

It’s certainly possible; after all, the GnuCOBOL compiler is written in C. A large part of every COBOL program tends to be simple move and arithmetic statements that seem like they should be easy to port. The difficulty comes with the data declarations. COBOL’s pic statements don’t just define length and whether or not they’re numeric. They also come with complex behaviors that are enforced at run time. For example, anything that’s a pic 9 is stored as a sequence of 0-padded text digits, but you can also do arithmetic on them. They work like a car odometer in that if you add 1 to a variable that’s all 9’s, the result is all 0’s. They also allow you to do arithmetic on currency amounts (like I do in the article) exactly, without having to worry about IEEE floating point round off errors. That’s another reason the banking industry likes COBOL.

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

#132

Shouldn't it be possible to convert COBOL to C C++ LLVM IR or even WebASM?

It’s certainly possible; after all, the GnuCOBOL compiler is written in C. A large part of every COBOL program tends to be simple move and arithmetic statements that seem like they should be easy to port. The difficulty comes with the data declarations. COBOL’s pic statements don’t just define length and whether or not they’re numeric. They also come with complex behaviors that are enforced at run time. For example,…

Wouldn't that just mean using functions to have the same results?

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

#133
COBOL was inflicted upon me as a student and BOY am I glad I have never had to use it in the 30 years since. It was as slow, unwieldy and out-of-date a mess then as it is unbelievable now that people persist with such nonsense. It deserves zero respect. It was a blight on my education. A vile pox on it and all its advocates.

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

#134

Earlier quoted context omitted.

It’s certainly possible; after all, the GnuCOBOL compiler is written in C. A large part of every COBOL program tends to be simple move and arithmetic statements that seem like they should be easy to port. The difficulty comes with the data declarations. COBOL’s pic statements don’t just define length and whether or not they’re numeric. They also come with complex behaviors that are enforced at run time. For example,…

Wouldn't that just mean using functions to have the same results?

Sure. My point was just that it's more difficult than it seems. Also this would mean that lines like

add x to y giving z

become something like

cobol_add_giving(&a, &b, &c);

which is a lot less readable.

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

#135

I have not used COBOL for 30 years but the language deserves respect. The transition from assembler to COBOL was one of the biggest productivity improvements in the history of programming, comparable to the introduction of Java and VM-based programs in the 1990s. COBOL is still pretty efficient for tasks like scanning data on magnetic tapes--not that most of us do that any more. In fact it was pretty good for any pro…

The best thing about COBOL is the distinct lack of hipster coders or frameworks. I worked on various COBOL code bases over the years, and they were always approachable, if a little long-winded. My cheques still process via COBOL code a friend's grandmother wrote and still runs on emulated Unisys hardware.

I will not mourn the death of paper checks in the USA. I still have to pay my rent with a paper check. Le sigh.

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

#136
post #116

Earlier quoted context omitted.

Sure, if the money was right. I actually know a bit of COBOL, most of it forgotten. After a while I would move on if they didn’t give me other projects, but I’d even be willing to do it in parallel.

Not sure if I understand you. Isn't "if the money was right" another way of saying "if forced by the customer/platform"? In other words, if the customer told you "pick the language you want" and the platform wasn't a mainframe, why would you choose COBOL?

Well, I wouldn't. The language has a lot of shortcomings. All I was saying was that it was fairly readable.

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

#137
post #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 usefu…

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

Both Go and Java can do that (yes, without having to install a JVM on the target machine).

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

#138
post #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 div…

It's certainly true that there's a lot of boilerplate verbosity involved in reading files in COBOL. But once you've done that, parsing out the fields will likely be much simpler than in most modern languages. Records like this are still produced at government agencies such as the US Census Bureau. I've often wondered if it might be simpler to do the parsing in COBOL and then pipe it to another language to do the rest…

On IBM i all files are are also databases, so you could just define the length of all the fields in the file, then it's a SQL database ready for use. No need for a program to parse it. Just define a file, copy the incoming file to that file. Ready to be handled with SQL. Fixed length records are trivial on the platform.

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

#139
post #28

Earlier quoted context omitted.

> 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? You would be utterly shocked. I did some COBOL work for a bank. Most of the new code they write is in C++. However, COBOL was still a huge part of t…

> I did some COBOL work for a bank. > Most of the new code they write is in C++. Sounds like jumping from the frying pan into the fire.

S/390 has good interop for Cobol & C++: http://www-01.ibm.com/support/docview.wss?uid=swg27003846&ai...
Post reply on HN