[E-Lang] static typing

"Marc Stiegler" <marcs@skyhunter.com> wrote:
> On a good day, static type checking has historically helped me write correct
> programs much as capabilities have helped me write secure programs. This is
> particularly noticeable writing servlets, for which my testing cycle for a
> 1-line change is enormous (sometimes requiring a restart of the web server).
> On a bad day it just gets in the way and makes me write enormous amounts of
> code to do a simple thing (when interfacing to a DBMS, for example). As you
> can tell, I have a love/hate relationship with static type checking :-)
Types can help you write your code in the first place, not just check
it before you try to run it. Like how dimensional analysis can lead
you straight to the right formula in physics, modulo some constant
factor, type constraints can lead you straight to the right code.
This is a good thing even without static checking. None of this says
your language should force a particular type system on you, though.
> I have wrestled with the question of what to say about static/dynamic
> checking in Walnut at some length. While your discussion here is
> illuminating, it doesn't change the following truth, which is approximately
> what I say in Walnut (in the Introduction) now: you could write a book just
> about the pros and cons of static type checking. E has chosen dynamic type
> checking. Lots of excellent real world software has been written with
> dynamic type checking. If you the reader are a static type checking
> aficionado, all we can say is try E anyway, we think you'll be pleased.
I asked a friend who'd avoided Lisp largely from doubts about its
dynamic typing, how did he get over them?
<luke_> dc: well actually I was procrastinating heavily and Karl mentioned
Erlang, and without knowing what it was I downloaded it and got hooked
within an afternoon. says a lot for having good introductory manuals - if
you can nab people who only have a procrastinatory interest you're doing
well :)
<luke_> getting over fear of dynamic typing I think just came from hacking in
a dynamically typed language for a while and the world not ending :-).
although Erlang did it for me and not lisp, because little things like the
compiler picking up on misspelled variable names or wrong number of
arguments to local function calls etc helped to more slowly wean me off
relying on the compiler a lot. I used to make lots of stupid/frustrating
mistakes in lisp
> luke - istr pattern matching was a factor somehow
> which I guess ties in with the frustrating mistakes in lisp
<luke_> dc: yeah I think so in a big way. also I was just realising recently
that deconstructing [H|T] in a function head makes it really unlikely that
you'll do something stupid like accidentally recurse on the whole list
instead of just the cdr
Erlang also has a guards feature, though iirc it's restricted to a
built-in set of checks, not programmable. I guess he'd have mentioned
guards if they'd been important to him.
-Darius