[History] An editor letter by Edsger Dijkstra, titled: "go to statements considered harmful" (march 1968).

abbadon420@lemm.ee to Programming@programming.dev – 99 points –
Letters to the editor: go to statement considered harmful | Communications of the ACM
dl.acm.org

In this letter, Dijkstra talks about readability and maintainability in a time where those topics were rarely talked about (1968). This letter was one of the main causes why modern programmers don't have to trouble themselves with goto statements. Older languages like Java and C# still have a (discouraged) goto statement, because they (mindlessly) copied it from C, which (mindlessly) copied it from Assembly, but more modern languages like Swift and Kotlin don't even have a goto statement anymore.

42

You are viewing a single comment

And yet it's still easy to write spaghetti code in Java. Just abuse inheritance. Where is this function implemented? No one knows but the compiler!

And don't forget to use miracle sort for any sorting needs you have. Why do the work yourself when you can just hope it gets solved for you?!

That doesn't make it spaghetti code though. In well-written OOP code you shouldn't care where a function is implemented. The problem is a much too high level of abstraction. If your high level code is so abstract that it is only running tasks and handling messages there's no way to write it in a way that prevents mistakes because you couldn't possibly know what the actual implementations do.