Could Python supplant Java?
joeking at merseymail.com
Wed Aug 21 13:49:14 CEST 2002
laotseu <bdesth at nospam.free.fr> wrote in message news:<3D631FF3.7060804 at nospam.free.fr>...
> FISH wrote:
> > laotseu <bdesth at nospam.free.fr> wrote in message news:<3D61A538.2050107 at nospam.free.fr>...
> > [snip...]
> >>I used to think the same (what about VB's 'variant' ? yuk !)... But
> >>python's dynamic typing has got me, specially in the case of oo
> >>programming. It makes polymorphism a really simple thing.
> > And more dangerous :-)
> What is the more dangerous : relying on the compiler or knowing what you
> do when wrting code ? It's more about the way you work than about the
> language you use.
Aha - you must be one of those rare creatures who writes
thousands of lines of code which is all 100% bug free. The
rest of us mere mortals unfortunately are not so lucky. :-)
Most of the developements in software engineering over the
decades have focused around giving programmers the tools to
write software with less chance of bugs - meaning we can
push the science harder and longer while not vanishing up
our own backsides under the weight of all the errors we
create. Let's face it - if it wasn't for the need to
reduce errors and write more dependable code, nobody would
have invented third generation languages, or structured
programming practices, or object orientation for that
matter. All of these 'devices' are meaningless at the
machine code level - they exist merely to serve programmers
with ways to construct stronger, more reliable, software.
> > Yes, but the error is flagged in compilation, as opposed to
> > five weeks after the product ships, when it crops up in a bug
> > report from a customer.
> Programs *should* be tested before shipping
> (ok, I know it's a dream but... )
Software testing is the *LAST* line of defense against bugs,
not the *FIRST* !!! ;-)
A good programmer uses appropriate techniques and tools to
try to minimise the number of bugs which get into software
in the first place - before it even hits testing.
> > Dynamic types are less
> > hassle to work with, but of course they push an added burden of
> > testing onto the developer
> No. Write (good) tests first, then write your code, then let the
> computer run the tests.
And how do I test the tests? (If your test software is there to
ensure your program works - what is ensuring your test software
works? Do you have test test software? And test test test
software?) We're back to what I said before - testing is the
LAST line of defense against bugs.
> > - because mistakes are not so easily
> > spotted.
> Your compiler won't spot most of the mistakes. Well written tests will.
How do you know the tests are well written? You're relying on the
validity of one piece of software you wrote to check the validity
of another piece of software you wrote. (And at the same time you
seem to poo-poo the idea of allowing the compiler - which is just
a piece of software after all - to check the vailidity of your code!)
Were as I have nothing against writing test software (all in favour,
in fact) it compliments other tools - such as using static datatypes
to ensure the compiler can check your handling of the data they carry.
Okay - not all software grows to the size where an average human
cannot keep track of data usage in variables. So for languages
which specialise in small single purpose code (often falling under
the category of 'scripts' - although this is very much a general-
isation) it is possible to discard fixed data types for variables
for a more flexible system.
> > However, for languages targetted maining at scripting
> > (scripts tend to be brief by their very nature) then the added
> > burden of dynamic typing is managable, and the benefits often
> > outweigh the problems.
> > This is one of the reasons why I do not consider Python a suitable
> > alternative to Java. Dynamic typing is fine for scripts, but when
> > it comes to full-blown 'ten thousand line' applications you really
> > should be looking as something IMHO which gives you the added
> > security of strong typing, to catch as many potential bugs as
> > possible.
> Ok. Objective C has dynamic typing. Whole Operating systems have been
> written in Objective C. Would you consider that :
> - Objective C is not suited for anything else than scripting ?
Yes. It may have many virtues, but I would not be my first choice
for large scale or complex projects. That's not to say you *cannot*
write large scale or complex project in it - just that other
languages (like C/++ and Java) would be better.
> - Java would be a sensible choice for writing an OS ?
No. Although this is one of the few large scale projects I would
not consider Java suitable for. Ultimately Java is designed to
run atop a VM, so extreme low level and/or time critical code
is best tackled in another language. The choice of 'OS' was a
poor one for the example's sake.
> (NB : I'm *not* suggesting Python would be a good choice if you plan to
> write an OS)
Again - you *could* write an OS in Python I'm sure - but other
languages would be better (and more bug resistant!) when handling
that volume of code.
More information about the Python-list