News for hackers. Stuff that matters.
Re:Ask HN: How do I learn real-world COBOL? by agumonkey on Tuesday June 28, 2022 @10:07AM (#31907851)
the few I've seen, COBOL legacy is its own kind. It meshes decades of users, practices, tools and paradigms. We've been shown code that blend old original code with 3GL crude code generator with 4GL custom COBOL transpiled DSLs with monkey patching. It was really not pretty (to stay polite).
Re:Ask HN: How do I learn real-world COBOL? by hermitdev on Tuesday June 28, 2022 @01:04PM (#31910265)
My last project as an intern was to rewrite an old batch processed COBOL app into a simple webform in C#/ASP.Net. The COBOL app was nothing special, really. From what I recall, it was around 65 pages printed. Took me a while to comprehend what was going on, but the first 80% or so was basically just hard-coded rules to take action on based upon user input. Things like when "B", generate "X" & "Y". When "A", generate "X", "Y" & "Z" sort of thing. Nothing fancy, at all. Once I figured out what was going on, I basically just ran the COBOL through some regexs, transformed into an XML doc (don't judge me - it was early 2000s) and wrote the rules engine in maybe one or two screenfuls of C#.

I did learn one thing, and that was COBOL has one up on 'goto'. Check out the control flow statement: MOVE NEXT SENTENCE. It's basically a goto, but it doesn't jump to a label, per se. Instead, it jumps to the next period in the source. Yes, in a big, blocky, verbose language like COBOL, where everything is in UPPER CASE, you're now looking for a teeny tiny period that is easily lost in the verbiage. Hands down, my least favorite programming language construct ever.

Re:Ask HN: How do I learn real-world COBOL? by JD1967 on Wednesday June 29, 2022 @09:12AM (#31919619)
NEXT SENTENCE (not "MOVE NEXT SENTENCE") is sort of equivalent to "continue" in modern languages.

In more "modern" COBOL's like COBOL-85, there is actually a "CONTINUE" which is essentially a no-op.

Some COBOL shops instituted a "one-period-per-paragraph" rule (on the last statement in a paragraph) to avoid some of this. And COBOL-85 (thankfully) added scope delimiters (i.e. END-IF) to help avoid the issues with periods.

Re:Ask HN: How do I learn real-world COBOL? by agumonkey on Tuesday June 28, 2022 @03:21PM (#31911880)
You never ran into an ALTER ?
Re:Ask HN: How do I learn real-world COBOL? by ElectricalUnion on Tuesday June 28, 2022 @02:26PM (#31911190)
> COBOL transpiled DSLs

That problem happens with any transpiled language really, now you have all the problems of the new language and all the problems of the target language, and you need to fix "supposedly compiled" output by hand sometimes.

Re:Ask HN: How do I learn real-world COBOL? by agumonkey on Tuesday June 28, 2022 @03:20PM (#31911874)
I've nothing against cobol, but I think it's worth there, because of the gap with a python like lang (IBM made one) and cobol. Coffeescript to es5 wasn't too hard to guess.