Is this a true statement?
Tim Daneliuk
tundra at tundraware.com
Sun Jun 24 14:29:41 EDT 2001
"Steven D. Majewski" wrote:
>
> On Fri, 22 Jun 2001, David Lees wrote:
>
> > Not necessarily. It might go faster if you were comparing a Python
> > built-in operation (coded in C) with something inefficiently coded in
> > C++. But the statement that "Python can do everything C++" is true, but
> > a tautology. You can substitute nearly any language; Basic, C, Algol,
> > Lisp,... and it is still a true statement.
> >
> > david lees
> >
> >
> > MDK wrote:
> > >
> > > Python can do everything C++ can do but just slower.
>
> Wrong, David.
> Turing completeness means that anything you can *COMPUTE* in one
> language you can computer in another. Python, Lisp, C++, etc.
> are all equivalent in that sense.
>
> But you can't *DO* all of the same things in all languages -- for
> example: you can write a device driver in a language if you can't
> specify interrupt vectors or hardware address pointers.
>
Not so, Steve. If something is Turing-Complete you CAN do everything
in that language - it just may be ugly. All Turing-Complete languages
(like C, BASIC, Assembler, C++, Python...) can compute *exactly* everything
which is computable and therefore exactly what each of the other T-C
languages can compute. They will do so with different degrees of effectiveness
(which corresponds to their suitability for the problem at hand) and efficiency
(which corresponds to Turing machines of different computational complexity) but
they are all *equivalent* in functionality.
As to the objection that one cannot write device drivers in
Python - this is nonsense. Someone already gave the counterexample of having
Python *generate* such a driver and this is entirely valid. Another
counterexample would be to wire the OS kernel with an embedded Python interpreter
runtime (which, after all, Python was designed to do) and then write the driver
as native Python code. The reason this is not done is not because
it is impossible. This is not done because it is inefficient.
So, to the original question, yes, Python and C++ *CAN* do exactly the same
things (as can all other Turing-Complete languages), but they are not suited
equally well for all problems.
As far as speed goes, there is no clear answer. In this GUI-driven world in
which we live, code speed is very often/rarely the issue - the machine spends all
its time waiting for keystrokes and mouseclicks. Even on heavily loaded servers,
the performance is more usually bounded by I/O than CPU. Clearly there are
counterexamples - code efficiency is critical in modeling and numerical
analysis problems. For the most part, though, expecially in commercial
applications, *correctness* and *programmer* efficiency are way more important
than code size or speed.
Python is ideal for a very large class of programs because it allows programmers
to quickly create large amounts of correct code. If, in fact, performance does
become an issue, if the code is well designed in the first place, it is
relatively trivial to do a "hotspot analysis" and replace the performance
impeding code with hand-coded C, Assembler, or what have you...
--
------------------------------------------------------------------------------
Tim Daneliuk
tundra at tundraware.com
More information about the Python-list
mailing list