Go To Statement Considered Harmful(1968)
August 26, 2023Edgar Djkstra criticized the excessive use of the go to statement in Go To Statement Considered Harmful. While the source code is static, the process taking place under the control of the source code is dynamic. The programmers should aim to shorten the conceptual gap between the source code and its process to describe the progress.
Let us characterize the progress of a process. If there are no procedures and repetition clauses, we can characterize the progress by a pointer to a suitable step in the source code. With the inclusion of procedures, we need a sequence of pointers. The length of this sequence equals to the dynamic depth of procedure calling.
With the inclusion of procedures, pointers are no longer sufficient to describe the dynamic progress of the process. With each entry into a repetition clause, we need a counter that denotes the corresponding current repetition. The pointers and the counters provide independent coordinates in which to describe the progress of the process. The excessive use of the go to statement makes it hard to find a meaningful set of the coordinates.
Remark
While “Go To Statement Considered Harmful” became the iconic opponent of go to statement, it does not describe why the go to statement makes it hard to find a meaningful set of pointers and counters that describe the progress of a process.