The History of the For Loop

As everybody knows (or should if they don't), a For Loop is a statement in programming languages that allow you to iterate (repeat) a body of statements. That's what a loop is (repeating a body of statements).

There are three common loops: For Loop, While Loop, and GoTo Loop. Some folks don't like GoTo loops (because of all the spaghetti it might make).


And so the For Loop is the most common of the three. The For Loop repeats for a certain number of times (for example, 6 times). Because that number can be a variable, your user can specify it. In other words, they can type "9" in your program, and then your For loop can read that variable and repeat 9 times.

A For loop repeats something FOR a certain number of times! You get it? You get where the "For" came from? Excellent! Moving on...

Read about how to create For Loops in Small Basic here: Small Basic: How to Create For Loops


And so that brings us to the question...


Where did For Loops come from?


Well, there were originally three different perspectives on looping a body of code a set number of times...

  1. FORTRAN - Fathered the Do Loop
  2. ALGOL - Fathered the For Loop
  3. COBOL - Mothered the "Perform Varying" loop


Although ALGOL is the least recognized of the three languages, it's the one that won the "Loop Nomenclature War" and got to decide the term we use the most today... the For Loop.

Now, part of the reason why it won and also why it isn't as recognizable as a language is because it came last of the three (chronologically). So it didn't have quite as big of an impact on programming (being a bit of a copy of what was out there), but it also had the chance to think through some key improvements. And Fortran and Cobol have found long lives as they continue to wiggle down their business paths.

See how I used "Mothered" for COBOL and not the others? See what I did there? Well, as you read below, let's just say you'll start to have some "Grace" with my puns.



FORTRAN stands for FORmula TRANslating System and was started in 1953 by John Backus at IBM, in New York (the compiler was released in 1957). It was created as an assembly language for their shiny, new (and huge) IBM 704 mainframe computer (more like a whole room by itself). (NASA bought some of these bad boys in the 50s.) It borrowed heavily from the GEORGE compiler of 1952.

It included a bunch of programming concepts we still use today, like If, GoTo, Read, and Print. It also helped popularize loops with the Do Loop.

Read more about how to program Do Loops here:



Enter Grace Hopper, a United States Navy rear admiral (commodore). She was one of the first programmers of the Harvard Mark I computer in 1944! She invented the first compiler, she popularized machine-independent programming languages, and she even started the phrase "debugging" when she physically removed an actual moth from a computer! She even got the US Navy Destroyer USS Hopper named after her! That's why they called her "Amazing Grace"!

Well, in 1943, Amazing Grace joined the US Navy Reserves, aced school and went to work at Harvard, where she was one of the first programmers on the Harvard Mark I. In 1949 through 54, she went to work at Eckert-Mauchly Computer Corporation, where she helped invent the UNIVAC I, the first compiler, MATH-MATIC, and FLOW-MATIC.

Then, in 1959, the Navy funded her to get together a group of programmers (CODASYL), and together they masterminded COBOL (from Grace's FLOW-MATIC and IBM's COMTRAN). Also, Amazing Grace staffed most of this team, so she pretty much (grand)mothered it in!

COBOL stands for COmmon Business-Oriented Language.

Being an assembly language, it has a more complicated take on iterative loops (thus the use of "Perform Varying"). Some people think that 80% of the code in the world is COBOL and it powers the world or something crazy like that. Personally, I prefer using midi-chlorians.



ALGOL stands for ALGOrithmetic Language. It was developed by a committee of American and European scientists who met in Zurich in 1958. A key contributor was (you guessed it) John Backus!

Backus is back (us)!

One member of that committee was Heinz Rutishuaser, who brought in some elements of his Superplan language, including the Für loop, which they renamed to the For Loop in English. They also used the Step and Until delimiters.


So there you go! That's a shotgun blast of programming history.

Leave a comment to help add some info to this rich history!


And click here to learn about how Small Basic does For Loops: Small Basic: How to Create For Loops

- Ninja Ed


See Also

Comments (8)
  1. Fixed a typo on "Navy"

  2. Colin says:

    Why is it called the 'for' loop?  Any idea?

  3. Colin, it will loop for X many times.

    That got condensed into "For X Times"

  4. Computers Today (part 1 of 6)…/computers-today.aspx


    CS SPOTLIGHT: Girls in computer programming… why it matters!!!…/cs-spotlight-girls-in-computer-programming-why-it-matters.aspx

    Computational Thinking – Videos & Papers by Jeannette Wing…/computational-thinking-videos-amp-papers-by-jeannette-wing.aspx

  5. UPDATE: I added a bit about why the word "For" is used:

    "A For loop repeats something FOR a certain number of times! You get it? You get where the "For" came from? Excellent! Moving on…"

  6. UPDATE: Added the See Also links.

  7. Milan Josipovic says:

    Hi 🙂 great story.
    I have a question so you maybe can help me.
    What are the mathematical roots of the For Loop, where did it came from?
    Is there a connection with Basel Problem and Euler’s solution of the same?
    Well, the last question is the most interesting for me.
    I wish you all the best 🙂

    1. Milan, do you mean specifically the implementation of the For loop in ALGOL?

      I was going to refer to it as “the ALGOL language,” but I can’t, because the “L” stands for “Language.” It would be like saying the “Algorithmetic Language” language. That would be weird.

Comments are closed.

Skip to main content