Go To Statement Considered Harmful

Citation: Dijkstra, E. W. (1968). Go To Statement Considered Harmful. Communications of the ACM, 11(3), 147-148.

Core Contribution

Argued that goto statements make programs harder to understand and reason about. Introduced the concept of structured programming — using sequence, selection (if/else), and iteration (while/for) as the only necessary control structures.

Key Claims

  1. The quality of a program is inversely related to the number of goto statements it contains
  2. goto makes it impossible to understand program flow (compute the number of paths through the code)
  3. Structured programming leads to programs that can be reasoned about mathematically
  4. Proved that any flow chart can be transformed into an equivalent structured program

Historical Context

  • Written as a letter to the ACM editor, not a formal paper
  • Sparked the “structured programming revolution”
  • Led to languages like Pascal (1970) that omitted goto entirely
  • Modern languages still have goto but it’s rarely used

Why It Matters

This paper established the foundational idea that program structure affects correctness. Before this, programs were often written as spaghetti code with arbitrary jumps. The insight that control-flow structure should mirror program logic is now obvious — but it was revolutionary in 1968.

Limitations

  • The argument was partly aesthetic and empirical, not formal
  • Some algorithms (exception handling, state machines) are awkward without goto
  • Modern exception mechanisms are essentially controlled goto

See Also