5 ms·
Have not dealt too much with COBOL but learnt it a while ago. It was one of the easier languages to comprehend quickly. I thought it was well suited for input a
by kerng 7y ago
Have not dealt too much with COBOL but learnt it a while ago. It was one of the easier languages to comprehend quickly. I thought it was well suited for input and data processing focused applications.
I do remember thinking it's odd that a line has exactly 80 characters and putting an asterisk in the 7th or 8th row means the line is a comment.
This is probably not true these days with modern COBOL. But when I saw Python the first time, and that it enforces similar restrictions with intendation and then Golang following suite, I had to smile that such old concepts of enforcing style still are seen as useful today.
Often we just have to go back and see what others have done decades ago to get new ideas!
- OneFamousGrouse 7y ago> I do remember thinking it's odd that a line has exactly 80 characters and putting an asterisk in the 7th or 8th row means the line is a comment. You should check out IBM RPG and its various iterations, it's a whole lot worse than that.
- lowken10 7y agoRPG was one of my first languages. It’s crazy to get your mind wrapped around it at first.
- wglb 7y agoAs someone who spent serious time in RPG III in a previous lifetime, I would not advise anyone whose welfare I cared about or was responsible for to go look at RPG. But yes, you are correct.
- russh 7y agoThere is RPGII code I wrote back in the 80's that is still in daily use today. Most of the people who know I wrote the code have passed on, so the support calls have stopped.
- wglb 7y agoPartway through that particular gig, the IBM CE came by and installed COBOL. (For many years, I had ranted about how much I hated COBOL.) So I transitioned all the RPG code to COBOL and what a relief. So I had to eat a little crow. Shortly after my gig, they went full scale IBM and built an IT department, as opposed to just a system 34 in accounting. So no support calls for me.
- AdieuToLogic 7y ago> As someone who spent serious time in RPG III in a previous lifetime, I would not advise anyone whose welfare I cared about or was responsible for to go look at RPG. One of my first gigs was working for a manager who loved RPG III. To the point where I was tasked with making a data collection interpreter using the same constructs RPG III is well-known for. To this day, whenever someone mentions "RPG III" and what that project entailed, I think of the other one[0]. 0 - https://en.wikipedia.org/wiki/Rocket-propelled_grenade https://en.wikipedia.org/wiki/Rocket-propelled_grenade
- sedatk 7y agoGolang doesn’t have semantic indentation.
- K0SM0S 7y agoI don't know why you're being downvoted, this is true. Generally, extra tabs and spaces do not change semantics; nor do new lines (when inlining statements you just can't imply the semicolon). Go files run just fine without any indentation whatsoever. People often assume enforced formatting by the `gofmt` tool is mandatory for the compiler, but most of it is addressed at human beings for readability. Here's the 'official' blog post about gofmt: https://blog.golang.org/go-fmt-your-code https://blog.golang.org/go-fmt-your-code Edit: downvotes don't change reality ; ) Try it yourself: https://play.golang.org/p/_bXvXryM5Ih https://play.golang.org/p/_bXvXryM5Ih — how incredibly ugly, and yet it runs just fine. Please hit format to clean your eyes.
- onei 7y agoI've seen go code fail to compile because a closing } was on the next line and there wasn't a trailing comma. I'd fully expect a formatter to handle that kind of minutiae for me.
- K0SM0S 7y agoOh absolutely, do use gofmt, always. The above example was just to make a point, and perhaps give insights into how the compiler works. IMHO, Go's 'enforcement' of common formatting is powerful; it has an incredible compound effect which gains momentum as you get acquainted with the language.
- thwarted 7y agoI've seen go code fail to compile because a closing } was on the next line and there wasn't a trailing comma. That actually is a syntax error, as go enforces (that is they are not optional) trailing commas. gofmt only formats syntactically correct code.
- 7y ago
- YeGoblynQueenne 7y ago>> This is probably not true these days with modern COBOL It still is. Which column (not row) a statement starts in matters and it's a syntax error to start the wrong statement in the wrong column. Sorry I don't remember any specific examples because it's been a few years since I last used COBOL. I remember hearing that this had something to do with how the early COBOL programs were encoded on punched cards. Anyway there was some practical aspect to it that is now not an issue anymore with the changes to hardware.
- wycy 7y agoThis was the case with Fortran 77 too, and for the same reason (punch cards). But modern Fortran (F90 through F2018) no longer requires formatting by column.
- YeGoblynQueenne 7y agoGood point. I think maybe one reason is that COBOL is valued for its consistency, with the same code often running on modern machines that was written 50 years ago or so (at least that was the received wisdom when I was working at a COBOL shop). Perhaps the same is not the case with FORTRAN?
- Lt_Riza_Hawkeye 7y ago>>It still is It is not if you use free source format, which most new cobol programming is done in. Fixed source format does require the columns specifically, free source format lets you start wherever on the line you want, and extend for however long of a line you would like, but comments start with *>
- brudgers 7y agoSo offsides syntax errors like Python. But immutable instead of arbitrarily dependent on context. Seems simpler and more modular to be able to look at a line of code and determine if the whitespace is correct.
- cr0sh 7y ago> I do remember thinking it's odd that a line has exactly 80 characters Maybe you know this now, but for those that don't: The limitation is due to punch cards - specifically IBM-format punch cards (which was pretty much the standard by the time COBOL was developed). Those punch cards had a layout of 80 columns by 12 rows: https://en.wikipedia.org/wiki/Punched_card#IBM_80-column_punched_card_format_and_character_codes https://en.wikipedia.org/wiki/Punched_card#IBM_80-column_pun... Each column would represent (more or less) a 12-bit "word" for each character on a line of code - so one card per line of COBOL code. Now - note that the IBM PC (well, 5100 and earlier terminals too) had a layout of 80 columns by 24 rows. Why? Because you could (in theory) see a virtual representation of two punch cards one above each other. Whether this was actually used or not, or is an apocryphal or retcon'd reasoning I'm not sure; I've been told both. There's also parallels and such with printers - standard printer width was 80 columns (for regular 8.5 inch wide paper - sans tractor-feed edges), while greenbar was 120 characters wide (using the regular font for most printers); I'm not sure why "40 extra characters" or "half-card" extra, but I bet it's related to IBM punch cards in some manner.