Re: Speed of C++ compared with speed of other languages
In article <35d326dd-b7ac-4c55-8f33-cdf092c414be@a32g2000yqm.googlegroups.com>, James Kanze <james.kanze@gmail.com> wrote:
On Dec 25, 2:30 pm, r...@zedat.fu-berlin.de (Stefan Ram) wrote:
James Kanze <james.ka...@gmail.com> writes:
As I said before, never trust a benchmark you haven't falsified
Yes, of course, it all starts with the fact, that one cannot
compare the speed of languages but only the speed of
specific programs running under a specific /implementation/
of a language running under a specific operating system
running on a specific hardware.
Yes. And the fact that any given implementation (and any given
language, for that matter) will have it's strong points and its
weak points. If you want a language to look good, you write to
its strong points, and to the other languages weak points.
What is language-specific is only the fact that some
language features make some kinds of optimization possible
(like restrict in C) or impossible (e.g., when aliasing by
pointers is possible).
There's possible and impossible, but but there's also
difficulty. There are C++ compilers, for example, which use
profiler output, and if it makes a difference, generate two
versions of a function, depending on whether there is aliasing
or not, with a quick test at the top to decide which one to use.
But it's a lot more effort than in Java. Similarly, given an
array of Point (where Point is basically 2 double), it's
perfectly conceivable that a Java compiler treat it as an array
of double[2]. But it's a lot more work, and a lot less likely,
than for a C++ compiler.
So, if I had to implement some algorithm, I would not refuse
Java from the first, because it is slow , but do some
benchmarking with code in the direction of that algorithm.
Exactly. Most of the time, what eliminates Java is that it
doesn't support really robust programming.
Wow. That bites. I'd be curious to see some specifics on this.
After all, /if/ Java is sufficiently fast for my purpose,
it gives me some conveniences, such as run-time array index
checking, automatic memory management and freedom from
the need for (sometimes risky) pointer arithmetics.
It also pretty much makes programming by contract impossible,
requires implementations of concrete classes to be in the same
file as the class definition,
And THAT is a ROYAL drag. No questions about it.
and does a number of other things
which make programming in the large difficult.
Well... I don't know what kind of things you are talking about.
That said, it's not a bad language for small non-critical
applications.
Except it is routinely used in MASSIVELY scaled apps
in banks, Wall street, etc. I just see those guys too often.
And it has a pretty nice GUI library, and is well
integrated in web server environments.
--
Programmer's Goldmine collections:
http://preciseinfo.org
Tens of thousands of code examples and expert discussions on
C++, MFC, VC, ATL, STL, templates, Java, Python, Javascript,
organized by major topics of language, tools, methods, techniques.