Type Safety (was Re: fun and empowerment)

Richard A. O'Keefe ok at hermes.otago.ac.nz
Sun Jan 30 23:52:52 UTC 2000


	My problem with static type checking is that the types in most languages are not
	first class.

Do not confuse "type checking" with "most languages".
Common Lisp has run time type checking, plus optional static type checking,
with first-class values that represent types.

	Type signature information that could potentially be
	useful to a programmer is thrown away by the compiler.
	
Does Java reflection provide what you want?

	   I also do not like inputting code that doesn't *DO* anything.
	
Types in Ada, Haskell, Clean, and Mercury amongst others are used for
overloading.  This goes all the way back to Fortran, where types let
you write X+1.0 as well as I+1, as opposed to say BCPL, where you had
to write X #+ 1.0 to distinguish floating point add (#+) from integer
add (+).  Ada &c allow user-defined overloading.  Writing
	X: Foo;
does do something for you, because it means you can write
	Bar(X);
	Ugh(X);
instead of 
	Foo_Bar(X);
	Foo_Ugh(X);

What's more, the presence of types in a langauge doesn't mean that
you have to write any more code.  Take the Haskell function

	f x = x + 1

The compiler infers the type

	f : Num a => a -> a

all by itself.

	Static type-checking is not good for rapid prototyping of
	applications.

The Haskell experience is otherwise.  The main issue for rapid
prototyping is "how much code do you have to design, code, and test",
NOT how much of it is type declarations.  What's in the library is
perhaps the most important thing.  Does any sane programmer use
Perl or Java because they are good *languages*?  Of course not.
You use Perl because of the CPAN; you use Java because of its library.
Suppose typeful language A requires 20% more lines on average than
typefree language B, but language A has 60% of what you need already
there in its library and language B only has 30%.  Then it's less
work to do it in language A.

Even (perhaps especially) in rapid prototyping, you had better write
useful comments, and they will far out-bulk any type declarations you
need in a modern typeful design.

Of course, Squeak does well on both measures, except that I don't
_know_ what's in the library.  It would be very nice to have full
documentation.





More information about the Squeak-dev mailing list