Java Faster Than C++?
jg21 writes "The Java platform has a stigma of being a poor performer, but these new performance benchmark tests suggest otherwise. CS major Keith Lea took time out from his studies at student at Rensselaer Polytechnic Institute in upstate New York's Tech Valley to take the benchmark code for C++ and Java from Doug Bagley's now outdated (Fall 2001) "Great Computer Language Shootout" and run the tests himself. His conclusions include 'no one should ever run the client JVM when given the choice,' and 'Java is significantly faster than optimized C++ in many cases.' Very enterprising performance benchmarking work. Lea is planning next on updating the benchmarks with VC++ compiler on Windows, with JDK 1.5 beta, and might also test with Intel C++ Compiler. This is all great - the more people who know about present-day Java performance, the better.""
... C++ is more portable.
And Microsoft is more stable than Linux.
Just see what comes out of profiling this:
int main( int argc, char **argv )
{
for ( int ii = 0; ii < 10240; ii++ {
cout << ii << endl;
}
return( 0 );
}
Now compare it to this:
int main( int argc, char **argv )
{
char s[ 2 ];
s[ 1 ] = '\n';
for ( int ii = 0; ii < 10240; ii++ {
s[ 0 ] = '0' + ( char ) ii;
write( 1, s, 2 );
}
return( 0 );
}
Guess which one's going to be several orders of magnitude faster?
... and always will be.
Give me ONE good reason what java actually does right?
You need one hell of a machine to run all the crap. It is still not fault tolerant to any degree.
And seeing as it was initialy designed to run video recorders and washing machines, et al, why doesn't it now?
Nick
Like Java, C# is compiled to an intermediate code for a "virtual machine" that is typically JIT compiled for the target processor. I've been amazed at the speed. I'm doing graphics applications where I'm moving bits around manually, and C# is plenty fast! And it's nice to have garbage collection and modern features.
C# also has some other advantages over Java: it's a standard language (it has been submitted to the ECMA standardization committee), and has advanced features like "generic types" (similar to templates), pointers, and good XML serialization support.
Best Buy can have you arrested
There is no excuse for writing anything in C++ in this day and age:
- If you are writing a kernel or an embedded bit whacker or a real-time thing, use C. C++ is too slow.
- If you are writing an application, be it desktop, server, whatever, use Java or C#. C++ is far too unsafe.
- If you are writing a rapid prototype, use PERL, or Python, or Ruby.
My condolances to the KDE kommunity. It's a cool desktop & all (I'm typing on it) but bolting your whole framework on a C++ basis was a really unfortunate choice. It dooms KDE to long-term security vulnerabilities.Crispin
----
Crispin Cowan, Ph.D.
CTO, Immunix Inc.
So, I'm done with my CS degree from RPI, and I'd like to point out we're not all morons like this kid apparently is. Also remember he's just finished his sophomore year, and has probably just taken basic classes like Data Structures and Algorithms and Operating Systems.
It just cheapens my degree, sadly.
--
lds