Three Ways Juggling is Like Programming
I'm going to my first ever juggling convention this weekend! If any of you are in Madison, hit me up. Not sure if I'll be able to get away from Madfest, but worth a shot. In celebration of this momentous event, here are three ways that juggling is just like programming:
1. You gotta balance a lot of things!!!
2. Benefits from a rigorous formal specification
In 1985, jugglers put juggling on a sound mathematical foundation. This foundation, called siteswap, permanently changed the sport.
Let's say I do the most common juggling pattern, three balls, hand to hand. This is called a "cascade". After a while I've reaching an equilibrium, where I'm regularly throwing and catching a ball each beat. To keep up that pattern, each ball must be in the air for three beats. We can say the pattern of throws looks like this:
3 3 3 3 3 3 3 3 ...
a b c d e
On throw (a), I throw ball 1 with my dominant hand. (b) I throw ball (2) with my other hand. (c) I throw ball (3) and catch ball (1). From then on, I'm throwing and catching on every beat. We can shorten this pattern to just 3
.
Now what if I want to throw ball (3) higher? Like 5 beats total. The pattern would look like 335335335...
, or 335
for short. In the second cycle, when I try to throw (3), it hasn't actually come down yet! This is an impossible pattern! But I can adjust it. If I instead throw 531
, the pattern becomes possible. We can see this by following each balls "orbit". The first ball ends up coming down on the 1
and being thrown as a 1
back to the 5
. The 3
throw lands back on the 3
throw and is again thrown as a 3
. Three balls, two orbits, valid pattern.
This might be a bit confusing, because I haven't taken the time to edit it into something that sounds sensible to nonjugglers. Also, I'm not providing visual aides. This would be a lot easier with visual aides. The point is, though, that simply by inspecting the numbers of a pattern, I can tell if it's 1) sensible, and 2) what it looks like. We can even tell things like number of balls in the pattern, by finding the mean of the sequence. 40
has two balls. 4413
has three balls. 71
has four.
This is incredibly powerful. We can create very complicated patterns and see if they embed in other patterns. We can communicate patterns very easily: it's possible to say "this is 55500
" and the other juggler immediately knows what it means. We can even use this to discover patterns! Siteswap revolutionized juggling, and is a driving force behind the ever-more-sophisticated patterns jugglers can now do.
Siteswap isn't perfect. It only shows a small facet of juggling. It doesn't handle multiplexing, where we catch and throw two balls, or simultaneous throws, or body motions. There's no way to encode an under-the-leg throw in siteswap. The same is true of programming formal specifications: the model is only a small facet of the code. But even that is powerful enough to get stuff done. We model because it makes it easier to think about the problem.
Incidentally, if you are a juggler, try juggling 441
. It's the only 3-ball pattern discovered purely via siteswap.
3. Practice practice practice!!!
If you're reading this on the web, you can subscribe here. Updates are once a week. My main website is here.
My new book, Logic for Programmers, is now in early access! Get it here.