Submitted by Dacadey t3_z89cro in explainlikeimfive
pdpi t1_iyckqgh wrote
GOTO is one of a handful of really fundamental, core concepts in programming, you basically can’t achieve anything useful without it. The flip side to that is that, because you need GOTO for everything, you need to read a lot of the surrounding code to understand what, exactly, you’re trying to achieve.
As it turns out, there’s a small handful of uses (if/else, while, for, try/catch, function calls) that completely dominate compared to everything else. Instead of a goto that can mean anything, you can use one of those language constructs instead and say exactly what you mean (this is also why most languages are slowly adopting for x in list
, because it’s the most common usage pattern for for loops). This is easier to read, it’s less error prone (because the compiler/interpreter can handle all the setup and cleanup chores for you).
People do forget that there is a long tail of legitimate use cases for goto, though, which is a bit of a shame.
Viewing a single comment thread. View all comments