ID:193795
 
goto hell

Although most people think that hell is the bad word of the 2 listed above any talented programmer will tell you that the other one is much worse.
Theodis wrote:
goto hell

Although most people think that hell is the bad word of the 2 listed above any talented programmer will tell you that the other one is much worse.

Heh, yes, definitely.
Theodis wrote:
goto hell

Although most people think that hell is the bad word of the 2 listed above any talented programmer will tell you that the other one is much worse.

hmm... why is goto so bad? i used to use it all the time in qbasic, i never had any problems to make it worse than the under world... now, if you need a bad word, take um... well... eh... whileloop... er something...
Theodis wrote:
goto hell

Although most people think that hell is the bad word of the 2 listed above any talented programmer will tell you that the other one is much worse.

Heh. Although I grew up on BASIC, then switched to C many years ago, I think goto gets a bad rap. Top-down programming has achieved a kind of snobbery about goto, but the simple fact is that the goto statement is embedded into machine code; it lies behind all if statements, all elses, all short-circuited ors and ands, all switches, all while and do-while loops, and for loops, break and continue, and the control statements of other languages--some of which differ, but mostly follow the same basic set of structures.

Now here's the interesting thing: I have yet to see a language that includes the full set of high-level structures needed to efficiently replace goto. There are just some situations where it's necessary.

For example: In C, it is often necessary within a nested loop to break out of more than one loop at once. C has no statement capable of this (except return, which doesn't cover every situation), so either goto or some complicated variable mechanics must suffice.

Another example: While loops (used internally to construct for loops) are basically constructed as an if (to skip ahead if a test fails), a block of code, and a goto to return to the if. The problem with this is that modern processors use look-ahead instruction fetching, and a lot of extra jumps in the code throw them off; while loops have two jumps, not just the one conditional. Programmers out to optimize for every last ounce of speed practice a technique called "loop flipping", which some compilers can do automatically but most don't. The idea is to rearrange this as a do-while with a goto in front: A jump, the block of code, and then the if--which jumps back to the block of code if the condition is met. The first jump goes right to this if, skipping the block of code within the loop. Loop flipping is most feasibly accomplished with a goto; if you flip your loops manually, you need to use a goto or an if that uses the same condition test as the loop, and the if may be quite complicated. Goto is essential to do this the least bit elegantly.

Now, the real problem with goto is that it makes code less readable. Fully appreciated. Should it be avoided in favor of higher-level constructs? Whenever feasible, yes. Should it be eschewed completely? Definitely not. The truly talented programmer knows the use of goto, and uses it only where appropriate; sometimes the simplest tool really is the best.
And in closing, I'd just like to add that "goto" is not an English word at all, but a bad concatenation of two words. :)

Lummox JR
In response to Lummox JR
Well if you wanna get technical most assemblers use some variation of the word jump not goto :). And unless you're working on a core piece of code that is ran thousands of times per second, it's best to sacrifice speed for readability. Also if it is a core piece of code that is run a large amount of times in a small amount of time it's best to write the code in assembly anyway.