Origins of the for loop

Where did the for loop come from?

ALGOL 58 introduced a for statement of the form:

for i := base (increment) limit

This closely resembled a loop structure in Rutishauser’s programming language Superplan, developed in the early 1950s. His loop used “=” instead of “:=”, and the German keyword Für in place of for. Algol 60 modified this slightly, replacing the parentheses with keywords:

for i := base step increment until limit do
...
end

Fortran I went another route instead of the for loop: do. The functionality was the same, but it might have evolved this way to differentiate it from Algol58.

    do 10 i = base, limit, step
10  statement

After the early years, many languages adopted the use of either of these renditions. BASIC adopted for, PL/I adopted do, and COBOL created it’s own variant using the keyword PERFORM. By 1970, the for loop had become the norm, edging out do. C, Pascal, and Ada all adopted some variant of the for loop.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s