[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Strong Typing, Dynamic Languages, What to do?

I'm not a CS PhD, nor do I play one on TV, but maybe I
ease your aching soul.

A [static] type system is a state of mind.  A way of
viewing the world.  Specifically a way of saying
statically what is and isn't a valid program.  Now
there are many ways of seeing the world and so there
are many type systems.  And they all say certain
programs are valid and certain programs are invalid
and they all get it wrong a occasionally.  But you
knew that already.

Now if we take this view that a type system is a
static thing we can apply many type systems to the
same program.  This is what the PLT guys have done -
Soft Scheme, MrSpidey, and MrFlow all apply different
type systems to Scheme and all accept and reject
certain (and different) programs.  So if you desire
you can HM Scheme (which is what Soft Scheme does I
believe) and program in an ML style.  Not many Scheme
programs will pass that test but you can make sure the
ones you write do.  So you can be statically typed. 
And then you can write programs that don't pass the
type checker and you can just tell the Scheme system
to put in the appropriate run time checks and fail if
you made a type error.

So we can take a dynamically type system and by
limiting the language we use we can turn it into a
statically typed system.  Any statically typed system.

Now lets go the other way.  Hmmm... Can't be done.  If
the type system you use fits your program then you're
home.  So writing compilers in ML and simulations in
Java probably doesn't suck.  It's when you go the
other way that you feel the pain.  And that's when you
wished you had a dynamically typed language: because
there are more problems than there are type systems to
handle them and though more advanced type systems
require you to tie less of your hand behind your back
they'll never do away with it entirely (and least
while they remain decidable).

So for my money I'd rather use Scheme than ML.  A lot
of my programs look like ML but there are occasions
where they don't and its those outliers that make the
difference.  I'm happy to have static type systems
built on to Scheme so that I can statically check 90%
of my programs and I'm just as happy to throw away the
type system for the other 10% of programs.  It's the
perfect middle ground!


Do You Yahoo!?
Yahoo! Movies - coverage of the 74th Academy Awards®