Monday, July 11, 2005

I Can Already do That!

Some day around twenty years ago, back in the days when I knew absolutely nothing about computers and programming, I was nonetheless writing a sequence of statements in Basic – I don’t dare to call it a program. I’m talking about a time when, unlike now, there wasn’t a computer in almost every office and home, and kids didn’t start operating and programming computers long before their first love kiss.

I was at the time a young first-year college student in economics, and all my knowledge about what a computer was could be summarized in what I had so far seen in the movies. And I mean those times’ movies: a huge cabinet covering an entire wall and displaying a mystifying collection of tiny titillating colored lights.

But it was my fate that I got a job as the messenger boy for a computer hardware shop, and one day curiosity led me to a Basic Reference Manual besides an unoccupied Wang PC. Reading instruction descriptions in the manual and looking at the examples I began experimenting whit this computer thing after my working hours. Some days later I was able to paint a sequence of circles in the screen, varying its size and color, and making them zigzag and bounce on the screen borders. Trivial, yes, and absolutely useless too, but I was so proud of my recently acquired “programming skills” that I dared to show it to one of the engineers. He looked unemotionally at what I had written, and focused in a section that read something like this:

310 I = 1
320 CIRCLE (X+I, Y+I), 30, 15
330 I = I + 1
340 IF I <= 50 THEN GOTO 320

He then proceeded to show me how this could be expressed as:

310 I = 1
315 DO
320 CIRCLE (X+I, Y+I), 30, 15
330 I = I + 1
340 LOOP WHILE I <= 50

or even better as:

310 FOR I = 1 TO 50
320 CIRCLE (X+I, Y+I), 30, 15
330 NEXT

After he explained me how these for and while worked, I looked at him with puzzlement. “But… isn’t that the same thing I had already written?” I humbly asked, thinking I was surely missing something. “It produces the same results, yes…” was his only response. “Then, what do I need that for? I can already do that!” I shoot back at him, all my humbleness suddenly lost. He didn’t respond. Instead, he gave me an enigmatic smile, a “you’ll eventually get to that, little grasshopper” kind of smile, and with that he walked away. It took me a while, but I did get to it, and I always thank him for letting me figure it out by myself.

But learning why using a for construction was better than writing its equivalent if-goto combination was only a part of what I got from that experience. I also learnt that rejecting something new just because “I can already do that”, is foolish and almost always a sign that I'm completely missing the point.

In software design and programming in particular, there are very few things, if any, that are absolutely needed in the sense that you can’t do it in some other way. But clearly some ways are better than others, at least in some situations, so why should I reject a proposed new way just because “I can already do that” in the older way?

We don’t need structured languages in order to write structured code, and we don’t even need structured code in order to write a given program. Similarly, we don’t need object oriented languages to write code in an object oriented way, and of course we don’t need object oriented code either. I may or may not like object oriented programming, or structured programming, or any of the languages that support them, but rejecting any of those on the basis that “I can already do that” without them, makes no sense. Still, I’m sure that when those ideas were initially proposed, many objections of that kind were heard.

Whenever I’m presented with a new idea and I find myself thinking “I can already do that”, I remember those circles in Basic and force myself to think again without saying anything; I know I might be entirely missing the point. When it’s me presenting something new and I got “I can already do that” as a response, then I know it’s my time for a “you’ll eventually get the point, little grasshopper” silent smile.

Labels:

6 Comments:

Post a Comment

Links to this post:

Create a Link

<< Back to Main Page