Goto - Criticism and Decline

Criticism and Decline

The 1960s and 1970s saw computer scientists move away from GOTO statements in favor of the "structured programming" paradigm. Some programming style coding standards, for example MISRA C and the Gnu Pascal Coding Standards, prohibit use of GOTO statements, particularly in view of the aforementioned structured program theorem. The Böhm-Jacopini proof did not settle the question of whether to adopt structured programming for software development, partly because the construction was more likely to obscure a program than to improve it. It has, however, sparked a prominent debate among computer scientists, educators, language designers and application programmers that saw a slow but steady shift away from the formerly ubiquitous use of the GOTO. Probably the most famous criticism of GOTO is a 1968 letter by Edsger Dijkstra called Go To Statement Considered Harmful. In that letter Dijkstra argued that unrestricted GOTO statements should be abolished from higher-level languages because they complicated the task of analyzing and verifying the correctness of programs (particularly those involving loops). An alternative viewpoint is presented in Donald Knuth's Structured Programming with go to Statements which analyzes many common programming tasks and finds that in some of them GOTO is the optimal language construct to use. Some programmers, such as Linux Kernel designer and coder Linus Torvalds or software engineer and book author Steve McConnell, also object to Dijkstra's point of view, stating that GOTOs can be a useful language feature, improving program speed, size and code clearness, but only when used in a sensible way by a comparably sensible programmer.

The viewpoint that use of GOTO is sometimes undesirable is evident in the design of some programming languages, for instance Ada visually emphasizes label definitions using angle brackets.

Fortran introduced structured programming constructs in 1978 and in successive revisions the relatively loose semantic rules governing the allowable use of goto were tightened; the "extended range" in which a programmer could use a GOTO to enter and leave a still-executing DO loop was removed from the language in 1978, and by 1995 several of forms of Fortran GOTO, including the Computed GOTO and the Assigned GOTO, had been deleted from the language. Some widely used modern programming languages, such as Java and Python lack the GOTO statement, though most provide some means of breaking out of a selection, or either breaking out of or moving on to the next step of an iteration.

An example of why GOTO can be dangerous.

E.g.:

#include int main(void) { if(1) { printf("HELLO"); goto A; } else { A: printf(" WIKIPEDIA\n"); } return 0; }

The above program compiles fine and provides the output HELLO WIKIPEDIA. But, the concept of if-else (Conditional (programming)) is completely ignored here with the usage of GOTO.

Read more about this topic:  Goto

Famous quotes containing the words criticism and/or decline:

    Parents sometimes feel that if they don’t criticize their child, their child will never learn. Criticism doesn’t make people want to change; it makes them defensive.
    Laurence Steinberg (20th century)

    Our achievements speak for themselves. What we have to keep track of are our failures, discouragements, and doubts. We tend to forget the past difficulties, the many false starts, and the painful groping. We see our past achievements as the end result of a clean forward thrust, and our present difficulties as signs of decline and decay.
    Eric Hoffer (1902–1983)