Friday, January 19, 2007

Wheel reinvention for fun and profit

It's come to my attention that some among you think it's a waste of time to reinvent the XML-described UI. Some such rot about "reinventing the wheel".

Strunk and White's Elements of Style has a nice little turn of phrase I've always liked: "Infinitives, like round stovewood, sometimes benefit from being split." To which I add that wheels occasionally benefit from judicious reinvention.

There are three responses to this complaint, actually. First is why I believe that it's not a waste of time to reinvent the XML-described UI wheel, and it's the same as anything else in this venture: yeah, lots of people describe UI in XML, for the simple reason that XML is specifically designed to describe things. There are, in fact, a couple of XML UI description frameworks already out there for wxPython. As I said at an earlier point -- I don't like them because I didn't write them: the flippant version of saying, "I don't like them because they don't do everything I want and they don't express things as elegantly as I like." There's a great deal of machinery behind the wxpywf that simply doesn't exist in any comparable framework I know of. The fact that it's XML-described is only the surface -- the thing is, by reinventing XML UI description in the context of my existing workflow toolkit, I saw that there was a great deal more that could be done to encapsulate the UI in the first place.

Essentially, the UI frame is itself now an XML-describable object at runtime. It is an array -- I can effect changes to the UI simply by assigning a variable, and the framework takes care of figuring out how to implement the actual visual changes. If you take a look at the actual code for the filetagger, instead of carping about wheel reinvention, this elegance becomes more apparent. And so yes, I think that this particular wheel did not suffer from gratuitous reinvention.

So that's one response, a nuts-and-bolts thing. The second is more of a philosophical nature, a simple refutation of the weird notion that There Can Be Only One. Is there only one database? Did anybody carp at the MySQL writers that PostgreSQL already existed, so they were just reinventing the goddamn wheel? Did sendmail's mere existence make it superfluous to consider any other mail handler? For that matter, what about Linux itself? Didn't Unix already exist? Didn't Windows already exist -- what's the point of writing a GUI environment for Linux, then? Python is a reinvention of Perl, Perl of C, Java of C++. wxPython is a waste of time given TK, and Tcl isn't a reinvention of anything recognizable but still manages to be a waste of time. Or so it would seem to this humble wheel reinventor.

A healthy ecosystem benefits from a great number of competing -- and symbiotic -- species. That's a point equally true of carbon and software. If you don't like my GUI framework, don't use it. But whatever you do, don't complain that I wasted "time" -- whatever the hell that is -- by writing it. Because reinvention is progress. It was reinvention of the basic fabric of society that gave us the American Constitution, and a reinvention of our attitudes towards the universe itself that gave us the Enlightenment. I maintain that I was not wasting time.

And then the third and lowest-level response: who the hell are you to complain about wasting time, anyway? Why the hell do geeks think anything of a time-wasting nature is an affront? Do I complain about people playing RPGs or watching football? Is that stuff inherently more useful than my coding? What did you do today that wasn't a waste of time? Still got a TV? Bet you watched 24. Talk about a waste of time! At least I have something to show for my time that's different from what ten million other oxygen sinks did.

Waste of time. I'll give you waste of time.

2 Comments:

At 8:39 PM, Blogger Step said...

err, huh. wow. Cool! :) I dug that response, especially the third response. Amen, brother! :D

 
At 4:18 AM, Blogger The Ultimate Koala said...

That's a subject I have often debated. Here is what I think.
----

Summary:
If you re-invent something that suits you and works right away, you gained time.

If later, experience helping, you find out that you could reuse something existing and make your code simpler, this is another gain of time.

Otherwise, NOT reinventing IS a waste of time.

-----
Detailed explanation:

I want to build a grocery list that suits my needs.

Case 1:
I have access to a toolbox that already does this.

I have to figure out how to do it using this toolbox, get a grasp of the implementation details, and of the logic of the code.

I implement it, and later, find out that I have to extend this toolbox to suit my specific needs (using OCR on the cash receipt so my list can figure out how much I paid, how much the prices have raised, and to determine automagically the supermarket where the products are cheaper)

As I dont fully understand the use of the toolbox, I have to stunt my way through the API to write tangled unmaintainable code that does half the things I want.

Case 2:

I reinvent the wheel and use TK to implement my tick boxes. I use sane for OCR, and I try to find my way through the PostScript spec to print my grocery lists.

I keep my code clean all along, as I have access to everything I have coded. I fully understand how my program works. And it works.

Then, I look at the API of the nifty toolbox I found. If I find out that the logic of the API is the same as my program's, I'll try to see if the implementation with the toolbox leads to simpler code. If it does, I will do clean code that suits my need and reuses a powerful toolkit. If it does not, I'll have gained time not being entangled in crappy code, because the toolkit does not suit my needs, and I have invented something that does not exist!

I find that I gained time in Case 2. Don't you think ?

 

Post a Comment

<< Home