3 ms·
I usually associate fanatical goto hatred (as in #4) with people who don't do systems programming, particularly in C, where using a goto to jump to a label that
by vezzy-fnord 12y ago
I usually associate fanatical goto hatred (as in #4) with people who don't do systems programming, particularly in C, where using a goto to jump to a label that executes instructions (like cleanup and freeing memory) in the event of an error condition, is a very common pattern.
These people would probably be shocked if they read the source code of the average GNU/Linux distro's software stack.
- InclinedPlane 12y agoTo be fair, the example in #4 is EXACTLY WHY IT'S BAD TO USE GOTO. It's a horrible abuse of the construct that makes program flow much more difficult to follow and should have been replaced with moving some of the code off into methods.
- username42 12y ago'GOTO considered harmful' is practically biblical law amongst many programmers, but it's worth remembering that he made that statement in the context of an argument with Donald Knuth. Knuth won: ( http://web.archive.org/web/20070927094626/http://pplab.snu.ac.kr/courses/adv_pl05/papers/p261-knuth.pdf http://web.archive.org/web/20070927094626/http://pplab.snu.a... See also http://web.archive.org/web/20051128093253/http://kerneltrap.org/node/553/2131 http://web.archive.org/web/20051128093253/http://kerneltrap.... about goto Good uses of goto are very rare with current programming languages. The only cases where I have found good uses were with languages that did not have exception handling and in each cases, there was some deficiencies in the specifications and the code containing the goto has disappeared with the corrected specifications. Maybe this was luck. I still think it is ridiculous to hate goto.
- MaulingMonkey 12y agoI associate goto hatred with people who've experienced goto hell, but perhaps that's extrapolating from my own experience too much. My first programming language was BASIC - one baked into the ROM of an Apple II. Numeral based gotos were simply how you got around. I saw no problems with this - it's just how things were. I've since been ruined by better programming languages. That gotos for cleanup is the lesser evil in C speaks more to the weakness of C than the virtue of gotos for me. I'm sure stockholm syndrome would eventually assuage my pain and I'd stop hoping for raptors if I went back to C... For what it's worth: I'm not a systems programmer, so chalk up another one for that association. I was a little shocked by GNU software - the 50 line GCC if statement, not the cleanup goto pattern. But only a little - I've seen Lugaru's GameTick.cpp before it was cleaned up.