[Newbie] Morph class>>new

Stephane Ducasse ducasse at iam.unibe.ch
Tue Apr 15 13:13:43 UTC 2003

Hi cees

On Tuesday, April 15, 2003, at 02:55 PM, Cees de Groot wrote:

> On Tue, 2003-04-15 at 10:53, Christian Hofer wrote:
>> would twice initialize the Morph. This would not happen if Morph used:
>> self basicNew initialize
>> Is that wrong?
> I've been wondering about this myself. Everywhere I look, I see 'super
> new initialize', while I think that 'self basicNew initialize' really 
> is
> a cleaner way. In fact, I think
> Object>>new
> 	^self basicNew initialize
> should be in the image. The initialize methods themselves usually know
> best whether a 'super initialize' needs to be done. I use 'self 
> basicNew
> initialize' exclusively and I'm quite happy with it, but the fact that 
> I
> see so much code with 'super new initialize' makes me wonder - is there
> something wrong with 'self basicNew initialize'?

Yes there is. Remember the discussion in the VW mailing list, I 
recently talked with eliot that was really in favor of having new 
calling initialize and he told that their main problem is their clients 
so they will certainly not do it but not for the
reasons of speed because he said that with their jit it would cost less 
and 1%.

In CLOS 8 years after Smalltalk they got it right.
	Make (new) invokes allocate (basicNew) then initialize

CLOS was doing that everywhere so the Behavior>>new was invoking 
Now in Squeak we do not have to do it at the metaclass level, so we just
Object class>>new
			^ super new initialize

is enough. When andreas was visiting us we play with that and he was 
surprised to see that this was not costly around 3% on macrobenchmark 
even if one was at 12% but we could optimize that by defining the same 
on array new: for example.

Some people were also afraid that they could lost control and pay one 
extra send.
First you do not lose control as if you want a non initialized method 
you simply call
allocate (=basicNew).

Now I should sit down, understand how the profiler really work and 
prove that this is worth (at least all the trees for the book and 
bandwidth we use)


> <signature.asc>
Prof. Dr. Stéphane DUCASSE
  "if you knew today was your last day on earth, what would you do 
different? ...  especially if,
  by doing something different, today might not be your last day on 
earth" Calvin&Hobbes

"The best way to predict the future is to invent it..." Alan Kay.

Open Source Smalltalks: http://www.squeak.org, 
Free books for Universities at 
Free Online Book at 

More information about the Squeak-dev mailing list