[Haskell] pros and cons of static typing and side effects ?
ajb at spamcop.net
ajb at spamcop.net
Thu Aug 11 23:01:05 EDT 2005
G'day all.
Quoting John Meacham <john at repetae.net>:
> I find pretty much completly the opposite is true. for random hacking
> and evolving code, static typing is essential.
I agree with that.
While you can't be certain that once your code typechecks, it's bug-free
(though that does often happen), you can be almost guaranteed that if
your code typechecks after a refactoring, the refactoring didn't
introduce any bugs. This is a crucial property of "sufficiently typed"
languages which I rely on all the time when evolving code.
In addition, coming up with typed data structures tends to focus my
thinking early. I think it was Dijkstra who commented that he could
understand your code much better if you show him your algorithms AND
your data structures, rather than showing him your algorithms alone.
When programming in a less statically-typed language, I often find
myself having to document the structure of the data during the "random
hacking" phase anyway, even if I'm only using diagrams on paper. So why
not document it in a form that the computer can also understand?
One thing I do sympathise with is that programming in a statically typed
language is no fun if the type system isn't flexible enough to support
serious hacking. You really can feel like you're fighting the type system.
Older ML variants (I have particularly bad memories of SML), and older
Turner-esque languages for that matter, are no match for Haskell 98 plus
Glasgow extensions or O'Caml in this respect.
Cheers,
Andrew Bromage
More information about the Haskell
mailing list