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.


Dan said...

I meet more people who think they're programmers because they're "software engineers" who know all about the "software development life cycle" and "design patterns" and "three tier enterprise architecture", but who would be seriously challenged to write that alarm clock app.

A major part of software engineering is recognizing when the simple and stupid is the best solution. Lisa did not need an alarm clock provider manager factory with remotely manageable plug-in wake-up modules.

I wonder why there isn't a good alarm clock app. Lots of people keep their laptop by their nightstand; progressive alarm, Zeno snooze, music trove access, backlight control, and similar features seem widely desirable.

Piaw Na said...

Yeah, that's the flip side of certain people who think they're good software engineers when they're not. I don't think of such people because my interviews tend not to be filled with abstract architecture astronaut type questions, so even if I was interviewing with such a person I wouldn't recognize him or her.

My point though was this: stupid cut and pasting code isn't software engineering. It might be good enough to get things done, but a software engineer also has to understand what's going on behind the scenes/underneath the covers, or the problem solving will always be very shallow.

ark said...

So where's the source code? would like to take a peek and it might help someone else out?

P.S. it irks me that adding comments opens up a new window (usually my browser is good about opening tabs for me)

Piaw Na said...

Source code is at:

(Yes, I didn't even bother checking it in)