News for hackers. Stuff that matters.
Re:Learning COBOL: A Journey for the Modern Programmer by Bostonian on Wednesday April 07, 2021 @12:24PM (#26727155)
Looking at COBOL code such as

   PERFORM N TIMES
     ADD 1 TO I
     DIVIDE X2 INTO 1500 GIVING Y
     SUBTRACT Y FROM 815 GIVING Y
     DIVIDE X1 INTO Y
     MOVE X1 TO X2
     SUBTRACT Y FROM 108 GIVING X1
     DISPLAY I'|'X1
    END-PERFORM.
I wonder if someone has written a Python-to-Cobol translator so that you can program using regular math notation and then translate that into wordy Cobol.
Re:Learning COBOL: A Journey for the Modern Programmer by shakna on Wednesday April 07, 2021 @12:47PM (#26727473)
> I wonder if someone has written a Python-to-Cobol translator so that you can program using regular math notation and then translate that into wordy Cobol.

Yes. But worse. And used in the real world.

Whilst I cannot give all the details for obvious reasons, when I was assisting a particular bank with translating some of their stack from COBOL to modern Fortran, part of the problem was that a large amount of their COBOL code was actually generated.

It wasn't a Pythonish-to-COBOL, though. It was a mix of the C-preprocessor and Bash that generated the COBOL code.

(Problem for me was that all source code was printed, and not stored anywhere digitally, so I had to restore that evil Bash/CPP script just to be able to restore the code I had to retype by hand).

Re:Learning COBOL: A Journey for the Modern Programmer by CountHackulus on Wednesday April 07, 2021 @01:05PM (#26727698)
This is more common than you might think. Back when I worked on a COBOL compiler at IBM one of our test cases was an "expert system" that turned ~20 lines of business-specific DSL into ~100k lines of COBOL. It was extremely un-fun to deal with.
Re:Learning COBOL: A Journey for the Modern Programmer by the_af on Wednesday April 07, 2021 @02:07PM (#26728591)
Looks like the COBOL I saw when working at a bank, years ago. And it wasn't the output of any automated translation.

COBOL is simply horrible. Avoid it if you can.

Re:Learning COBOL: A Journey for the Modern Programmer by Smithalicious on Wednesday April 07, 2021 @12:46PM (#26727458)
Maybe it's because I'm not a native English speaker but what does "divide into" mean?
Re:Learning COBOL: A Journey for the Modern Programmer by hn8788 on Wednesday April 07, 2021 @12:52PM (#26727522)
I'm a native English speaker, and I've never heard that phrase either. I assume it's the same as "divide by", but I could be wrong.
Re:Learning COBOL: A Journey for the Modern Programmer by jdcaballerov on Wednesday April 07, 2021 @02:24PM (#26728855)
Divide into is the opposite of Divide by. X2 into 1500 is 1500/X2
Re:Learning COBOL: A Journey for the Modern Programmer by forinti on Wednesday April 07, 2021 @12:51PM (#26727517)
DIVIDE X2 INTO 1500 GIVING Y => Y=1500/X2