[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: in defense of types
> Date: 29 May 2002 17:29:58 -0000
> From: Paul Graham <firstname.lastname@example.org>
> Occam's razor suggests that *that's* what's special about
> this particular kind of assertion. It is merely a
> tradition. Static typing has some benefits (catching bugs),
> and when something is both traditional and has some actual
> benefits, it is hard to discard. But static typing has costs
> too, of the very worst sort: it makes programs longer and
> more rigid, and thus makes the language a bad tool for
> exploratory programming.
Have you tried programming in an ML dialect e.g. ocaml? The type
inferencing makes it possible to avoid > 90% of the type declarations. The
type system itself is extremely powerful, so you rarely feel cramped.
There is an adjustment required; some things that would "just work" in lisp
have to be made to work in ML by declaring the appropriate types. But when
all is said and done, your program is much closer to being "correct by
construction" than it would be if you wrote it in lisp. There is a cost in
flexibility (I don't think you can write the Y combinator in ocaml, for
instance ;-)), but it's much less than most people assume. I'm not saying
ML languages are the best languages for all jobs, but they represent a nice
trade-off. OTOH it's not clear how well macros interact with ML; my
impression is that it's an open research problem.