11 Augusti 2005

Stupid programming-language tricks

I do not know any Java, and already I know I do not like it.

Got a list in Python? Need to do something to each item in the list? Dead simple:

for item in list: do something to item

In Java?

for (int i = 0; i < list.length; i++)
{
list[i].doSomething()
}

That’s. Just. Stupid. I understand precisely how it works, thank you; I just think it’s bloody stupid. I know I’m going to forget to put the index in there the first zillion times I try it. And probably the next zillion, too.

A little syntactic sugar goes a long, long way.