The Weary Travelers

A blog for computer scientists


Date: 2023-04-29
Author: Suhail
Suhail.png

A Case Against the Goto Statement

Dijkstra, Edsger W. “Letters to the editor: go to statement considered harmful.” Communications of the ACM 11.3 (1968): 147-148.

Conclusion

Goto statements ought not to be1 Equivalently: “oughtn’t be”, “should not be”, “shouldn’t be”. used in high-level programs.2The programs under Dijkstra’s consideration were imperative programs only.

Limitation and scope

The analysis applies to sequential processes where the order of evaluation matters. As such situations where the order of evaluation does not matter, e.g., “functionally pure” portions of an algorithm, the case against the Goto statement falls apart.

Reasoning structure

The paper shows that using the Goto statement comes at a cost. It claims that this cost is significant.

Details

  • Claims: the sequential execution (process) of a program is the main thing of interest. The program is a means to this end.
  • Claims: given a stage in a sequential process it is important to know what has happened and what hasn’t yet happened.
  • Shows: given a Goto program3A program using the Goto statement. and coordinates4 Here a coordinate is some combination of grounding of terms that are manifested in the program text (e.g., line 23; [line 21, line 56, line 14]; [line 23, i=10, line 26]). corresponding to two process states it is not possible to know which state is before the other.

Historical tidbit

Per Wikipedia:

Considered harmful was popularized among computer scientists by Edsger Dijkstra’s letter “Go To Statement Considered Harmful”,[3]​[4]​ published in the March 1968 Communications of the ACM (CACM), in which he criticized the excessive use of the GOTO statement in programming languages of the day and advocated structured programming instead.[5]​ The original title of the letter, as submitted to CACM, was “A Case Against the Goto Statement”, but CACM editor Niklaus Wirth changed the title to “Go To Statement Considered Harmful”.[6]​ Regarding this new title, Donald Knuth quipped that “Dr. Goto cheerfully complained that he was always being eliminated.”[7]​

Frank Rubin published a criticism of Dijkstra’s letter in the March 1987 CACM where it appeared under the title “‘GOTO Considered Harmful’ Considered Harmful”.[8]​ The May 1987 CACM printed further replies, both for and against, under the title “’”GOTO Considered Harmful“ Considered Harmful’ Considered Harmful?”.[9]​ Dijkstra’s own response to this controversy was titled On a Somewhat Disappointing Correspondence.[10]​

Comments

Comments can be left on twitter, mastodon, as well as below, so have at it.

To view the Giscus comment thread, enable Giscus and GitHub’s JavaScript or navigate to the specific discussion on Github.

Footnotes:

1

Equivalently: “oughtn’t be”, “should not be”, “shouldn’t be”.

2

The programs under Dijkstra’s consideration were imperative programs only.

3

A program using the Goto statement.

4

Here a coordinate is some combination of grounding of terms that are manifested in the program text (e.g., line 23; [line 21, line 56, line 14]; [line 23, i=10, line 26]).