Monday, January 21, 2008

Casual Programming in Windows

The EEE PC makes a perfect nightstand computer, a more fully functional Chumby, if you will. Lisa wanted an alarm clock application. Here are her requirements:
  • "Gentle wake". Slowly increasing volume until she wakes up.
  • Music player --- plays any MP3 in our collection (stored on our RAID NAS server)
One would think that someone has already written an alarm clock application for Windows already, but none of the ones we tried had "Gentle wake", and one of them simply crashed. What crappy software.

Well, I program computers for a living, so I started working on one a couple of nights ago. It had been 4 years since I programmed windows, but since this isn't a full-featured application, I could take short cuts I'd never do professionally. For casual programming, one of the best languages around is Python. The python port to windows is robust and small, and even more important, there's a windows layer readily available. Of course, using the raw windows API to decode MP3s is a pain, so I searched for a python media library and got pointed to Pymedia, which astonishingly came with an example to decode an MP3 and play it.

I dug around for a volume control API for windows, found it, and hooked up the whole thing, and then I was done. The code is only 126 lines. Of course, there were weird things along the way, like finding a version of pymedia compatible with Python 2.5, so I had to uninstall and reinstall various different versions of Python and pymedia, but all in all it was pretty painless --- programming by googling for code snippets you want and then copy and pasting and debugging is pretty easy.

Of course, I didn't even attempt the time consuming stuff, such as putting in a fancy GUI or even having a UI at all. I start my alarm clock by typing ".\ 22:30". I'm a software engineer, so command-lines feel easier to use than GUIs anyway. If you could talk to a computer, you'd want to say, "Wake me up at 7:30am", and clicking around on spin controls and clicking check boxes just doesn't feel natural compared to that, while the command-line would seem to be quite a bit closer. There are no snooze features, and you hit control-C to stop the music. Hey, the goal is to get you to wake up.

All this ease of programming reminds me, however, that this is why there are many people who think that they are great software engineers just because they can program a computer to do stuff. Being able to code a simple application like this in no way qualifies you to be a software engineer, and unfortunately, all too often I interview candidates who are confused about that difference. But that's another topic for another day. In the mean time, Lisa's satisfied with the app, and that's all I care about.
Post a Comment