3 ms·
Yeah the GOTO got a bad rap, if someone used it wrong it would have unpredicted results by goting to the wrong part of the program. It confused beginners so it
by orionblastar 11y ago
Yeah the GOTO got a bad rap, if someone used it wrong it would have unpredicted results by goting to the wrong part of the program. It confused beginners so it was to be avoided.
People forgot that any language gets converted into assembly language and it has JMP or JUMP statements in them that basically do the same thing as a GOTO in a higher level language.
I wrote Visual BASIC 6.0 code and in order to trap errors we had a On Error Goto ErrorHandler: where we had an error handling routine that would do a customized message box to give the user more information on the error and prevent the program from ending. I would give recruiters samples of my VB code and it had On Error Goto and they saw the Goto and told me I shouldn't be using it.
VB.Net did away with Gotos and did the try/catch borrowed from Java to catch errors.
I remember learning Ada in 1989 and it used Goto statements as well. Modern Ada avoids Goto statements.
Programming without using Goto is harder and in some cases needs more lines of code.
There was never any real evidence that Goto was harmful, as the article states people accepted it was harmful without any proof. The decisions to not use Goto was decided by managers with no real world programming experience.
- efaref 11y ago"GOTO considered harmful" needs to be read in its historical context, where structured programming (for loops, while loops, functions) were new-fangled and under-used. Dijsktra was not arguing against GOTO per se, but rather against unstructured programming. Using GOTO to implement structured programming constructs that did not exist in the language (e.g. JMP in asm) is fine.