Things Have History

software-architecture

The letter that killed the goto

Listen

In the autumn of 1967, over lunch at the ACM Conference on Operating System Principles in Gatlinburg, Tennessee, Edsger Dijkstra laid out to a small group of colleagues his case against a single programming instruction. The instruction was GO TO — the most primitive statement in any language of the day, doing nothing more than telling the machine to jump from one part of a program to another, unconditionally. His colleagues were persuaded. They urged him to write it up.

He did. The result appeared in the March 1968 issue of Communications of the ACM as a two-page letter to the editor. Dijkstra was a Dutch mathematician at Eindhoven University of Technology who had already made his name with shortest-path algorithms and operating-system theory. His argument here was simpler than either of those: GO TO destroys a programmer’s ability to reason about where a computation stands at any given moment. Follow enough arbitrary jumps through a program and you no longer have control flow — you have what programmers were beginning to call spaghetti. “The quality of programmers,” Dijkstra wrote, “is a decreasing function of the density of go to statements in the programs they produce.”

The math was already on his side. In 1966, Corrado Böhm and Giuseppe Jacopini had proved that any program containing arbitrary jumps could be rewritten without them, using only three constructs: sequences, selections, and loops. Every GO TO was, therefore, optional. Dijkstra’s letter made the aesthetic and cognitive case for making it illegal.

One detail the letter’s legend tends to skip: Dijkstra did not write “Go To Statement Considered Harmful.” He submitted the piece under the title “A Case Against the GO TO Statement” — precise and, in a Dutch way, slightly aggrieved. Niklaus Wirth, the ACM’s editor and himself a language designer of some note, liked the argument enough to rush it through as a letter rather than a full article, and in doing so quietly invented a new title. That phrase — “considered harmful” — went on to spawn at least 65 follow-on essays in computer science, each one borrowing Wirth’s construction to condemn something else. Donald Knuth noted with dry sympathy that computer scientist Eiichi Goto “cheerfully complained that he was always being eliminated.”

The response was not unanimous admiration. Programming journals lit up for five to ten years with heated letters, and Dijkstra received, by his own account, a torrent of abusive mail from programmers who regarded the GO TO as their birthright and resented the implication that their code was incoherent. The profession was under stress: the first NATO Software Engineering Conference, held that same October in Garmisch, Germany, had just named the “software crisis” — projects late, over budget, or cancelled outright. A two-page letter about a single keyword felt to some like academic quibbling. It was not. By the mid-1970s, structured programming was the assumed baseline of the field. By 1996, Java shipped without a goto statement — keeping the keyword reserved so no one could accidentally use it as a variable name, but giving it no meaning whatsoever.

A prohibition that started at a lunch table in Tennessee eventually rewrote what programmers understood themselves to be doing: not just issuing instructions to a machine, but constructing arguments that a human being could follow, step by step, without getting lost.

Sources