Where Knowledge Rules

Computers & Technology:

Software

Get a Widget for this title

History of the 'goto' command

The "goto" command (strictly speaking it's a "keyword" and not a "command") first showed up in the original high level languages used on computers. These included Fortran and Cobol. To these were later added PL/1, Basic and many others. The keyword was necessary because it was often the only way to alter the flow of a program so that the program could "make a decision". For example:


IF value > 0 GOTO somewhere_else
do something
GOTO after_somewhere_else

somewhere_ else:
do something else

after_somewhere_else:
carry on doing things

This reflects the way computers actually worked at a low level - and they still work this way. At a low level, computers use instructions such as "jump fred" where "fred" is label attached to a piece of code elsewhere. When the first high level languages were designed it was only natural that this paradigm was carried over.

The major cost associated with a piece of software during its lifetime is not, however, the coding nor even the design. It is usually the testing/debugging and the through-life maintenance with the latter often accounting for over half. Because of this, ease of maintenance became a priority. Code with many "goto"s is not easily maintained - trying to trace the path taken through the code for a particular set of circumstances can be a nightmare. Even worse is trying to alter it without upsetting what happens in a different set of circumstances. This eventually led to the design of languages which had control constructs which did not exist on real computers - they were abstractions. These languages, such as Algol, Ada, C, are referred to as "block-structured". In a block-structured language, a typical (simplified!) way of making a decision is:

IF value > 0
BEGIN
do something
END
ELSE
BEGIN
do something else
END
END IF;

As far as I remember, the first language with a construct of this type was Algol 60 around (surprise, surprise :) 1960. Although Algol still had the "Goto", it's use rapidly became deprecated. Algol was followed by many block structured languages such as PL/1, CORAL 66, JOVIAL, C, Ada and Pascal. Some modern languages have been designed without "goto" - if done correctly, it is always possible to do what could have been done with a "goto" by using other control structures

Another driver of the move away from "goto" is the fact that an optimising compiler can do a much better job (i.e. create more efficient machine code) if there are no "goto"s present in the code. Modern compilers can then also take advantage of the pipelining present in current microprocessor designs so that repetitive operations (program loops) can run more efficiently: the whole loop can be held in the processor's instruction cache.

Learn more about this author, David Harris.
Contact this writer Click here to send this author comments or questions.


Below are the top articles rated and ranked by Helium members on:

History of the 'goto' command

  • 1 of 3

    by Lam Luu

    The discussion of goto command is, undoubtedly, among the most interesting discussion in early software engineering discipline.

    read more

  • 2 of 3

    by Kristopher Chambers

    Ever since the late 1970s, new programming students have been taught how to use a simple instruction called GOTO, yet are

    read more

  • 3 of 3

    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

    read more

Add your voice

Know something about History of the 'goto' command?
We want to hear your view. Write_penWrite now!

Helium Debate

Cast your vote!

Which is better, Windows Media Player 11 or Windows Media Player 10 and why?

Click for your side.

224344

Featured Partner

Society of Professional Journalists

The Society of Professional Journalists is the nation's most broad-based journalism organization, dedicated to encour...more

What is Helium? | Buy Web Content | Contact Us | Privacy | User agreement | DMCA | User Tools | Help | Community | Helium’s Official Blog | Link to Helium

Helium, Inc.
200 Brickstone Square Andover, MA 01810 USA