Goto in basic. Goto in fortran. goto in Algol. Goto in PL/1. Goto even in the old RPG language. Goto in most every language I have ever used. All can be used to write clean code. And all can be misused to write code that is very hard to follow. Much of my programming over the years has been in various assembly languages where the goto (jump/branch/whatever) instruction is ALL you get for any sort of control structures. I have seen marvelously clean assembly code. I have seen marvelously convoluted assembly code. All depends on the programmer's skills...syzygy wrote:I fully agree that Dijkstra's article has to be understood against the background of the coding practices of that time (1968). But he was probably not thinking very much about BASIC (which is from 1964 and was probably hardly used for serious programming).Ras wrote:Goto is a perfectly fine tool - and like any tool, it can be misused. The goto aversion stems from a Dijkstra article in the 1960s, but that referred to the goto in Basic. That was another beast because it was using fixed line numbers as jump targets, which quickly could become a maintenance nightmare once you inserted additional instructions somewhere.
http://koblents.com/Ches/Links/Month-Ma ... rnel-Code/Goto usually should not be used in regular control flow, and it should only be forward goto. For error handling in C, goto is much nicer than nested ifs. As soon as you have more than one thing to clean up, nested ifs also entail code duplication. That's why goto is used in the Linux kernel.
(The guy who started that thread also suggested that the Linux code was of questionable quality given the many patches coming in.)
This thread is an example of poor programming that leads to convoluted code due to pedantic reasons such as objecting to the use of a goto (break) which makes the code much easier to read than the ugly do/white syntax proposed...
The people that developed these languages (Thompson, Kernighan, Ritchie for C) were pretty bright. While C is far from perfect, the do/while is not a good example of something that was done poorly.