1. 6
  1. 7

    It bothers me when the typical enterprise coder who abuses try - catch tells me that goto is considered harmful. Did you not realize that try {} catch also breaks out of the nice flow of control and can lead to confusing spaghetti? What’s worse, is that sometimes these people keep throwing exceptions all the way up outside of their own function.. sometimes over 12 deep.

    1. 5

      Personally the discussions on goto are getting rather old. People seem to latch on to tidbits of “wisdom” without understanding it. Without understanding the “wisdom” becomes a burden and causes countless pointless discussions like this. This is just like the Dynamic vs Static arguments that have morphed beyond the original meanings and are now strongly debated “wisdom” that doesn’t make any sense. (Referencing this and similar articles: Bellman Confirms A Suspicion - Where does “dynamic programming” come from?.)

      1. 1

        Perhaps I’m a bit younger (I started working professionally in 2008); I’ve never heard anyone ever question the “goto considered harmful” paper. I found Linus' comments in this article fascinating. For the first time in my life I’m now considering the possibility that goto could improve clarity (I still probably won’t use it, but it’s opened up my mind).

        1. 2

          I think where and what you’re working on is pertinent, e.g. if you’re writing a fast finite state machine, goto is indispensable. However, I’ll readily confess that practical uses for goto have become fewer and fewer.

          1. 1

            I meant to reply to this a while ago, sorry…

            That’s part of my complaint. It’s been forever since that paper was written and people STILL hold it up as indisputable fact. It’s an opinion, and a damaging one at that. It would be far better if goto was warned against rather than completely admonished. Like this and many other articles/discussions point out you can’t blame the language (except perhaps for Brain Fuck) for a programmer making a mess. Perl is a perfect example. I’ve seen so many people complain how unreadable it is. Perl is a perfectly readable language, if it is written clearly. You can produce read-only code in any language just as you can make spaghetti code without goto.

            1. 1

              I’ve had a colleague that kept insisting that goto is bad and then produced something along these lines:

              do {
                      tmp = process(input);
                      if (!tmp)
                              break;
              
                      result = further_process(tmp, 42);
                      if (result == -1)
                              break;
              } while (0);
              

              Don’t touch my gotos. :-)

              1. 1

                It sounds like your colleague was against labels, not gotos.

          2. 2

            This is an interesting discussion, dated from 2003, about the usage of goto in the Linux kernel code. It starts with someone bringing the famous “Goto Considered Harmful” argument, which leads prominent figures of Linux kernel development, including Linus, into explaining why this is bullshit :)