PEP 3107 and stronger typing (note: probably a newbie question)

Alex Martelli aleax at mac.com
Sat Jun 30 18:34:40 CEST 2007


Bruno Desthuilliers <bdesth.quelquechose at free.quelquepart.fr> wrote:
   ...
> I still maintain that the primary *practical* reason behind static 
> typing is to provide optimization clues for the compiler. You can (or at

It's definitely a helpful aspect, yes -- given that compilers able to
infer types are still not very common for widely used languages; also,
complete type checking or inference requires analysis of the whole
program, which may be quite impractical -- and stops what Van Roy and
Haridi, in their masterpiece "Concepts, Techniques and Models of
Computer Programming", call "totally open programming".  Quoting a post
of mine from 2004:
"""
I love the explanations of Van Roy and Haridi, p. 104-106 of their book,
though I may or may not agree with their conclusions (which are 
basically that the intrinsic difference is tiny -- they point to Oz and
Alice as interoperable languages without and with static typing, 
respectively), all the points they make are good.  Most importantly, I 
believe, the way dynamic typing allows real modularity (harder with 
static typing, since type discipline must be enforced across module 
boundaries), and "exploratory computing in a computation model that 
integrates several programming paradigms". 

"Dynamic typing is recommended", they conclude, "when programs must be 
as flexible as possible".  I recommend reading the Agile Manifesto to 
understand why maximal flexibility is crucial in most real-world 
application programming -- and therefore why, in said real world rather
than in the more academic circles Dr. Van Roy and Dr. Hadidi move in, 
dynamic typing is generally preferable, and not such a tiny issue as 
they make the difference to be.  Still, they at least show more 
awareness of the issues, in devoting 3 excellent pages of discussion 
about it, pros and cons, than almost any other book I've seen -- most 
books have clearly delineated and preformed precedence one way or the 
other, so the discussion is rarely as balanced as that;). 
"""

> least could) have declarative static typing with very few type 
> *checking* - I may be wrong here but I think one could even write a C
> compiler without *any* type checking. Heck, the programmer said it's a
> char*, so it must be one, right ?-)

That compiler, I believe, would violate the ISO standard for C (so
calling it a "C compiler" would be about as correct as calling it a
banana, in my view:-).

> wrt/ proofs of correctness, I'll just point to the spectacular failure
> of Ariane, which was caused by a *runtime* type error in a system 

I like a quote by Knuth -- "beware this program may have bugs as I have
only proven it and not tested it":-)

> Hmmm... For a dinausor, C seems well alive. Can you remind me which 

So do chickens.


Alex



More information about the Python-list mailing list