In yesterday’s post I named the “GoTo” statement as basically a bad thing. To my surprise this started a short Twitter discussion and also came up in the comments. So I did a bit more research. I found this fairly balanced article called “Using gotos” by Steve McConnell. And Mark Guzdial twittered a link to an older post he wrote titled “Plea to Language Designers: Bring Back GoTo!” Wikipedia also covers the issue fairly well with a bunch of external links. So clearly there are multiple sides in this issue. I made the comment in Twitter that this issue is far from settled science.
By settled science I mean that there is still a lot of discussion going on. Arguably there are cases where GoTo statements have a place. One of the things that Mark Guzdial pointed out in twitter “When non-programmers define processes, they use goto’s. GoTo is natural.” There is a lot of truth there. Of course one could argue either for or against what is “natural” and people do. Another thing to concider is how an understanding of GoTo helps with understanding other concepts. Ian Bogost (@ibogost)Twittered “GOTO made understanding machine branches easy.” Let’s face it most assembly languages could not function without the equivalent of a GoTo statement!
Most programming languages do include a GoTo statement of some form. Why? Well the discussion comes up every time and people ultimately decide to include it and yet at the same time hope people will not use it. Even the venerable Programming Proverb 7 says “Avoid unnecessary GOTO’s” and not avoid all use of the GOTO. I suspect that this is a debate that will go on for ever. Not that there is anything wrong with that. I think I learn something new every time it comes up.