Python less error-prone than Java

Ilpo Nyyssönen iny+news at iki.fi
Mon Jun 5 00:49:52 EDT 2006


"Kaz Kylheku" <kkylheku at gmail.com> writes:

> Buggy library code is what prompted that article.

Yes, but it is an error type that happens very rarely still. And so it
seems that very few programs even notice that bug in that library. 

> 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.

If the input value range is limited, you want to get an error, if out
of range value is given. If you want to handle unlimited values, you
really need to take a look that you can do it. Think for example
storing such value to a database.

>> 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? ;)

It is not different. Your crash can tell you that it was a null
pointer. Your crash can tell you that you stomped over memory. You
just get the information about the error in different way.

> 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.

Yes and I actually think that as bad thing. It is nice to be able to
tell the difference between null pointer and wrong type. Of course if
the error message tells you that you had null there, it is not a
problem, but what if you somehow lose the error message and get only
the exception class name? (Yes, you should always keep the message
too, but it does happen.)

-- 
Ilpo Nyyssönen # biny # /* :-) */



More information about the Python-list mailing list