10 October, 2008

i = i + 1 : A ridiculous way to say increment I !

How many of you have coded in C, C#, Java or even JavaScript for that matter? If you have, then you'd probably know i=i+1 as one of your best companion when dealing with loops. Yet, I call the practice ridiculous...Why do you think that is?

For one, any programmer with a basic understanding of math would have puzzled over this question: isnt i->i+1 more meaningful than i=i+1 in a programming context? Why then do all programming languages follow the pattern of variable = variable +1?? I have no clue whatso ever, but I would reckon it is a reminiscent of the age when there were no standardized charecter sets for various programming languages and all vendors defined their own charecter sets, and standards.

And, to add to this mess, every programmer, no matter how experienced uses the counter variable named i, instinctively. Of course, he'd have to use an alternate variable to nest loops within other loops, he'd have to use another variable, and the second variable would instinctively be named j. I do not know if the collective conciousness of all programmers is at play here, for I have seen the same pattern repeating with every coder I have met over the past decade or so.. Even with me ! As we all pave way for new programming languages and techniques, I also hope that this hideous practice will be stopped, for all our sakes.