3 ms·
I've always thought that learning to follow GOTOs and GOSUBs was the key to understand assembly language. "GOTO considered harmful" is really what's considered
by dragonbonheur 10y ago
I've always thought that learning to follow GOTOs and GOSUBs was the key to understand assembly language. "GOTO considered harmful" is really what's considered harmful. I never take anyone who says "X considered harmful" seriously because of "GOTO considered harmful".
- Jtsummers 10y 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.
- sevensor 10y agoI agree -- the whole "considered harmful" meme is long overplayed. I don't even click on links with "considered harmful" in the title. The original point, which was that GOTO abuse was letting undisciplined programmers create impossible-to-follow control structures, was true in its time. I've seen some truly headache-inducing GOTOs in 1970s-era FORTRAN that involve jumping into the middle of loops and the like. But the modern point of view that rejects GOTO out of hand is just ignorant.