Novel Thoughts on Scripting and Languages

Andrew Dalke adalke at mindspring.com
Fri Jan 10 12:36:46 EST 2003


James Huang:
> Without static typing, what good does strongly-typedness do?

Because it's the objects that are typed.  Python variables are
all references to objects, so their type is (philosohpically)
"pointer to objects."

x = 200

creates an object of type 'int' and makes 'x' reference it.

y = "Hello"

creates an object of type 'str' and makes 'y' reference it.

x + y

gives an error because you can't do that with ints and strings.

> If you can change the class on the fly, does this break the
> strong-typedness? It's sort like (void*). JudoScript does the same
> thing, because an object, after all, is a map with a list of
> associated methods/functions; unless, of course, it is a Java object
> or ActiveX.

Since you can cast in Java, doesn't that break strong-typing?

The old object is strongly typed.  The new object is strongly
typed.  I've just changed the object type dynamically, that's all.


> Python seems to have quite a few dangerous features that lack in Java
> but do exist in C++. Java was born so many years after C++ and Python,
> so there must be some reasons, I am afraid. Otherwise, with good
> discipline, C++ can be just as good (except for garbage collection).

Man, you've bought the party line hook, line, and sinker.  (Umm,
idiomatic expression meaning that I've heard that before from others,
that it seems to come from Sun, and that I don't agree with it, nor
that I believe you've thought it through enough to judge it.)

Java doesn't have:
   Multiple inheritance
   User-defined definitions for how instances interact with operators
   Generics

The reason given for the first two is that "they are dangerous features
and shouldn't be used."  But MI has its uses, as does redefining how
operators work.  (I find the latter especially useful.)  And generics
in Python and C++ are very powerful.  Last I heard, they will be
added to Java "someday."  (Didn't bother to check if they exist
already.)

Oh, and Java does have that weird "we have integers and Integers".
(I've heard the expression 'boxed' vs. 'unboxed.')

Have you ever considered that the people who developed Java didn't
develop a better language than those which existed before?



> It's the statical typing that make strong-typedness a big help for
> boosting software quality -- the compiler! And that's what makes me
> wonder people implement big software without the help of compilers.

The Python party line (which I agree with) is that there are plenty
of other errors which can arise in programming.  Type checking is
one way to find those errors, but a good regression suite -- which
you need in any case -- catches nearly all the errors that type
checking would have caught, and catch more.  The downside of static
typing is that you have to enter in all those types, so the code is
more verbose and harder to read, understand, and maintain.

> To me, Python and Java are similar because they both support class and
> inheritance, and garbage collection. I wouldn't say C++ and Python are
> similar. Of course, variable declaration or not, blah blah ...

Hmm... OCaml supports classes

http://caml.inria.fr/ocaml/htmlman/manual005.html#ss:classes-and-objects

and inheritance

http://caml.inria.fr/ocaml/htmlman/manual005.html#ss:inheritance

but it's a functional language.  I think again (as others have asserted)
that your exprience in programming languages needs some broadening.


					Andrew
					dalke at dalkescientific.com





More information about the Python-list mailing list