Loop

In computer terms, a loop is defined as a series of commands that is performed repeatedly until a set of conditions are met.

The commands within the loop itself may result in meeting the conditions after a certain number of repetitions or may require the influence of an external factor. For example if the loop states that the computer will go to sleep or on standby mode after 10 minutes without anyone using it, then without anyone having to do anything the computer will start counting up to ten minutes and can use a loop to check on the state by asking itself, “How many minutes has passed without the computer being used?”

As long as the answer is not 10 minutes, the computer will keep on asking that question or performing a loop and as soon as the condition is satisfied (10 minutes reached) then the loop will execute a command, in this case put the computer on standby mode, and the loop will stop.

In some cases, a computer performs what we call an infinite loop. The infinite loop, as the name indicates, is a series of commands that never stop. This is a result of having either a condition that can never be met or having an end command, when the condition is finally met, that ends up starting the entire series of commands all over again.

Infinite loops are notorious for making computer systems “hang” or “freeze”, which is why programmers are always on the lookout for bugs in their program that could unexpectedly cause a certain portion to go on an infinite loop. However, although infinite loops have become synonymous to programming errors for non-programmers, they are actually used by programmers routinely.