Looks like an older post got some attention. Stefan Matthias Aust dropped this nugget in my mail box the other day, and with permission which he's granted, I share it with you
"...In your blog entry about ruby keyword messages vs. Smalltalk keyword arguments you compared Ruby with Visualworks Smalltalk. I did a similar experiment using Squeak.
Now that I did the experiment, I thought I can also share it with you -
hope you don't mind. Feel free to ignore it :)
To set a base line, this Ruby code
500000.times { area :left => 1, :right => 2, :top => 3, :bottom = 4 }
needs about 2,9 seconds on my machine to run.
Running
Area compute: #(#left 1 #bottom 7 #right 20 #top 2) asArgs
in Squeak needs 9 seconds. Of that, 5.6 seconds are spent in #asArgs. I implemented that straight forward, I think:
asArgs
| s d |
s := self size.
d := Dictionary new: s / 2.
1 to: s by: 2 do: [:i | d at: (self at: i) put: (self at: i + 1)].
^d
Using Array#after: performs slightly better, 5 seconds, but keeping in mind that constructing the Dictionary needs about 6 seconds, the dictionary access variant is actually faster than the use of #after:.
I actually did the test because I wanted to explore the suggestion from the comment, using DNU and implemented #compute: as
compute:
^(aDictionary atright - aDictionary atleft)
* (aDictionary atbottom - aDictionary attop)
and
doesNotUnderstand: aMessage
(aMessage selector startsWith: 'at')
ifTrue: [^self at: (aMessage selector allButFirst: 2)].
^super doesNotUnderstand: aMessage
This needs about 19 seconds to run. Doing the string operations might be
expensive, so I came up with the following variant:
^(aDictionary at right - aDictionary at left)
* (aDictionary at bottom - aDictionary at top)
and
at
^Delegate for: self
and in Delegate
doesNotUnderstand: aMessage
^delegatee at: aMessage selector
This needs 12 seconds to execute for 500.000 times.
The "native" variant using one keyword messages, btw, needs 0.3 seconds.
When using what you called the comma list form in Ruby, my 1.8.5 interpreter needs 0.7 seconds to execute that.
Running the same example with Python 2.4 - which has true keyword parameters - it executes in 0.8 seconds and 0.4 seconds with 4 comma separated values..."
The conclusion seems to be that while Squeak can better Ruby's hash pseudo keyword with Smalltalk keyword syntax, it can't simulate the "any order" nature of Ruby's psuedo hash keyword faster than Ruby can itself. Whereas VisualWorks was quite a bit quicker. Thanks for the results Stefan!
This of course leads me to toss the gauntlet over to Bryce Kampjes to see how much faster it will go when running Exupery.