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

Bruno Desthuilliers bdesth.quelquechose at
Thu Jul 5 06:51:25 CEST 2007

Paul Rubin a écrit :
> Bruno Desthuilliers <bruno.42.desthuilliers at> writes:
>>Because static type checks impose a lot of arbitrary restrictions,
>>boilerplate code etc, which tends to make code more complicated than
>>it needs to be, which is a good way of introducing bugs that wouldn't
>>have existed without static type checks. 
> Why do you say that?   By metrics and anecdotal evidence, Haskell code
> appears to be at least as compact as Python code.

Haskell - as other languages using type-inference like OCaml - are in a 
different category. Yes, I know, don't say it, they are statically typed 
- but it's mostly structural typing, not declarative typing. Which makes 
them much more usable IMHO. It's too bad they are not more widely adopted.

>>Depending on the application domain and some technical and
>>non-technical constraints and requirements, it (often) happens that
>>it's better to have the application deployed now with an occasional
>>error message than to have it next year...
> I suppose that includes the thing I'm currently working on.
> For
> some other stuff I've done, such errors would have caused huge hassles,
> lost customer money, etc.  

Still, static typechecking is not a garantee against runtime errors. Nor 
against logical errors.

>>And FWIW, when it comes to "weird piece of input data", statically
>>typed languages are not specially better than dynamic ones...
> I know that ML gives compiler warning messages if you have a pattern
> match (sort of a variant of a case statement, not a regexp match)

I know what pattern matching is, I did play a bit with OCaml and Haskell.

> which is non-exhaustive.  And Haskell's Maybe monad is part of an
> idiom that handles failing computations (like regexp matches) much
> more gracefully than Python can.  Both of those would help this
> situation.

I'd have to see a concrete use case. And I'd need much more real-world 
experience with some ML variant, but this is not something I can expect 
to happen in a near future - it's difficult enough to convince PHBs that 
Python is fine.

More information about the Python-list mailing list