The Code Circus

Saumitra Khanwalker
5 min readDec 14, 2015

So I wrote some really good code the other day. When it worked, I was so over the moon that I wanted to talk about it. I wanted to tell everyone what an amazing piece of tech jugglery had I succeeded in performing. The sad part, though, is being at home doesn’t really provide one with an audience that would appreciate it. When I thought more about it, I realised that no non-programmer understands what we programmers really do. For them, the word programming triggers images like-

or something like-

Boring black screens within which lies a programmer’s world.

Now, in the seventh heaven as I was, I decided to present an alternate view to this; the view I personally relate to. Allow me to take you into the magical, spell binding world of circuses.

Generally speaking, programmers are in-charge of circuses. They put up the tent, they hire performers, they get the props, they decide on the tricks the performers will play and then in the end, they hire a ring master who conducts the show.

Doesn’t make sense? Play along. My story has four protagonists — the Ring master, the Elephant, the Mosquito and the stunt cyclist.

When we started, we just had the cyclist, the elephant and the Ring master. Now, I decided the first trick should involve the crowd. What if the crowd throws a ball at the ring master, the ring master passes it to the cyclist, the cyclist performs a crazy stunt, passes it to the elephant, the elephant does its jugglery and passes the ball back to the ring master who throws it back into the crowd. It sounded pretty entertaining to me.

So, I pitched the plan to the performers. They practiced long and hard. The cyclist got so good that he could catch the ball from the ring master, do the crazy stunt and pass the ball to the elephant within a blink of the eye.

The elephant on the other hand was trained for something pretty standard. It would calmly catch the ball, juggle it with all the other balls exactly five times and then pass it back to the ring master.

It was time for a test round. I stood in the audience and threw a ball at the ring master, who passed it to the cyclist, the crazy stunt and the ball was with the elephant. I took another ball and threw it at the ring master and this time, chaos ensued.

Do you see the problem? The cyclist passes the elephant the new ball well before the elephant is done juggling the ball from the previous round. The elephant gets confused and lets complexity get the better of him.

How do you solve this problem? The fact that the cyclist is fast is good. A slow cyclist won’t look appealing and the elephant can’t get any faster because well, it is an elephant! The problem was in the fact that the cyclist delivered the ball to the elephant after his stunt irrespective of whether it was done juggling the previous ball. It wasn’t really possible for him to wait either.

With a heavy heart, I took the decision to fire the cyclist and simplified the routine. Now, the ball came from the audience, the ring master juggled it until the elephant was free with the previous ball. As soon as it was, the ring master would pass it the next ball. The cyclist still abuses me when I run in to him, though.

The test round for the revised routine revealed flaws too. The ring master was left too busy juggling balls and was unable to entertain the crowd. Plus, juggling balls wasn’t really his forte. He could barely manage three.

This was when I saw the resume of a mosquitto, in the Circus Performers Hiring Weekly. His skill set was fascinating. He could catch balls thrown anywhere. He was fast. He could juggle many balls at a time and the most compelling of all- he could throw a ball back to exactly the person who had thrown it to him, no matter what happens.

So I interviewed this mosquito and found him apt for the job. With the mosquito on board, our routine got extremely organized and fluidic.

The audience would throw the ball at the mosquito, it would catch and juggle until the ring master is free. (Remember, ring master juggled until the elephant is free.) As soon as he was, the ball would go to the ring master, then to the elephant who would juggle, then back to the mosquito who would throw it back into the crowd.

This is pretty much what I did the other day. This is what most programmers do on their best days. Please see, best days. The other days are spent getting the performers to play along with each other. Quite a quarrelsome lot they are. Even the Ring master, looks jolly but is one nasty old man.

Every programmer will have stories like this to tell, stories they share only with their programming circle but would love to tell you. My request to you, give them a chance. Sometimes, its indeed quite clever; programming after all, is just some good ol’ problem solving.

P.S- For the technically inclined, the analogies might need some explaining. The Ring Master is my server running on NodeJS. The elephant is PostgreSQL database. Due to the event driven nature of NodeJS, the database transactions were creating problems if run in a loop. The cyclist is basically a loop that queried the database. The mosquito is a MQTT broker called Mosquitto. It’s used for reliable messaging with embedded devices. The juggling was analogous to queuing.

--

--