Class Variable Question

Pieter Nagel pieter at equinox.co.za
Tue Apr 10 13:41:44 EDT 2001


On 9 Apr 2001, Douglas Alan wrote:

> "Steve Holden" <sholden at holdenweb.com> writes:
> 
> > That's correct. Python gives you "enough rope to shoot yourself in
> > the foot", and so does not offer the protection schemes associated
> > with statically-types languages like Java and C++. This increases
> > the flexibility of the language, at the (slight) risk of errors
> > which would not occur in Java or C++.

> In practice it is a *very* significant problem.  This is certainly one
> of the largest sources of bugs.  And it is, annoyingly enough, one of
> the few valid complaints that Perl devotees can make against Python.

In my experience, the number of potential bugs that statically typed
languages like C++ catch with protection schemes like these are
minimal.

In fact, static type systems often force you to overspecify types too
narrowly; which forces one to a) write all kinds of runtime-type or
template or preprocessor gumph to get around the type system, which
is in itself error prone, or b) have code duplication all over the
show because the type system makes it too difficult to hoist the
higher-level abstractions out the code.

For example, in C++ you must either write

	template <class T> T min(T a, T b) {return a < b ? a : b;}

which introduces the whole template nightmare to the language, which
is bug prone both in the compilers which need to compile them and the
code which uses them, or
OBor
	int min(int a, int b);
	long min(long a, long b);
	float min(float a, float b);

because it *forces* you to put the int, long and float types on the
parameters to min - a good example of where the type system forces
you to be overspecific.

My suspicion is, that in a static type system, you end up in a worse
position that in a dynamic type system, for little gain.

-- 
     ,_
     /_)              /| /
    /   i e t e r    / |/ a g e l




More information about the Python-list mailing list