Strong types (.NET) versus weak types (Python)

Steven Bethard steven.bethard at gmail.com
Fri Nov 12 12:52:04 EST 2004


j_mckitrick <j_mckitrick <at> bigfoot.com> writes:
> 
> I recently took a one week course on .NET, and they emphasized over
> and over again that the key is types.  Everything is strongly typed
> and enforced.
> 
> Python is the exact opposite.

Python is strongly typed by most normal definitions of "strongly typed" (though
see http://www.python.org/moin/StrongVsWeakTyping for arguments about exactly
what strong/weak typing means).  I believe what you mean to say is that .NET is
statically typed, in which case it's true that Python is the opposite --
dynamically typed.

It's claimed by some that Python 3000 will have optional static type
declarations, though only time will tell...  It's far from trivial in a language
like Python that allows you to do things like change an object's class at
runtime.

> I prefer Python, but is .NET likely to change this view of types?

No.  Static vs. dynamic typing is a major language decision and is usually hard
to change, at least in any meaningful way.  .NET could go to dynamic typing, but
you would lose all the compile-time checking for very little gain -- AFAIK it
doesn't provide any way to do the things that make dynamic typing most useful,
like adding methods to an object, changing the class of an object, etc. at
runtime.

Steve




More information about the Python-list mailing list