does lack of type declarations make Python unsafe?
tim at remove_if_not_spam.digitig.cix.co.uk
Mon Jun 16 00:49:46 CEST 2003
On 15 Jun 2003 13:28:06 -0700, beliavsky at aol.com wrote:
>In Python, you don't declare the type of a variable, so AFAIK there is
>no way for the interpreter to check that you are calling functions
>with variables of the correct type.
That's one of the reasons I would not advocate Python for mission
critical systems. But then, neither would I advocate C++ or FORTRAN,
for a whole host of reasons. The mission critical systems I work with
have the possibility of killing a few hundred people whenever they go
wrong, and the whole system development process, including choice of
language for software elements is quite specialised.
Using a rather looser meaning of "unsafe" than the one I usually work
with, yes, Python is type unsafe. Does it matter? Well, it depends.
Sooner or later all code comes down to machine code, which is type
unsafe on any system I can think of. You need to manage the types in
your program somehow; the more help your language gives you the less
likely you are to get bugs in this area but, /mutatis/ /mutandis/, the
harder it is to use the language and the longer it will take you to
roll out your code. These are conflicting concerns. Python is
deliberately placed towards the "ease of use" end of the scale, where
I believe it excels. For some work that's simply not where you need
to be and you should be using a different language. I don't believe
in general purpose programming languages; to misquote Michael Jackson
(the JSM one, not the "Thriller" one nor the Beer Hunter one) "If a
language claims to help you equally well with every problem, it won't
help you much with any problem". Or to misquote him again, "If a
language is claimed to be just as good for all problems, it probably
probably is, but not in the way the person making the claim intended".
More information about the Python-list