The Win32 API and Simplicity

 | December 5, 2008 2:22 am


Everything should be made as simple as possible, but no simpler.
- Albert Einstein

I had an epiphany today. It came early this afternoon when I was sitting and trying to do something easy. Like all easy things, it turned out to be monstrously difficult. There is, of course, a back-story so let me expound.

For the past several days, I have been trying to finish up my little download manager, and I've made a lot of progress. Then I got stuck. But I was stuck for a good reason: I was trying to make my program pretty.

I thought it would be cool to display an icon in the download table after a file download finishes. I mean, just a list of files with the times the download finished was boring. Shouldn't be hard at all. I'm not writing advanced image processing software, after all. There's just two steps: you retrieve the proper file icon from the file types and then you put it in a little box. It gives the world color and excitement, it might even restore a sense of wonder. Firefox does it, Safari does it; I mean … how hard could it possibly be?

Thinking these and other naïve thoughts, I turned to the great oracle of Google and wasted a ponderous amount of time. I searched for every logical combination of keywords I could think of (and quite of few that were not so logical). I even discovered that Google ignores expletives and other creative language (who would have thought?).

Google, Yahoo Search and even Windows Live Search all failed to find anything helpful (though Windows Live doesn't ignore colorful language). Following my second failure, I pulled out all the stops. I started reading the MSDN community boards. While most of the results were about as helpful as gangrene or tetanus; I did find this. And after an additional hour of searching through some of Google's more obscure search results, I found this little gem as well (on search page 118). I don't understand either example, but that is neither here nor there.

By this point, I was locked in an obsessive need to finish what I had started. So … I created a custom class to retrieve the file icon. It is 66 lines of code long and I have little idea of what it actually does. I resorted to a tried strategy: copy and paste followed by lookup of the compiler output. About half way through, I even got the computer to stop beeping. What's even more surprising, though, is that it worked. I was able to retrieve the icon for my file type. Never mind that the output is 32 x 32 pixels, about half the size I need.

But that isn't really important. What is important is that I finished my download manager … and after struggling with the Win32 APIs, it was a spoiled moment. Now back to my epiphany. This experience made me think of Einstein. He understood an essential truth: things should be simple, elegant and clean. 66 lines of code are not simple, elegant or clean. It is an absolute shame that simple requires so much work. No wonder the world overflows with caring and compassion.

Similar Posts:

One Response to “The Win32 API and Simplicity”

[...] there were many specific things I wish I had known (for example, that the Win32 API is complicated), there were a few general items that I thought particularly helpful. As a result, this post is [...]