Python less error-prone than Java

Kaz Kylheku kkylheku at gmail.com
Sun Jun 4 04:13:44 EDT 2006


Ilpo Nyyssönen wrote:
> This is one big thing that makes code
> less error-prone: using existing well made libraries.
> You can find binary search from python standard library too (but actually the API
> in Java is a bit better, see the return values).
> Well, you can say that the binary search is a good example and in real
> code you would use the stuff from the libraries.

The trouble with your point is that Christoph's original posting refers
to an article, which, in turn, at the bottom, refers to a bug database
which shows that the very same defect had been found in Sun's Java
library!

Buggy library code is what prompted that article.

> I'd say it is not
> good example: How often will you write such algorithms? Very rarely.
>
> Integer overflows generally are not those errors you run into in
> programs.

Except when you feed those programs inputs which are converted to
integers which are then fed as domain values into some operation that
doesn't fit into the range type.

Other than that, you are okay!

Like when would that happen, right?

> The errors happening most often are from my point of view:
>
> 1. null pointer errors
> 2. wrong type (class cast in Java, some weird missing attribute in python)
> 3. array/list index out of bounds
>
> First and third ones are the same in about every language.

... other than C and C++, where their equivalents just crash or stomp
over memory, but never mind; who uses those? ;)

> The second
> one is one where the typing can make a difference.

Actually, the first one is also where typing can make a difference.
Instead of this stupid idea of pointers or references having a null
value, you can make a null value which has its own type, and banish
null pointers.

So null pointer errors are transformed into type errors: the special
value NIL was fed into an operation where some other type was expected.
And by means of type polymorphism, an operation can be extended to
handle the case of NIL.




More information about the Python-list mailing list