Slashdot Mirror


Empirical Study On How C Devs Use Goto In Practice Says "Not Harmful"

Edsger Dijkstra famously opined in 1968 on the danger of Goto statements. New submitter Mei Nagappan writes with a mellower view, nearly 50 years later: By qualitatively and quantitatively analyzing a statistically valid random sample from almost 2 million C files and 11K+ projects, we find that developers limit themselves to using goto appropriately in most cases, and not in an unrestricted manner like Dijkstra feared, thus suggesting that goto does not appear to be harmful in practice. (Here's the preprint linked from above abstract.)

6 of 677 comments (clear)

  1. why? by Anonymous Coward · · Score: 5, Insightful

    Is that because they were warned by Djikstra that it would be harmful to use it haphazardly? Or is it for some other reason?

    1. Re:why? by Anonymous Coward · · Score: 5, Insightful

      If I worked for someone as rigidly blind as yourself, I'd have left years before you "fired me", "manager in your dreams".

      THE ONLY RULE is that rules are meant to make you think carefully before you break them.

      Rules are for the guidance of the wise and obedience by fools.

      You, sir, are a fool.

    2. Re:why? by tepples · · Score: 5, Insightful

      How many levels of nested if blocks are you willing to tolerate solely in the name of avoiding a single use of the keyword goto?

    3. Re: why? by Darinbob · · Score: 5, Insightful

      What if I actually am an expert? Am I still bound by your superstitions about goto?
      It's one thing to tell a student or beginner to avoid goto, but another thing to place an absolute prohibition on them.

      The original goto-considered-harmful paper was written at a time when structured programming was extremely rare, spaghetti code was common, and the flowchart was a common design method. We're decades past that time though and the general programming style everywhere is to be highly structured. So the same repulsion about using goto is no longer necessary, we know enough to not use it at a whim but should be allowed to use it when it is indeed appropriate in languages which do not have the necessary structured constructs to avoid it.

  2. What's the term for a prophylactic prediction? by myvirtualid · · Score: 5, Insightful

    There is an implication that Dijkstra was wrong about the goto - the implication being based on how conservatively it is used.

    Perhaps it is wiser to conclude that the goto is used so conservatively because Dijkstra was right and that programmers have, in general, taken his wisdom to heart and avoided the goto except for those instances where, properly documented, it is the best tool for the job.

    (By prophylactic prediction I mean the sort of warning or planning that completely forestalls the danger predicted, through awareness, preparation, etc. Kind of like the Y2K non-event.)

    --
    I'm here EdgeKeep Inc.
  3. Way to bury the lead by Chess_the_cat · · Score: 5, Insightful

    Headline should read "Thanks to Dijkstra's warning, GOTO in practice not harmful."

    --
    Support the First Amendment. Read at -1