Type Safety (was Re: fun and empowerment)

Henrik Gedenryd Henrik.Gedenryd at lucs.lu.se
Fri Jan 28 10:35:20 UTC 2000


Mike Thomas wrote:

>> Or is it a myth that we invented to rationalize the typing
>> needed to improve the compiler's performance?
> 
> Peter Norvig's book "Paradigms of Artificial Intelligence Programming: Case
> Studies in Common Lisp", 1992, Morgan Kaufman Publishers Inc. comes out
> strongly in favour of type-declarations, citing a case on page 318 where
> various hints to the compiler give a 40x speedup, so I see no need to
> rationalize.
> 
> I do feel it is a shame that compilers can't work it out for themselves -
> stupid damn machines.  I guess it all boils down to "What's in a name?"


This is exactly what Self's polyvariant specialization optimizing does.
(This is where they compile one version of a method per "class" it is
invoked by. Ie. it uses "type" information.) There is an example in one of
their papers where the only extra Sparc machine code ops generated by Self
vs. optimized C are the range checks for the arrays (IIRC). In the
benchmarks shown, Self is in range with optimized C and substantially faster
than C++. This evidently doesn't scale beyond benchmark-size programs,
though, judging from previous postings to this list re. perceived Self
speed.

Another thing is that in Smalltalk, you get swift and useful responses from
the debugger on type mismatch-style bugs. This was not the case in the days
when Pascal was invented.

Henrik






More information about the Squeak-dev mailing list