The Evilness of goto
I was hoping this post wasn’t going to be needed, but the nasty little monster has reared his ugly diminutive head. Allow the following image from xkcd to elaborate on this.

Now for the why. Goto is a means of directing a programs flow by forcing it to jump from one point to another. While this ability itself is a good thing, this method of doing so isn’t anymore. It used to be that goto was the only means for a programmer to move from one section of code to another but as time went by, it was discovered that the goto statement was really cumbersome. It has no inherent control over when it executed leaving the programmer no choice but to create tons of control code around the statement.
Let’s look at an example. Say we want a bit of code to execute 10 times. As a goto statement it can look like this:
int counter = 0;
begin:
cout << "I'm repetitive!\n";
counter++;
if (counter < 10)
goto begin;
Because programmers were wasting time creating these structures to handle a very trivial matter such as this over and over again, and then deciphering it again when maintenance time came, loops were created. Let’s take a look at that very same code as a for loop.
for (int counter = 0; counter < 10; counter++)
cout << "I'm repetitive!\n";
Doesn’t that look much nicer? Only two lines (compared to 6) of code here and all of the loop control is grouped into one spot (line 1 as opposed to lines 1, 2, 4, 5, 6). While both of these sets of code do the same thing, the second is much easier to create, read, and maintain. Those last two points are the important ones.
Code creation is easy. You sit down with a plan of what the program is going to do and hammer it out. But then 10 months down the road someone is going to decide that the program needs some small minor change. Now if you were the one to make the change, which set of code would you rather look at? The one that consists of 12000 lines or 4000 lines? Goto is a thing of the past and serves no purpose in you code right now. It has been replaced.
1st.
Good thing I had no idea how to use it.
GOTO end;
Not only an explanation–but a cartoon! You go the extra mile
I can use this at work! It is just as true in RPG as C++ and I suspect most if not all languages!! Goto’s create a maintenance nightmare!