February 2, 2017

Happy Groundhog Day

Filed under: Main — admin @ 12:01 am

Bill Murray as Phil Connors in 1993’s Groundhog Day.

February 2 is Groundhog Day in the US. It’s the midpoint of winter. Seasonally, winter is only 6 weeks old, but because winter weather can start in mid-November, at this point of the year most people are really sick of the cold, wet, snow, and ice. So Groundhog Day becomes a point of reflection: Do we have six more weeks of winter or can we hope for an early spring?

In the film Groundhog Day, character Phil Conners experiences February 2 over and over. According to lore, he spends 10,000 years reliving the same day over and over. No one else is aware of this situation. So in the 1993 movie, Bill Murray has fun playing with the concept of knowing exactly what’s going to happen. It’s one of my personal favorites, not only because it’s a fun movie, but it explores life and taking time to reflect.

The nerd in me, however, admires the concept of the loop.

In programming, a loop is a chunk of code that repeats: The same instructions are executed again and again, usually a given number of times. The loop is one of the basic foundations of programming, along with decision-making and the subroutine.

When a loop lacks an exit condition, it’s called an endless or infinite loop. I prefer the term endless loop. Apple programmers must prefer the term infinite loop because (and it’s probably an inside joke) Apple headquarters is located at One Infinite Loop in Cupertino, California.

In some programs, having such a loop works. For example, a dedicated piece of hardware may rely on an endless loop because it just keeps doing the same thing over and over again as long as the power is on. In many cases, however, an endless loop is the result of an error.

For example, a programmer — even an experienced programmer — can write code where the loop counter gets lost and the loop just keeps going. I committed such a sin the other day where I reset a loop variable without knowing it and wondered why my program never quit: It was stuck in an endless loop.

In Groundhog Day, Phil enters what appears to be an endless loop. No matter what he tries, the same day repeats. He moves from a state of disbelief to panic to anger to amusement and finally acceptance. I would find the situation terrifying, but apparently Phil eventually arrives at the point where he becomes a better person. That change is the exit condition for the loop, and the movie finally ends on February 3. The loop terminates.

Where I live it’s been brutal winter. You can check the PorchCam: It’s been white outside since early December. Despite some warmer weather (in the 30s), the massive amount of snow will take some time to melt. I expect it to be with us until March. But unlike Phil Conners, this winter is not an endless loop. It will end soon, whether Punxsutawney Phil sees his shadow today or not.

No Comments

No comments yet.

RSS feed for comments on this post.

Sorry, the comment form is closed at this time.


Powered by WordPress