Is Python overhyped (just like Java)?
aleax at aleax.it
Tue Apr 1 11:40:52 CEST 2003
David Abrahams wrote:
>> One example I give is a task for which C++ is quite suited, with its
>> standard library -- reading a text file, breaking it into
>> whitespace-separated 'words', building an index from each word to
>> the line numbers on which it appears, and showing the index with
>> words in alphabetical order, one per line, each followed by the line
>> numbers on which it appears.
> Boy, that sure sounds like a job for Python to me. Something like
> "high-performance linear algebra with sparse matrices" sounds more
> like a job for which C++ is "quite suited".
The C++ standard library has no primitives to deal with sparse
matrices, while it does have some for handling text, etc, etc.
If you have other libraries available, besides the standard ones,
both C++ and Python could be fine. To WRITE such libraries, I'd
choose C++ (or maybe Python + Numeric, but that's iffier) -- but
applications are another thing.
>> excellence of Python's intrinsics (dictionaries, lists, strings)
>> versus the lesser quality of C++'s library implementation (maps,
>> vectors, strings) -- with different implementations, you may see
>> different ratios.
> Really? Are you sure that time wasn't sunk into I/O? "Read all the
> lines from a file" is a primitive in Python, but not in C++.
Add files to the list of Python intrinsics above, I guess!
> Also, it's only fair to point out that C++ doesn't have one library
> implementation -- each compiler comes with its own. Which
> implementation(s) were you testing? Oh, I see it was probably
> libstdc++ that comes with gcc 3.1. Well, IIRC GCC-3.1 was well known
> to optimize poorly (it took them some time to figure out how to
> integrate all the new optimizations that came in with GCC-3, and they
> actually made things slower for a while), and I wouldn't exactly say
> that libstdc++ is the fastest implementation.
Yes, I used the gcc and libraries that come for free with Linux. I'll
be quite happy to benchmark with any other free compiler and implementation
of the C++ standard library, of course!
> In other words, there's nothing intrinsic about C++ which says that it
> has to be twice as slow as Python at this job. I don't think it's
> fair to talk about "the lesser quality of C++'s library
> Aren't you glad I'm asking these questions now, instead of at your
> talk in Oxford? ;-)
No, I'll be quite happy to debate this in Oxford, too. Hmm, better
rush -- my plane's leaving soon...!
>> The simplest and most flexible C++ you can write is still way
>> bigger, more complicated, and less flexible than the most refined
>> and optimized Python code it may make sense to write -- it's as
>> simple as this.
> I think when you're comparing the use of the core language I have to
> agree. However, when it comes to functionality provided by libraries,
> it really depends on the quality and availability of the library
> interface. That said, I think Python probably still has many more
> useful libraries than C++ does.
I'm talking of the STANDARD libraries only. If you open the field
to third-party libraries, you've basically comparing infinities;-)
More information about the Python-list