What programming approach was envisioned to eliminate the need for goto and avoid spaghetti code?

The story behind the answer

Structured programming was envisioned to eliminate the need for goto and help avoid spaghetti code.

Earlier programs often used goto to jump between labeled instructions. As programs grew, those jumps could make control flow tangled and difficult to read, giving rise to the “spaghetti” metaphor. Structured programming instead organizes execution around sequence, selection, and iteration, using constructs such as blocks, if statements, and loops.

The approach emerged in the 1960s. The 1966 Böhm–Jacopini result showed that programs can be expressed using structured control patterns, while Edsger Dijkstra’s influential 1968 letter, “Go To Statement Considered Harmful,” helped popularize opposition to unrestricted jumps. Languages including ALGOL, Pascal, Ada, and later Python and Java encouraged this style.

This does not mean every use of goto is automatically wrong. Some programmers, including Donald Knuth, argued that carefully chosen jumps can occasionally improve clarity or efficiency. The canonical answer, however, is structured programming: its central aim was to replace unnecessary goto-based control flow with clearer structure.

Source: Wikipedia · fact-checked Sept. 2026

Add question to a list

Choose a list to keep this question in: