Thursday, February 23, 2006

To optimize, or not to optimize

Typically, one does not care much about the implementation of things such as OrderedCollection. They are so commonplace that it is safe to assume they work because otherwise the whole system would crash.

It is here that sometimes one finds the opportunity to optimize code. Take for example OrderedCollection>>addAll:, implemented in terms of aCollection do: [:each | self add: each] in VisualWorks. There's nothing wrong with this, and actually it's kind of nice because it seems to show some double dispatch tendency, written in some beautifully lazy way.

Until addAll: starts showing up in the TimeProfiler. Then you wonder... why should range checks be performed for each invididual addition? Or why should the collection have to grow several times when the final size is already known?

Of course then you look at the implementation of addLast:, inline the range / grow check in addAllLast: and then send addLastNoCheck: instead. Voila, all that OrderedCollection nonsense is gone from the TimeProfiler.

But... the new implementation is harder to understand. Is that element count right in the grow check? And by how much should the collection grow? Just to self size + aCollection size? Or should it grow a bit more in anticipation of more additions? By how much? Ahhh... the hours of second-guessing this kind of stuff can create while increasing the cost of change...

So, given this background... if you were to improve addAll: as discussed above, should you propose that the improvement is included in VisualWorks' next release as an enhancement? Is the sometimes quite significant speedup worth the additional complexity?

Questions, questions.

Tuesday, February 07, 2006

But with teachers like these, maybe...

So... sure enough, in general terms we suck, but every so often I have the chance to see the kind of action that requires courage. I do not know the guy very well, but I certainly like the way in which he handled what in theory is a sad situation*. Take a look (Windows Video or QuickTime), and thanks for the breeze of fresh air.

*In some way, the approach reminded me of the village of the mills in Akira Kurosawa's Dreams.

History will teach us nothing

Behold, the story of pygmy Ota Benga, put in a zoo display in New York about 100 years ago.

We have tenaciously refused to learn anything related to the terms "human rights". All this progress, civilization, even democracy... just bullshit. We still suck.

Saturday, February 04, 2006

Heard in the NYC Smalltalk User Group

Make your PC silent and cool with this Do It Yourself technique!

Thursday, February 02, 2006

GemStone 64 presentation - you missed it!

Yesterday I went to the NYC Smalltalk User's Group meeting. Besides meeting cool people and being able to share our common interests, we had a presentation on GemStone 64 by Norm Green of GemStone fame. It's amazing to see what the guys at Beaverton have done with their products!

But how come you were not there? I will forgive you only because it's the first time I blog about the NYC Smalltalk User Group. But in a few weeks, James Robertson of Cincom fame will be giving a presentation. So reserve the date in your calendar right now!

On March 1st, you have no more excuses. See you there!

(The date has changed and it's no longer February 23rd!)