3 ms·
"GOTO considered harmful" is about a style of unstructured programming that was prevalent in its era. GOTOs are certainly not harmful on their own. But they of
by Jtsummers 11y ago
"GOTO considered harmful" is about a style of unstructured programming that was prevalent in its era.
GOTOs are certainly not harmful on their own. But they offer a power that leads to unmaintainable and unreasonable [0] code. Like the spaghetti mess that is callback hell today. Languages which offer structured constructs that are really just syntactic sugar over GOTOs are better [1]. Structured use of GOTOs are feasible. But it requires a discipline that is not found in the community at large. If you're responsible for any project involving more than yourself as the developer, you cannot assume that discipline is present.
With regard to assembly, yes, the branching and jumping instructions are the gotos Dijkstra was talking about. No, he wasn't wrong. The thing is, they have to be used in a disciplined manner or the outcome is extremely fragile code. Which was one of his biggest hobby horses. He viewed programming as a branch of mathematics. Where programs could be derived from first principles. GOTOs, as commonly used, necessarily broke that process. They also make it nigh impossible to understand poorly disciplined code. Same thing with magic numbers, weak type systems, and a number of other topics. They aren't bad on their own. They're bad when used in practice because they make undisciplined code trivial to produce.
[0] In the sense that the code cannot be reasoned about.
[1] In a strict sense, they're equivalent. In a less strict sense, they remove or minimize the ability to make unreasonable [0] code.