Python from Wise Guy's Viewpoint

Dirk Thierbach dthierbach at gmx.de
Mon Oct 27 06:43:31 EST 2003


Pascal Costanza <costanza at web.de> wrote:
> Dirk Thierbach wrote:

>> Maybe. It sure would help if you'd tell me your view instead of having
>> me guess :-) For me, a type is a certain class of values, and a static
>> type is given by a limited language describing such classes. A
>> dynamic type is a tag that is associated with a value. Arbitrary
>> classes of values (like "all reals less than 200") are not a type.
> 
> What are "non-arbitrary classes of values"?

Those that can be described by the language available for static types
e.g. in Haskell or OCaml.

> According to your criteria, (real * 200) is
> - a certain class of values
> - given in a limited language describing that class

Yes, but you will have a hard time developing a static type checker
that will work with such a language.

> I would be interesting to see a convincing definition of the term "type" 
> that precludes (real * 200), and similar type specifications.

Look at the definition for type in Haskell or OCaml, for example.

> (Maybe it helps to explain that CHECK-TYPE doesn't check a value per se. 
> (check-type 5 (real * 200)) doesn't work. CHECK-TYPE checks a property 
> of the variable it is being passed.)

Yes, I know. What does that explain?

> "very rare situations"
> "never a show-stopper"
> 
> How do you know?
> 
> If you are only talking about your personal experiences, that's fine, 
> but you should say so.

Of course I am talking from personal experience, like everyone does.
There is not other way. But in this case, I think my experience is 
sufficient to say that.

> The only claim I make is that static type systems need to reject 
> well-behaved programs. That's an objective truth.

This depends on the definition of "well-behaved". The claim I make is
that for a suitable definition of "well-behaved", it is not an
objective truth. And even if you stick to your definition of
"well-behaved", it doesn't really matter in practice.

> All I hear is that you (and many others) say that the disadvantages
> of static typing are negligible. However, I haven't found any
> convincing arguments for that claim.

What kind of arguments would you like to have? I have tried to
show with a few examples that even programs that you think should
be rejected with static typing will be accepted (if you allow for
the fact that they are written in a different language).

What else is there I could possibly do? The simplest way is probably
that you just sit down and give it a try. No amount of talking can
replace personal experience. Get Haskell or OCaml and do a few simple
examples. You will find that they have many things that you won't
like, e.g. no good IDE, no "eval", and (as every language) they
require a slightly different mindset compared to what you're used
to. They might also not have the library functions that you are used
to. But it might give you a good idea what programs are statically
typeable and what are not.

> But I am interested in the question why you (or others) think that 
> almost all software should be developed like that. 

I didn't say that. Please do not put up a strawman. In fact, I 
explicitely said "you use whatever tool you like best".

> I have chosen to illustrate examples in which a dynamic approach might 
> be considerably better. 

And you didn't convince me; all your examples can be statically
typed.

> Again, to make this absolutely clear, it is my personal experience
> that dynamic type checking is in many situations superior to static
> type checking.

That's maybe the important point. HOW DO YOU KNOW IF YOU HAVE NEVER
TRIED IT? (In a language with good static typing, not in a language
with lousy static typing). And obviously you haven't tried it,
otherwise you wouldn't give examples that can be easily statically
typed, or confuse exceptions or dynamic checks with static type checks.
So it cannot come from your personal experience.

> But I don't ask anyone to unconditionally use dynamically typed
> languages.

But you insist that dynamically typed languages are "better" or
"superior to" statically typed, because you claim you cannot do things
in a statically typed language that you can do in a dynamically typed
one. That's the point where I disagree. I don't ask you to use a
statically typed language, I just want you to give admit that both
are equally good in this respect, or at least you should sit down and
verify that yourself before saying it.

- Dirk





More information about the Python-list mailing list