3 ms·
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
by Bostonian 6y ago
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.
- Smithalicious 6y agoMaybe it's because I'm not a native English speaker but what does "divide into" mean?
- forinti 6y agoDIVIDE X2 INTO 1500 GIVING Y => Y=1500/X2
- hn8788 6y agoI'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.
- jdcaballerov 6y agoDivide into is the opposite of Divide by. X2 into 1500 is 1500/X2
- shakna 6y ago> 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).
- CountHackulus 6y agoThis 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.
- the_af 6y agoLooks 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.