There are 3 articles on this title. You are reading the article ranked and rated #2 by Helium's members.
Ever since the late 1970s, new programming students have been taught how to use a simple instruction called GOTO, yet are told never to use it. When asked why, the usual responses given by teachers tend to range from "because I said so" to "because it is the standard industry practice," depending on the focus of the class or course.
GOTO is simple enough to understand. When a system encounters a GOTO instruction, it "jumps" from executing code at one part of the program, to executing code at a different part. The ability to do this is part of how computers are able to do more than function as advanced calculators. On the machine code level, GOTO is a fundamental part of all programs. Instructions to jump from one part of a program to another are executed over and over again, sometimes hundreds of times, to perform a single high-level program statement, so why is specifying this sort of jump at a higher level frowned upon?
The answer to this may be traced back to the earliest roots of modern programming languages. In the days of FORTRAN and COBOL, coding practice allowed free reign of GOTO statements. In fact, they were necessary to perform almost any form of useful program. However, as programs became longer and more complex, and multiple programmers had to work on maintaining them, programs that jumped from one place to another over and over again become a nightmare to maintain, improve, or even understand. The term "spaghetti code" was coined, as it reflected the way that program execution was threaded throughout vast piles of instructions, jumping throughout in a jumbled mess.
To combat this tendency of code to become unmanageable, newer practices were developed. These were based on stricter program structures, such as formally defined subroutines and functions with only one entrance and exit, and later still object oriented methods and classes. These could be followed easier than spaghetti code, and thus explicit GOTO statements fell into disuse, even though they were still permitted by the programming languages. In recent years, some programming languages, such as Java, do not even have this command, which was once the backbone of computing itself, and in languages that do support the command, it is looked down upon by many people who do not even know it's history.
Learn more about this author, Kristopher Chambers.
Click here to send this author comments or questions.
Below are the top articles rated and ranked by Helium members on:
by Lam Luu
The discussion of goto command is, undoubtedly, among the most interesting discussion in early software engineering discipline.
Ever since the late 1970s, new programming students have been taught how to use a simple instruction called GOTO, yet are
by David Harris
The "goto" command (strictly speaking it's a "keyword" and not a "command") first showed up in the original high level languages
Add your voice
Know something about History of the 'goto' command?
We want to hear your view.
Write now!
Cast your vote!
Click for your side.
Featured Partner
Charity Music is a nonprofit public service organization that loans musical instruments free of charge to individua...more
hide