5 ms·
You really don't know bad programming until you have spent some time in a 50000 line cobol program. I'd post some crap I work on every day but I don't want to m
by redredraider 16y ago
You really don't know bad programming until you have spent some time in a 50000 line cobol program. I'd post some crap I work on every day but I don't want to make anyone cry. Nevermind. Here's some random code I'm working on.
MOVE SPACES TO LISTBAT-NAME.
STRING WORK-FILES "LIST.BAT" DELIMITED BY " "
INTO LISTBAT-NAME.
OPEN OUTPUT LISTBAT.
MOVE SPACES TO SCR-S.
STRING "DIR /B " DATA-PREFIX " > "
WORK-FILES "TMPLIST" DELIMITED BY " "
INTO SCR-S.
MOVE SCR-S TO LISTBAT-REC.
WRITE LISTBAT-REC.
CLOSE LISTBAT.
CALL "C$system" USING LISTBAT-NAME, 96
GIVING STATUS-VAL.
MOVE SPACES TO TMPLIST-NAME.
STRING WORK-FILES "TMPLIST" DELIMITED BY " "
INTO TMPLIST-NAME.
OPEN INPUT TMPLIST.
MOVE LOW-VALUE TO LIST-NAME.
PERFORM UNTIL 1 = 2
READ TMPLIST
INTO SCR-S
AT END EXIT PERFORM
END-READ
ADD 1 TO PROGRESS-REC-CT
INSPECT SCR-S CONVERTING LOWER-CASE-ALPHA TO
UPPER-CASE-ALPHA
PERFORM VARYING SCR-X FROM 50 BY -1 UNTIL
SCR-X = 1
IF SCR-S(SCR-X:1) = "."
MOVE SPACES TO SCR-S(SCR-X:)
EXIT PERFORM
END-IF
END-PERFORM
CALL "CC/STRINGER" USING SCR-S, STRING-INFO
MOVE SCR-S(1:STRING-INFO-LENGTH) TO TMP-RID
PERFORM LOAD-RPT-FILE THRU END-LOAD-RPT-FILE
END-PERFORM.
CLOSE TMPLIST.
The newline on some of those lines is off because HN makes it wrap but you get the idea
- rorrr 16y agoNote to self: do not learn COBOL.
- redredraider 16y agoI'm sure it would make you a better programmer. Using tools that were abandoned by their company 10 years ago teaches one to be humble and to appreciate the little things in life.
- jtolle 16y agoThat's funny, because I look at that and think it's too bad I don't know anything about COBOL. It's not like I'm planning to learn it or anything, but it's quite different from anything I've ever worked with. So, questions: I know I'll never program in COBOL. But I'm interested in programming languages in general. How much of a "quick intro" would be worth digesting just for the purpose of contrasting to C, VBA, Lisp, etc.? Is there a good one to look at?
- redredraider 16y agoI'm interning with a company that is a COBOL shop. It took me months to make the transition from "normal languages". I don't think it's worth learning honestly unless you get a job in it. Here are some things it has taught me. It's taught me to create pretty code that is indented correctly. I pretty much live in a debugger. Most people out of a CS program think they know how to debug stuff. They don't have a clue. It's taught me to be very meticulous and review every single thing I do down to periods(which BTW terminate loops and if statements making life hell) If you can't understand what you just wrote it needs rewritten. As far as language comparisons. All variables are declared at the top of the program. All variables are fully global. If you move a variable to a smaller variable it doesn't throw an error it just gets truncated. Loops start at 1 instead of 0. There is very limited error handling. I don't know of any resources online. I searched when I started working but I didn't find anything real helpful. I did have a 25 year old 30 million line code base to learn from though
- wglb 16y agoYou know, I once had that rule for myself. And I would state it loudly. My first consulting gig involved writing some moderately large royalty accounting programs in RPG-III for a System 34. One day, the engineer from the vendor stopped by and plopped cobol onto the system. Suddenly, COBOL didn't seem all that bad, and i broke my rule. Yes, there are some things worse than COBOL, and I hope you never have to deal with them.