Bools and explicitness [was Re: PyWart: The problem with "print"]

Russ P. Russ.Paielli at gmail.com
Thu Jun 6 00:25:33 EDT 2013


On Wednesday, June 5, 2013 7:29:44 PM UTC-7, Chris Angelico wrote:
> On Thu, Jun 6, 2013 at 11:56 AM, Steven D'Aprano
> 
> <steve+comp.lang.python at pearwood.info> wrote:
> 
> > On Wed, 05 Jun 2013 14:59:31 -0700, Russ P. wrote:
> 
> >> As for Python, my experience with it is that, as
> 
> >> your application grows, you start getting confused about what the
> 
> >> argument types are or are supposed to be.
> 
> >
> 
> > Whereas people never get confused about the arguments in static typed
> 
> > languages?
> 
> >
> 
> > The only difference is whether the compiler tells you that you've passed
> 
> > the wrong type, or your unit test tells you that you've passed the wrong
> 
> > type. What, you don't have unit tests? Then how do you know that the code
> 
> > does the right thing when passed data of the right type? Adding an extra
> 
> > couple of unit tests is not that big a burden.
> 
> 
> 
> The valid type(s) for an argument can be divided into two categories:
> 
> Those the compiler can check for, and those the compiler can't check
> 
> for. Some languages have more in the first category than others, but
> 
> what compiler can prove that a string is an
> 
> HTML-special-characters-escaped string? In a very few languages, the
> 
> compiler can insist that an integer be between 7 and 30, but there'll
> 
> always be some things you can't demonstrate with a function signature.
> 
> 
> 
> That said, though, I do like being able to make at least *some*
> 
> declaration there. It helps catch certain types of error.

I recall reading a few years ago that Guido was thinking about adding optional type annotations. I don't know if that went anywhere or not, but I thought it was a good idea. Eventually I got tired of waiting, and I realized that I just wanted a statically typed language, so I started using one.

Steven's view on static vs. dynamic typing are interesting, but I think they are "out of the mainstream," for whatever that's worth. Does that mean he is wrong? I don't know. But I do know that statically typed code just seems to me to fit together tighter and more solidly. Maybe it's a liberal/conservative thing. Do liberals tend to favor dynamic typing?



More information about the Python-list mailing list