2

What’s the difference between words cycle and loop in English? Why do we use loop in a programming and when do we use cycle?

2

Let me share my intuition. (I'm not going to quote any definitions in dictionaries in this answer. Also keep in mind that I'm a non-native speaker.)

Here is probably one of the best ways to think of the subtle differences between cycle and loop.

Imagine a "circle".

You have a circle in your mind now, right? Okay, that is a "loop".
A loop is basically a circle, or a round path. If you have a string and you tie the two ends together, you get a "loop". One important property of a loop is that it has no beginning and it has no end.

What about "cycle"? If you drag your finger along a circle, you will complete one "cycle" when your finger is back at the point where you started your dragging.

See, "loop" is a thing, a path that its end is its beginning and its beginning is its end;
while "cycle" is rather activity-like, like when we go along such a path or make/complete a cycle.

And because we can informally say either "my code loops through this loop" or "my code cycles through this loop", the real uses of the two words are kind of blended together. (You may want to use something else, such as "iterate", in formal writing.) Unsurprisingly, the two are interchangeable in some contexts, though most of the time, you wouldn't really want to use one in the place of another.


In programming, you'd want to write a loop, not a cycle, in your code ('cause a loop is a thing, while a cycle is an activity.) How many loops your code will run a loop would depend on the conditions in your code. When it runs, you may call "each time your code completes a loop" either a "loop" or a "cycle"; and you may want to call "each time your code completes its execution" either a "run" or a "cycle".

For example, let's say you're developing a game, and you've got a function named PrepareSkynet().
Let's assume that you write a for loop in your PrepareSkynet() to make 42 terminators.
You may say that your PrepareSkynet() runs the "make a terminator" for-loop 42 times.
You could also say that it does 42 "make a terminator" for-loops.
Or it loops the "make a terminator" for-loop 42 times.
You may as well say that your "make a terminator" for-loop runs 42 times, or 42 cycles.

See? It's rather flexible!

Hope you'll get the hang of it soon!

1

According to The New Hacker's Dictionary, both cycle and loop are used in computer programming. A cycle is usually very simple, such as:

  • The alternation of two states in flip-flop circuit (often used to establish a "clock cycle")
  • a "memory cycle"
  • Turning a system off and back on ("cycling" or "bouncing" a system).

Whereas a "for loop" can be arbitrarily complex, and execute over the course of many clock cycles.

In more general usage, there are some situations where "cycle" and "loop" can be used interchangeably. To the extent their meanings are different, "cycles" refer to regular phenomena, like the moving of a point around a circle. (Sinusoidal waves are cyclical in this sense.) Whereas "loops" can have various shapes, such as a dangling chain bracelet.

  • In addition, I think in cycles we have a little permission or ability to manipulate the process. However, in terms of loops, I think we can make better maneuver with more degree of freedom. Am right? – Cardinal Jun 19 '16 at 7:47
  • Thanks for explanations. However, as I see @Peter in his answer states that a cycle is bigger than a loop. Does it depend on programming or not programming context or why do we get a discrepancy here? – Ivan Yurchenko Jun 19 '16 at 9:00
  • I do know that, I meant we are more convenient in manipulation of the process – Cardinal Jun 19 '16 at 19:35
  • @Cardinal -- "have a little ability" is unclear. Do you mean "have the ability", or "have little ability"? – Jasper Jun 19 '16 at 19:39
  • Sorry, ! yes, have little ability. – Cardinal Jun 19 '16 at 19:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.