Showing results for 
Search instead for 
Did you mean: 
Create Post

Day 11 - Loop

Loops are among the most sublime constructs of programming, but as it turns out, often consume our personal lives as well. Whether baked into the silicon of routing ASICs or beautifully parallelized in Go, loops are the mechanism by which we say, “Yes machine you’re done, now do it again”. Loops tirelessly execute routine business logic, evaluate access control policies, they ensure our backups happen on schedule and they pull resources in and out of production to suit demand. But we forget that they are also a metaphor, endlessly iterating, endlessly reminding us as their keepers, not to fall into life-wasting loops of our own.

Consider three loop patterns, in BASIC, Java and Go:

140 LET X = INT(100*RND(0)+1)
150 LET N = 0
180 LET N = N+1
190 IF G = X THEN 300
200 IF G < X THEN 250
220 GOTO 160
// print the integers 10-19
for(int x = 10; x < 20; x = x + 1) {
         "value of x : " + x );
func main() {
  for {
    test := statusNow()
    if test == 10 {
    if test == 5 {

    time.Sleep(300 * time.Millisecond)

At first glance, they are the same: keep doing something until a condition is met. However these aren’t the same, not one bit, and they tell the human stories of their creators. Left-to-right, you might think of them as Get Out Fast, Deterministic, and Eventual Exit.

GOTO: Chaos Classic

In the case of BASIC, this loop expects to get out or at least is in the habit of falling-through. BASIC is like most languages of yore, procedural. It has first and last line, a beginning and an end, and all loops must end or the process can’t exit. GOTO came after conditionals, a mechanism to redirect the falling momentum of top-down execution. But it’s branch exception based on one particular condition- anything else and the process falls through. It’s also not technically a loop in the modern sense, GOTOs can go anywhere and the loop is actually a pattern not an operator.

The human equivalent of the BASIC GOTO loop is an interrupt driven life. You’re heading with determination in a direction, but issues pop-up and you have to go back to fix them. It’s two steps forward, one step back. In many ways it’s actually the most hopeful because it rewards tenacity, eventually leading to progress or transition. It’s also the diametric opposite is the For-Next Loop.

For-Next: Precision Planning

Say what you will about strongly typed languages, but the stalwart For-Next loop in Java, C# and others will save you debugging pain. While it’s possible to mess with the iterator or otherwise engage in continue/break shenanigans, for is used because it’s deterministic. The code will execute precisely a known number of times only. At it’s most extreme it’s the human analog of a prison sentence, or at least week, semester, year or similar conventions.

There’s a certainty about For-Next- awareness of initial commitment and start conditions and it’s iterators provide feedback along the way that guides us to conclusion. Why is Friday great? Because the next value in the day iterator is Saturday. We use these loops as technologists to accomplish life change, or at least to provide time scaffolding to hang other milestones of personal development. With For-Next we know what we’re getting into, even it’s a bit routine along the way.

While: Seductive, Soporific, Insidious

while then must be the ideal use of a computer, the ultimate hands-off delegation to automation. It’s an expectation that a thing will continue open-ended. In the GoLang example above for { may look like For-Next, but it’s not. No condition is being evaluated each loop- there’s no iterator. It just spins, printing integers to the console with a 300ms nap each pass. It continues or breaks on unrelated if’s. In other languages while contains a condition for escape, but not here. This use is the inescapable, even dreadful, while(true).

OS message and event loops are canonical monster examples, expecting to run without interruption until shutdown. The while loop’s momentum is not to run to a terminus like BASIC, and it’s also not deterministic like For-Next. while expects not to progress unless something exceptional happens. Its human analog literally, is to “while (wile) away your time”.

And in this time of IT transformation, failing to recognize one is trapped in a while is increasingly perilous. When I hear Ops teams say things like, “I guess this job is OK”, “Meh, SDN won’t affect me”, or “The datacenter will never go away”, I ask them what their day-to-day is like. Almost all fall into a narrow pattern of help desk misery, systemic underinvestment, nervousness about the future and lack of time for personal skills development. For them while is innocent enough- it’s emotional compensation to get though each day hoping there’s something out on the horizon.

Some in IT even subconsciously wait for radically new hardware, a layoff, re-org, or family relocation- anything that will force a major job change because they’re stuck. Usually in the past it’s worked out, but fortune without development is less guaranteed each year. Cloud and DevOps are brining unique changes that require significant skills upgrades. Many IT Jobs- at least the ones that will be interesting and rewarding- won’t be network configuration or application debugging. They’ll be something more. Something architectural, something analytical, something less expert and more inventive.

GOTO: Neurons

Perhaps there’s irony in the BASIC example above. It’s old, limited and even in its agnostic Integer BASIC form terrifically uncool. But just perhaps, it might be the most compatible with our human, wet-CPU processors. Perhaps living a life of interconnected pointers and evolving spaghetti code in the wonderful synaptic sense offers the most resiliency, captures the most opportunities, and breaks away in the most important top-right quadrant of human endeavor: fun.

Beware settling for while. It’s process interrupts are usually unexpected.

Level 10

Very succinct. Sometimes it feels like every day is a loop where I come into work and try to add a metaphorical line for the next day, get to the weekend. A few of those and the script for the year gets worked on and everything progresses nicely... Until I get to the festive season and suddenly I look up and realise there were bits I meant to implement! Next year, fresh script right? I'll put them in the next version.

In this fashion, I've so very easily spent a lot of time wishing for the next line, the next thing, the next major Event. Where what I needed to do was to write myself some new material for the next lines, actually change things up and write what I want to write. In a funny way, that's exactly how I came to be writing this post.

Level 17


I'm not a good cook, but that doesn't mean I can't appreciate a great meal.

Equally, by any reasonable definition of the word, I am not a programmer. In interviews, my standard line is that "nobody will ever weep with joy at the beauty of my code. The most complimentary thing anyone has ever said was 'well, it RAN...'".

But that doesn't mean I can't appreciate great code when I see it.

For as long as I have understood the difference between a macro and true programming, I have been entranced with what is usually assigned to programming 101 students: write a program that generates a fibonacci sequence, but only uses a single variable.

A fibonacci sequence is relatively easy to do when you have TWO variables to work with. But one? When I first heard of this, my mind boggled.

Then my friend and mentor Doug (@dugjohnson) showed me the answer, and my mind was opened to the elegant, delicate, ineffable beauty of code.

int Fibonacci (int x){

if (x<=1) {

return 1;


return Fibonacci (x-1)+Fibonacci (x-2);}

The solution to the problem of using a single variable is recursion.

The above code, broken out, ends up as:


= Fibonacci(3) + Fibonacci(2)

= (Fibonacci(2) + Fibonacci(1)) + (Fibonacci(1) + Fibonacci(0))

= ((Fibonacci(1) + Fibonacci(0)) + 1) + (1 + 1)

= ((1 + 1) + 1) + 2

= (2 + 1) + 2

= 3 + 2

= 5

A single variable (how many iterations of the fibonacci sequence to run) and the program winds itself up and spins itself out again leaving numbers in its wake, until a single answer is found.

In my more poetic moments, this is not unlike our lives (or parts of them).

  • We "wind ourselves up" - preparation, study, planning, executing, reacting, adapting;
  • And then we spin ourselves out again - reflecting, learning, growing, changing, and improving.

With luck, grace, support, and love in our lives this can be a lifelong process, like water along a beach:  constantly in motion, multiple waves at any given time, inexorably reshaping the earth. Over and over and over again.

Level 13

"Winds itself up, and spits itself out" might be the best emotional description of recursion I've ever seen. Yin and Yang, fearless re-use of deterministic code blocks, and in Node.js, some real tension of nested callbacks. Thanks for sharing that.

Level 10

Nested loop, for loop, while loop, ........

Love and hate coding!

Level 11

I am just getting ready to use NCM and I am very thankful for loops.

Level 12

Looping in the wind.

Level 9

Life is a loop, if you wait long enough everything comes back around.


I think we all find ourselves feeling like we're in a loop at some point. As others have mentioned, the daily grind can feel repetitive (hence "grind"); wake up, go to work, come home, repeat. Especially when you have a big project, working long hours, the days seem to roll on by. It comes down to how you break the loop in a positive way.

Level 9


Check out more here: Bees & Bombs

Level 9

Ugh, today's kids are forgetting the old-fashioned art of absentmindedly reading the same half-page of a book over and over and then letting your attention wander and picking up another book.

Level 14

Are you in the loop? Sometimes yes, sometimes no!

Like Leon .... the best thing anyone ever said of any code/script I authored is " it ran!"

Loops have value, they ensure we take into account every piece of data presented. Loops appear to be simple, but are and can be extremely complex.

Loop... or revolution.   Makes me think of this line from the Steven Segal "classic" Under Siege.

Tom Breaker: Look, Bill, if this is about reliving the 60's, you can forget about it, buddy. The movement is dead.

William Strannix: Yes, of course! Hence the name: movement. It moves a certain distance, then it stops, you see? A revolution gets its name by always coming back around in your face. You tried to kill me you son of a [female dog].. so welcome to the revolution.

Level 9

I think everyday is a loop for me.  My tasks may be a little different, but my routine is almost the same.  I don't think we were meant to do repetitive task.  Looping numbs us and keeps out new thoughts and innovations.

Level 15

I agree with shaneo​ it does appear that things come back around.   The loop in life is that we see styles loop back in to fashion, movies loop back as remakes, and not always for the better, and in IT the long trend was outsource vs in house.   That is a loop that might be changed forever.   With the strong foothold Cloud, virtualization, SAAS, PAAS, IoT, and everything else the lines are blurred now.   I am not sure That we will ever see a need to clearly define the roles as we once did.   Diversity, and the ability to be flexible in all things appears to be the best approach to ensure we do not become an unneeded resource.   Agility in our skill sets, in our career path, and in our view on IT will drive IT to the next level.   Things will always loop back around but the way they look will be different going forward.  

While in software coding a loop is consistent, life has a much outcome each time. 

Level 9

Working on a help desk I would occasionally get someone who could only describe their issue as a, "do loop" knowing fully well they weren't a programmer of any kind. To me these were the worst kinds of calls due to the person always felt they knew what they were talking about and aways fought everything you said, making the call run long, thus creating a "do loop" for their issue.

Level 13



The best example of a loop I can think of is Groundhog Day.  Keep doing something over and over until the desired result is achieved. 

Like the saying.  The definition of insanity is doing the same thing over and over and expecting different results.  The loop continues until you try / do something different.  Once you find out what it takes to get out of the loop, you are allowed to move on.

Level 10

While life might feel like an endless loop, be sure to grab onto those moments that stand out. As Tom Chochrane sang in Washed Away, "Round and round and round we go, Where it stops don't no one know, If you find a love you better let 'em know, Or you both get washed away."


My introduction to coding was with early BASIC. Now I'm not a coder, but I get it - I even taught High School students "Structured BASIC" for several years. I remember clearly code was broken down into routines and sub-routines. When I hear the word loop I think of routine. Some routines (loops) are good as they keep us on track - having a consistent bed and rise time are good (although often impossible in IT) having a routine of brushing your teeth is also good. Sometimes, however, routines either cause us to just move along for the ride or worse yet deteriorate.

How many times have you met couples that just "grew apart?" Most of the time they didn't focus on building routines that would keep them moving in the same direction - regular time together, purposely remembering why you learned to care for that person in the first place, regular date nights, etc. Routine got in the way and laziness ensued - on the part of one or both parties.

Years ago I found that I had some "routines" that in themselves weren't bad, but I could see complacency happening. So now I make a conscience effort, if I see something just becoming a habit I intentionally will change it. For example, there are multiple ways to get to work in the morning - most of us would choose the most convenient, or most scenic, or shortest, etc. I choose the shortest - but every few days I just arbitrarily just take a different turn - I still make it to work, I see new and different thing and I arrive conscious to work aware of my surroundings.

Level 12

I love to play with loops in garage band.

Fun story:

   I learned BASIC back in high school on an HP/3000 mainframe hosted by the county I lived in. It was used for so much more than just high school education. Each account had a profile assigned. Mine was "STUDENT" obviously. This would run a script that would put me into "Silent" mode whenever I would logon meaning I couldn't chat with anyone else. But I never knew I could chat until I started poking around the Help files. It was there I learned how to list who else was logged in and how to communicate with them. Problem was they were all silent, But I did learn that for the first 30 seconds I was logged on I wasn't silent and that the Admin wasn't ever. So for giggles I wrote a BASIC program:


20 TELL @ADMIN "Hello!"

30 GOTO 10

40 END

Yea... my session was ended and my Computer Lab teacher was called later that day. I was in trouuuuuble!!!

Level 13

Iterate though VLANs, yea verily

Level 13

Or the universe hits Ctrl-C on your main thread.

Level 13

Also Breaker and Strannix- best names ever.

Level 13
Level 13

<thumbs up> This. Especially for relationships, family or otherwise.

Level 13

Google just failed to find me the TRS-80 BASIC program for vertical scrolling zig-zag text..

Level 9

Of course my mind immediately goes to the thought of how life can become a loop. Wake up, go to work, go home, sleep, repeat. I know for me when I recognize when I am falling into a loop, I do something to shake it up as to not get burned out.


I recall joyful times with my children when they were wide-eyed infants, singing:


And I'm reminded of mistakes made that have caused Network Loops, resulting in local or major STP outages.  And also of the fixes and policies and commands we've put in place over the years, to ensure we reduce the likelihood of loops being created in the first place, and of being able to quickly resolve them and restore any lost resilience or connectivity.

It seems like the simplest words (e.g.: loop, love, God . . .) can be the most complex to define, and may have the greatest impact on a life--or a world.

Level 9

When work is going bad it feels like an endless loop that never stops.

Level 11

Loop: The basic pattern of the human fingerprint. fingerprint-findings.jpg

Level 20

For me the thing in computer science that took a little while to get with loops was a special type of loop... a loop that calls itself:


unsigned int factorial(unsigned int n) {

   if (n == 0) {

   return 1;

   } else {

   return n * factorial(n - 1);



Level 20

I just noticed you had the same thought I did Leon... the first thing that came to mind for me in computer science too, that took a little more thinking, was recursion.

Level 9

loop - an inner circle of advisors

I remember that one!!

  Also, a buddy and me were so proud of our project of getting a plane to fly through a cloud and have parts of the plane "disappear" behind it. I miss BASIC. So linear...

Level 11

Image result for programming loops

Level 9

I've been lucky, that I have not dealt with any network loops at my current job. 

I was lucky that on my previous job I was not in the position to deal with them.

Sometimes things just end up in a loop, especially if there is no documentation.

Life loops, obsessive compulsive disorder, addictions, all come to mind when thinking of loops outside of programming. Some loops are inside functions that are reentrant. For the bad ones in life try to set the semaphores so those loops aren't allowed to execute even if they are called. Contact a friend, use a physical object to remind you don't go there, this loop leads to ill affects.

On the other had for some who have other disorders, loops and repetitive actions are the comfort that lets them get thru their day and life. They are a good thing.

Now if only there were a real traffic loop around Austin?


I enjoy pondering concepts like infinity, when looking at a mountain wondering how it was formed via earthquakes or volcanic eruptions, and how much wind and rains it took to whittle it down to its current state, and it makes me wonder how many programming loops in code that I've written have iterated through over the years.  From the runaway mistakes that I struggled against the CPU to stop by hitting break or ctrl-Z, to the end product that has persisted throughout the years.   While checking out an ISP that I had stopped working at nearly a decade before, I recognized the accounting code that I had written to keep track of users dialup hours still being used.   The "C" backend code that reduced the radius files into a database, and the perl snippets that interfaced with said database to produce a webpage for users.   While I don't think my code has even made a dent in the vast range of infinity, its still fun to ponder.

And as someone mentioned earlier, the sheer elegance of recursive routines, which I stumbled across writing the game of life in pascal for a school assignment in my first year of college.   I still dust off the programming skills from time to time to aid in the management of networks, while the keywords might have changed, the basics are still pretty much there.

Maybe nature and our digital world aren't so different.  Nature pecks away at its mountains with loops of rain, snow, wind and sun.   We peck away at our mountains of data with coding routines and loops whittling it down to something we can easily digest...

Food for thought!     Food, another sort of loop perhaps - we put it in one end, it comes out the other, becomes fertilizer for plants, etc. etc... 

And now I'm reminded of a childhood / teen "loop".  My small, one-horse town had one main street.  Teens with access to automobiles, and with insufficient parental supervision, would cruise up that street, make a U-turn at the north end of town, and cruise south, make a U-turn, and repeat.

For us (OK, I was insufficiently supervised) this was called "Shooting the loop", and it could be done seemingly infinitely.

Maybe some teens need something structured to do with their free time, instead of letting their parents allow them to spend it any way they'd like?

"What did you do Friday night?"

"I picked up friends and we were shooting the loop until ten o'clock, then headed home."  Curfews, whether municipal or parental, were rigidly enforced.  Perhaps because some parents remembered having unsupervised free time . . .


Level 14

patrick.hubbard​ You are a very talented writer!  That sure is an in-depth loop.

Level 14


Level 12

Loop hole

Level 9

You're making me dizzy!  The reminder "not to fall into life-wasting loops of our own" has given me direction on reevaluating my footprints. 

Level 14

hmm... circle of trust?

You made me smile.

I suspect the meaning is "You're out of the loop."

Level 15
Level 10

I see all the Loops above in coding and logic again. My first thought is Hook. As in Hook and Loop, AKA Velcro.

Level 14

At first glance, loop takes me back to my mainframe programming days.  Fast forward through Basic, C++, and scripting.  Now, for me, a loop references a specific bicycling route and nothing more.

About the Author
I'm the Head Geek and technical marketing director at SolarWinds, (which basically means I'm an mature geek in the services of the product team). When I say geek I mean Geek, with extreme prejudice. I started writing assembly on my Apple II, got a BITNET email account in 1984, ran a BBS @ 300 baud, survived X.25, abused Token Ring, got some JavaScript award love in '96, and my hack flight notification service still backs These feats of course made me quite the chick magnet for many years. Along the way in various jobs I’ve been a developer, SE, PM, PMM, and now principal evangelist. (Let us all join hands around the server.) Over 10 years at SolarWinds I’ve hatched our online live demo systems, managed the SolarWinds Certified Professional program, launched the Head Geek program, helmed SolarWinds Lab, and these days I’m focused on Cloud, DevOps and helping IT admins learn the new skills they’ll soon need not just to get ahead, but even maintain their roles. I’m always looking for new and more fiendish ways to use our products- just like our customers. And when I have a few spare minutes I fly a little, when the weather is good.