Archive for September 2006

Code is Poetry (Screensavers Edition)

September 9, 2006

“Code is Poetry” is the slogan for I’m a longtime user of wordpress software, and I couldn’t agree more with that sentiment. Sometimes, after a long, hard day of coding at work, I go home and code some more, because I just have to see how something would work.

For example, back in the days of Windows 95 and Windows NT, there were some beautiful screensavers. But at the time, there weren’t many screensavers with interesting behavior. I wanted to see a little self-sustaining ecosystem: an aquarium where the fish would hunt and eat each other. So I wrote one. It is butt ugly. But it behaved exactly as I wrote it, and I couldn’t have been happier.

After a frustrating period of work, I wanted to punish the computer. So I wrote a screensaver to put the bugs in there to work. I made them perform a Sisyphean task of stacking balls that would later scatter, over and over again, forever. Butt ugly again. But I love it, it’s mine. I made it.

Code is my conduit from idea to reality. It’s essentially my modeler’s clay. It’s my art medium, and the medium has very exacting rules. Following the rules is difficult, but the results are so very rewarding. It is poetry.


Anatomy of a Bug (I)

September 1, 2006

How do bugs happen? Here’s an old bug of mine that illustrates how working code can suddenly break when a fix is made elsewhere.

Back when we first designed Studio 10, all new projects were tentatively assigned to the default folder My Projects. You could later save them elsewhere, but everything always started in that default directory.

Since you can save them elsewhere, Studio keeps a list of the directories in which you keep projects. The list was optimized to save space by not including the directory My Projects.


My thinking was, Studio code would always know to check the default directory anyway.

That wasn’t smart.

Later, our testers suggested that if they saved projects in a different directory, then that different directory should be the new default. They don’t care about My Projects anymore.

That made sense. So we changed Studio to set the default project directory to be wherever the user saved projects. Much better.

But I didn’t update the list of all project directories to accomodate the change!

A heinous bug rears its ugly head.

That list, which used to “know” that My Projects was always used, was now sometimes wrong. And this caused an off-by-one error in the size of the list. That off-by-one-error became catastrophic when when the size was 0, and off-by-one was -1.

A certain computer took a long time to count up from zero to negative one.

The bug’s since been fixed. But it took a while to discover what went wrong!