Announcing: Slashdot Deals - Explore geek apps, games, gadgets and more. (what is this?)

Thank you!

We are sorry to see you leave - Beta is different and we value the time you took to try it out. Before you decide to go, please take a look at some value-adds for Beta and learn more about it. Thank you for reading Slashdot, and for making the site better!

Java Faster Than C++?

michael posted more than 10 years ago | from the sacred-cow dept.

Java 1270

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.""

Sorry! There are no comments related to the filter you selected.

First Post (-1, Offtopic)

Anonymous Coward | more than 10 years ago | (#9434949)


my arse (-1, Troll)

Anonymous Coward | more than 10 years ago | (#9434956)

Ha, and im richer than bill gates

Re:my arse (3, Funny)

kaffiene (38781) | more than 10 years ago | (#9435087)

"My arse" is a good name for this post since that's obviously where your head is stuck - much like the rest of the /. morons with their anti-java-no-matter-what stance.

I used to be a C hacker and a laughed at Java when it came out because of it's poor performance. Times have changed, but the language bigots haven't.

Re:my arse (1)

Anonymous Coward | more than 10 years ago | (#9435151)

In terms of speed it is un debatable that C is faster than Java because the jvm is written in C and execute bytecode which no matter how intelligently refactored will create one more level of indirection that lets pure C be faster.

Re:my arse (0)

Anonymous Coward | more than 10 years ago | (#9435165)

Looks like you haven't changed a bit!

Re:my arse (0)

Anonymous Coward | more than 10 years ago | (#9435136)

what i want to know is how did they run the benchmark without the java virtual machine.

i'm sure "command not found" is worlds faster then a loop in C++.

FP! (-1, Offtopic)

Anonymous Coward | more than 10 years ago | (#9434957)


Caught up with the speed, but still the ugliest (-1, Offtopic)

Anonymous Coward | more than 10 years ago | (#9434961)

Java might have finally caught up with the speed, but Swing is still the ugliest GUI out there.

Re:Caught up with the speed, but still the ugliest (3, Informative)

mhale2243 (415016) | more than 10 years ago | (#9435064)

True, which is why the eclipse project (www.eclipse.org) created and maintains SWT. A portable native widget tookit. See http://www.eclipse.org/articles/Article-SWT-Design -1/SWT-Design-1.html for more info.

Re:Caught up with the speed, but still the ugliest (4, Informative)

mark-t (151149) | more than 10 years ago | (#9435103)

You haven't played with the pluggable look and feel for Swing much, have you?

Oh... and as of Java1.5, Swing apps can now be skinned to look however you'd like them to.

Re:Caught up with the speed, but still the ugliest (1, Informative)

Anonymous Coward | more than 10 years ago | (#9435175)

By the sounds of it you have no idea what a good GUI is. Skins and themes do not a pretty UI make.

Re:Caught up with the speed, but still the ugliest (4, Insightful)

saden1 (581102) | more than 10 years ago | (#9435119)

I’m sorry but someone who says "I've never been very good at decoding GCC's error messages" is not competent enough to perform performance comparison. This performance test is a shame and shouldn’t be taken seriously.

That just means... (2, Interesting)

SuperKendall (25149) | more than 10 years ago | (#9435131)

You were running Swing with the Windows L&F.

Re:Caught up with the speed, but still the ugliest (-1, Flamebait)

Anonymous Coward | more than 10 years ago | (#9435135)

Java might have finally caught up with the speed ...

I completely disagree, Java is still very slow (yes I have tried the newer versions of Java) and no, they are not fast. Yes compared to un-optimized C++ code which is also crap it might be faster. So what! My 468/25 is just slightly faster than my 486/33 but who cares both of them are no good. You don't see me posting that my 486/33 is whooping the 486/25 does you? Now if you want to do a decent comparison try even comparing Java with just C, oh wait its been done and Java cries when it is compared to C. Which is relatively low level. (that is why the Linux kernel uses it ;o) All you programmers that say you can do anything in Java/C#/etc are terrible. You have no respect for code. Learn assembly and then we'll talk.

My $0.02

Re:Caught up with the speed, but still the ugliest (3, Informative)

C. E. Sum (1065) | more than 10 years ago | (#9435170)

One of the best things about OS X is Aqua-ized Java apps.

http://developer.apple.com/documentation/Java/Co nc eptual/Java141Development/UI_Toolkits/chapter_5_se ction_2.html

c# is faster!!! (-1, Troll)

Anonymous Coward | more than 10 years ago | (#9434962)

c# is faster than java, so is c# faster than c++?

Re:c# is faster!!! (-1, Troll)

Anonymous Coward | more than 10 years ago | (#9435058)

NO WAY. The convicted monopolist could never create something better than java. And once java goes open source, get ready for it to kick the convicted monopolist's ass! Java is the future, and C# are for money hungry assholes.

Um, it's online (5, Informative)

JoshuaDFranklin (147726) | more than 10 years ago | (#9434963)

If you want, you can read the actual author's piece instead of a news story about it:

The Java is Faster than C++ and C++ Sucks Unbiased Benchmark [kano.net]

Re:Um, it's online (-1, Flamebait)

TWX (665546) | more than 10 years ago | (#9435111)

"The Java is Faster than C++ and C++ Sucks Unbiased Benchmark"

Uh, okay... Sure, unbiased you say...

Yes, I need to read it to find out how Java was used, how C++ was used, what compilers or interpreters or runtimes were involved, and what libraries and the like, but until one can write an OS kernel in it, Java is still not what I would personally look to for the future of software development.

Gentoo? (-1, Offtopic)

Anonymous Coward | more than 10 years ago | (#9434964)

I use Gentoo; how does this effect me?

Re:Gentoo? (0)

Anonymous Coward | more than 10 years ago | (#9435186)

i use debian, probably the same way it effects me, but years later.

I agree. (0, Redundant)

James A. S. Joyce (784805) | more than 10 years ago | (#9434965)

"...the more people who know about present-day Java performance, the better."

This person will never know how right they were!

FP! (-1, Troll)

Anonymous Coward | more than 10 years ago | (#9434968)

Not on my PC it ain't!

Good! (0)

Anonymous Coward | more than 10 years ago | (#9434974)

Java Rulez!

The Great Computer Language Shootout (4, Informative)

thebra (707939) | more than 10 years ago | (#9434976)

Correct link [bagley.org]

Yes but... (2, Funny)

Anonymous Coward | more than 10 years ago | (#9434978)

how does it corner?

Sorry, no. (0, Informative)

Anonymous Coward | more than 10 years ago | (#9434983)

Java Faster Than C++?

No, it isn't. It's much slower.

I wrote a program that simply counts to 10000 and then quits. Time from double-clicking the icon until when the program exits:
C++: 0.5 seconds
Java: 20 seconds
How hard is that?

Re:Sorry, no. (0)

Anonymous Coward | more than 10 years ago | (#9435089)

This reveals the inherent weakness of benchmarks. They are statistics, and you can make them lie for you anytime you want.

Perhaps in long-running code once the JIT has had a chance to run, the Java code performs better.... it all depends on the type of benchmark.

Re:Sorry, no. (4, Funny)

Ianoo (711633) | more than 10 years ago | (#9435096)

I think you're missing the point. I bet 19 seconds of that execution time was the start-up and shutdown of the virtual machine. As the program gets bigger and bigger, this becomes less and less significant.

Re:Sorry, no. (0)

Anonymous Coward | more than 10 years ago | (#9435101)

You're spot on there. Java compiled might be as fast, but it's still slower because I have to wait to compile the stupid thing before it runs.

You'll never get Java to be down to same "speed" as C/anything else. It just can't work that way.

Re:Sorry, no. (1)

mveloso (325617) | more than 10 years ago | (#9435105)

Wow, I counted from 1 to 10,000, and it came out much faster. How good of an example is that?

Re:Sorry, no. (1)

SpaceCadetTrav (641261) | more than 10 years ago | (#9435115)

How scientific.

Re:Sorry, no. (1)

Morgahastu (522162) | more than 10 years ago | (#9435126)

Yes. Very scientific. Was it the first time you ran the program? If so than the program is compiled. It's not anytime you run it after that.

Was that JVM running? If not then it had to load the very large VM before running the program.

Try running it a second time and then report back.

Re:Sorry, no. (-1, Flamebait)

Anonymous Coward | more than 10 years ago | (#9435143)

Haha, I sure hope you aren't a programmer by profession. You sir, are a dumbass.

This might be funny, but it isn't informative. (1)

John Harrison (223649) | more than 10 years ago | (#9435144)

I'll explain the joke for the moderators: He is incurring the overhead of launching the JVM, which is significant. In fact, all this tests is that invocation overhead and nothing else.

Re:Sorry, no. (0)

Anonymous Coward | more than 10 years ago | (#9435155)

Did you take into account Java starting the JVM? And did you use the server VM as the article suggested?

Even so, sometimes "faster" processes are not faster for relatively small tasks. For example, Quicksort is accepted as a faster sorting algorithm than Selection Sort. But, for sorting small numbers of items, Selection Sort is faster! You have to be sorting quite a few items before you see the benefit of Quicksort, and eventually it is MUCH faster than Selection Sort.

Re:Sorry, no. (1)

bckrispi (725257) | more than 10 years ago | (#9435157)

This is simply because there is a certain amount of time that it takes the JVM to start up. Once it's up and running, you should see these numbers converge. Setting up a more accurate test, I leave as an excercise for the reader.

Re:Sorry, no. (2, Insightful)

kaffiene (38781) | more than 10 years ago | (#9435164)

You're measuring startup time, not execution speed.


Sorry, yes (1, Informative)

Anonymous Coward | more than 10 years ago | (#9435172)

This means nothing.

That is the most typical benchmark of somebody who doesn't know anything about compiler optimization.

This is almost truly a mark on the compiler making an optimization in one case where the Java compiler doesn't. Assigning to an unused variable is a useless operation. A decent compiler removes the assignment, then notices an empty loop, then removes the loop.

Not to mention, your double-click takes into account the entire VM initialization, which greatly, greatly outweighs the test itself, rendering the test useless on that account as well.

So you end up benchmarking the entire VM initialization with a NOP. Gee, wonder which one's going to win?

This is why benchmarks are hard. This is why the SpecINT benchmarks are notoriously bad as they (at least were) easy to optimize against.


Anonymous Coward | more than 10 years ago | (#9434989)

Yup, it's fast... (-1)

Anonymous Coward | more than 10 years ago | (#9434990)

public class fristPsot extends slashdot()....

My C++OCK can find pussy faster (-1, Troll)

Anonymous Coward | more than 10 years ago | (#9434992)

I did comparision testing between my C++OCK and a Java drinking jock. My C++OCK won balls down.

Props to Penus Torvalds!!

I call shenanigans (-1, Troll)

Anonymous Coward | more than 10 years ago | (#9434994)

I'm sorry but there's just no way.

Java may be fast but ... (0, Troll)

Anonymous Coward | more than 10 years ago | (#9434995)

... C++ is more portable.

Bwhaha What a Troll... and he's full of shit (-1, Flamebait)

Anonymous Coward | more than 10 years ago | (#9434996)

Real world Java applications show that Java is far slower than C/C++.

Keep in mind very long load times for Java, as well as a general lack of responsiveness as it does garbage collection on slower machines.

If you don't run the JVM... (0)

Anonymous Coward | more than 10 years ago | (#9434998)

no one should ever run the client JVM when given the choice

If you don't run the JVM, how do you run your code?

Re:If you don't run the JVM... (4, Informative)

Tar-Palantir (590548) | more than 10 years ago | (#9435039)

He claims you should use the server JVM instead, stating that it is faster but slower to startup and consumes more memory.

Re:If you don't run the JVM... (1)

EmCeeHawking (720424) | more than 10 years ago | (#9435118)

Hey dumbass -

He said not to run the CLIENT jvm.

That still leaves the hotpsot and server jvm options available.

Now go back to the lobotomy ward, fuckhead.

Re:If you don't run the JVM... (0)

Anonymous Coward | more than 10 years ago | (#9435125)

Man, you're stupid.

Netcraft Confirms: (3, Funny)

BandwidthHog (257320) | more than 10 years ago | (#9435002)

Fact: C++ is dying....

Oh hell, I don't have the heart. Nevermind.

Re:Netcraft Confirms: (1)

Lost Dragon (632401) | more than 10 years ago | (#9435092)

C++ is dying? Nah, it hasn't even reached the 20-year "beleaguered" mark yet.

Anyone got a match? (5, Funny)

nebaz (453974) | more than 10 years ago | (#9435003)

Here's some kindling...

vi is better than emacs
bsd is better than linux
gnome is better than kde
anything else?

oh yeah...
my dad can beat up your dad.
And you smell funny.

Re:Anyone got a match? (0)

Anonymous Coward | more than 10 years ago | (#9435071)

Don't forget the classic "Your /. number is bigger than mine"

Re:Anyone got a match? (0, Offtopic)

DAldredge (2353) | more than 10 years ago | (#9435099)

vi = editor
emacs = os

Why are you comparing them to each others?

Re:Anyone got a match? (0)

Anonymous Coward | more than 10 years ago | (#9435108)

And you smell funny.

i knew i shouldn't have changed my deodorant!

Java Convergence (-1, Offtopic)

Anonymous Coward | more than 10 years ago | (#9435006)

For this one it's the X, you retarded?
'Cause i grab the mic and get down, like syndrome
hide and roam into the masses, without boundaries
which qualitifies me for the term "universal"
without no reheasal, i leak words thats controversial
like i'm not the one you wanna contest? see
'cause i'll hit yo ass like the train did that bitch
that got "BANNED FROM TV" -- heavyweight hitter
hit you watch your whole head split up
Loco is the motion, we comin through
Hollow tips is the lead the .45 threw

Pokey (-1, Offtopic)

Anonymous Coward | more than 10 years ago | (#9435009)


Java sucks, pass it on (-1, Troll)

mrshowtime (562809) | more than 10 years ago | (#9435013)

Yah, "present day" Java may be the bee's knees, but I cannot forgive it for it's slow-loading-lock-lock-up-my-computer- past.

Ah...yes... (1, Insightful)

Anonymous Coward | more than 10 years ago | (#9435016)

The great thing about language benchmarks is that there are so many to choose from...

meh (2, Funny)

jnapalm (749376) | more than 10 years ago | (#9435018)

i tried to get first post with my C++ autoposting application...but its too damn slow.

Just one game (1, Interesting)

sien (35268) | more than 10 years ago | (#9435020)

Are there any sizable 3D games, i.e. code that really needs performance written in Java?

Re:Just one game (1)

Troed (102527) | more than 10 years ago | (#9435059)

Yes, on cellphones.

Re:Just one game (1)

SteroidMan (782859) | more than 10 years ago | (#9435112)

Not until someone ports either OpenGL or DirectX to Java. OpenGL has a JNI implementation (blech!), and last time I checked Microsoft was banned from ever touching Java again. Summary: Fat chance.

Re:Just one game (2, Informative)

Mindcry (596198) | more than 10 years ago | (#9435158)

unreal uses a java like scripting language, but its for gameplay code, not the actual rendering, however, i think that's as close as it comes right now. (the java like stuff is something like 20x as slow as the c++ code, cause of the overhead etc)

P.S. a lot of gameplay code is also in c++ and compiled into dll's (i believe), but mods dont have access to the headers to compile c++ code into the game readily.

IL2 Sturmovik is Java (0)

Anonymous Coward | more than 10 years ago | (#9435188)

IL2 Sturmovik [il2sturmovik.com] is mostly Java. IIRC, only the rendering itself was done in native code for performance. With the advent of JOGL, even that can probably be done well in Java.

Developers: World Flat, Sky Green (0, Troll)

random coward (527722) | more than 10 years ago | (#9435028)

And Microsoft is more stable than Linux.

Re:Developers: World Flat, Sky Green (0)

Anonymous Coward | more than 10 years ago | (#9435129)

Microsoft isn't an OS. It's a company.

He used g++ to compare C++ with Java... (4, Insightful)

exp(pi*sqrt(163)) (613870) | more than 10 years ago | (#9435031)

...on x86? Please! Wake me up when someone who knows enough about C++ to pick a decent x86 compiler runs some benchmarks.

Of course it's faster -- (1)

ianbnet (214952) | more than 10 years ago | (#9435033)

Java uses Star Trek Transporter technology! To beam cows no less (front page of java.com, right now).

What's C++ got? Grappling hooks?

Nort really surprising (0, Troll)

Anonymous Coward | more than 10 years ago | (#9435037)

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?

Cross platform (2, Informative)

leakingmemory (750252) | more than 10 years ago | (#9435048)

Java's strength is mostly it's cross platform compatibility. I have never really liked C++ very much. It seems complicated to write cross-platform code with C++. (Header troubles, and all OSes seems to have it's own implementation. Ie. try to compile Linux code on FreeBSD, and opposite) As a conservative coder I therefore prefer C, which is as fast as you (the coder) make it.


EmCeeHawking (720424) | more than 10 years ago | (#9435190)

W'ow, yo'u stu'pi'd git, y'ou fu'cked' i't u'p a'ga'in!

Benchmarks (1)

AnomalyConcept (656699) | more than 10 years ago | (#9435060)

The benchmarks page is down. I'm getting the 'slash hole' page. Does anyone know what these benchmarks are? And, is it an accurate comparison between the object-oriented nature of Java vs. C++ (which, as far as I've done, doesn't really have true oo support)?

Re:Benchmarks (1)

thebra (707939) | more than 10 years ago | (#9435162)

Working link: LINK [bagley.org]

every year this happens... (0, Flamebait)

Sebastopol (189276) | more than 10 years ago | (#9435067)

When the following two pieces of code are written in Java, I'll take it seriously:

1) a java compiler for java (funny that the java binaries are written in C++ and compiled with a compiler written in C++)

2) id's next game engine

Re:every year this happens... (1)

furball (2853) | more than 10 years ago | (#9435189)

The current java compiler for java from Sun is written in Java. It's always been written in Java.

One down. One to go.

Languages vs Compilers (5, Insightful)

Anonymous Coward | more than 10 years ago | (#9435070)

Java and C++ are language. Languages aren't "faster" or "slower", but compilers for them might be. I find it somewhat underhanded to put the languages in the header when it's really comparing compilers.

Not to mention, inter-language compiler benchmark[et]ing is notoriously difficult to get 'right'. The programs tested are often stupid (doesn't do anything meaningful), or constructed by a person with more skill/bias for one language than the other.

-O3 (1, Insightful)

Anonymous Coward | more than 10 years ago | (#9435078)

If you care about run-time speed when using gcc you compile with -O3.

I'd like to see the benchmarks redone with this.

Re:-O3 (1, Informative)

Anonymous Coward | more than 10 years ago | (#9435094)

Don't forget strip -s

As usual... (-1, Offtopic)

Texas Consultant (690764) | more than 10 years ago | (#9435079)

The "reality" of the situation is more complex than our political and social identities would let us admit. Screw it, I'm heading to a Buddhist monastery, and I'll let the rest of you rot in dhamma-fixation.

Watch the flamefest unfold in realtime! (0)

Anonymous Coward | more than 10 years ago | (#9435081)

This is gonna be mean.

morons nearly as fast as robbIE's fauxking (-1, Offtopic)

Anonymous Coward | more than 10 years ago | (#9435084)

pateNTdead PostBlock devise.

from a previously PostBlocked post

YRO: kode developed to counter robbIE's whoreabull fauxking pateNTdead PostBlock devise. (Score:mynuts won, even more pretending)
by Anonymous Coward on Tuesday June 15, @03:10PM (#9433204)
where did they ever get all those dialups?

more guys like this, a few less billyonerror/stock markup FraUD softwar gangster felons, & the wwworld would be a better place.

HELSINKI, Finland, June 13 - If Tim Berners-Lee had decided to patent his idea in 1989, the Internet would be a different place.

Instead, the World Wide Web became free to anyone who could make use of it. Many of the entrepreneurs and scientists who did use it became rich, among them Jeffrey P. Bezos ( Amazon.com), Jerry Yang ( Yahoo), Pierre Omidyar ( eBay) and Marc Andreessen (Netscape).

But not Mr. Berners-Lee, a British scientist working at a Geneva research laboratory at the time. That is why some people think it is fitting - or about time - that on Tuesday, Mr. Berners-Lee will finally be recognized, with the award of the world's largest technology prize, the Millennium Technology Prize from the Finnish Technology Award Foundation. The prize, valued at 1 million euros ($1.2 million) is supported by the Finnish government and private contributors.

The Internet has many fathers: Vinton Cerf and Robert Kahn, who came up with a system to let different computer networks interconnect and communicate; Ray Tomlinson, the creator of e-mail and the "@" symbol; Ted Nelson, who coined the term hypertext; and scores of others.

But only one person conceived of the World Wide Web (originally, Mr. Berners-Lee called it a "mesh" before changing it to a "web"). Before him, there were no "browsers," nothing known as "hypertext markup language," no "www" in any Internet address, no "U.R.L.'s," or uniform resource locators.

Because he and his colleague, Robert Cailliau, a Belgian, insisted on a license-free technology, today a Gateway computer with a Linux operating system and a browser made by Netscape can see the same Web page as any other personal computer, system software or Internet browser.

If his employer at the time, CERN, the European Particle Physics Laboratory in Geneva, had sought royalties, Mr. Berners-Lee said he thought the world would have 16 different "Webs" on the Internet today.

"Goodness knows, there were plenty of hypertext systems before that didn't interoperate," he said in an interview on Sunday as three days of award ceremonies began here.

"There would have been a CERN Web, a Microsoft one, there would have been a Digital one, Apple's HyperCard would have started reaching out Internet roots," he said. "And all of these things would have been incompatible."

Software patenting today, Mr. Berners-Lee said, has run amok. In April, Microsoft was awarded a United States patent for the use of short, long or double-clicks on the same button of a hand-held computer to start applications, according to a report earlier this month on eWeek.com. At the same time, Microsoft said last week that it was appealing a $521 million judgment - the second-biggest patent-infringement award - won by a Chicago company called Eolas Technologies over plug-in applications in Internet browsers.

Due to excessive bad posting from this IP or Subnet, anonymous comment posting has temporarily been disabled. You can still login to post. However, if bad posting continues from your IP or Subnet that privilege could be revoked as well. If it's you, consider this a chance to sit in the timeout corner or login and improve your posting . If it's someone else, this is a chance to hunt them down. If you think this is unfair, we just don't care. if you want to whine, go get yOUR own fauxking corepirate nazi puppet blog.

Nice to hear... (4, Insightful)

twocoasttb (601290) | more than 10 years ago | (#9435088)

It's been ages since I've programmed in C++, but it's good to know see these favorable comparisons. I think about the Struts/Hibernate/Oracle applications I write today and shudder when I imagine what how difficult it would be to have to develop web applications in C++. C++ will be around forever and certainly has its place, but long live Java.

Java is still more expensive (0, Offtopic)

filesiteguy (695431) | more than 10 years ago | (#9435090)

...but accordiing to the unbiased and objective Microsoft study, Java under Linux on a 3090 mainframe is still more expensive to run than NT Server 5 on a whitebox machine with dot net. What do they say to that? Hell, I'll stick with coding in whitespace. What do y'all think of this routine: K

This doesn't make any sense... (-1, Troll)

3) profit!!! (773340) | more than 10 years ago | (#9435091)

How can emulation (running Java in a virtual machine) be any faster than running a native executable?

Re:This doesn't make any sense... (4, Informative)

Ianoo (711633) | more than 10 years ago | (#9435160)

Java isn't "emulation". Modern JVMs use a JIT (just-in-time compiler) to translate bytecode instructions into pure binary assembled object code just before it is reached in the program (hence "just in time"). This is cached, so the next time that particular code is executed, it will run at full assembler speed.

Something I've often wondered is whether this caching could be persistent, i.e. be kept between runs of the JVM. Eventually, the entire program would be translated to pure assembler with the cost of translation largely amortised across many sessions. You still keep the safety, cross platform compatibility and ease-of-programming of a bytecode language (i.e. Java, C#) but you get the bonus of the cached object code being just as fast, even during startup and shutdown.

A few points... (5, Insightful)

mindstrm (20013) | more than 10 years ago | (#9435107)

There seem to be some unanswered questions here..

- How equivalent were the benchmarks? Where they programmed in an optimum way for their respective compilers and libraries? I'm sure the java ones were.. what about the C++ ones? The author states he doesn't understand G++ very well.

G++ is also known to not produce the best results.

"I rant it with -O2"

My guess is many of the tests were not implemented properly in c++.

The main clue would be this... I can understand java having better than expected performance.. but there is no way I can accept that java is that much FASTER than properly done C++... it doesn't make any sense.

Could use a good analysis (5, Interesting)

GillBates0 (664202) | more than 10 years ago | (#9435113)

The results are very non-intuitive. An extra layer between the program -> CPU implies an extra amount of overhead - be it any layer (VM at the Application layer, VM at the OS layer, or even at the CPU layer (hyperthreading)).

I looked at his results page quite extensively, but failed to find a good analysis/justification of the results. Just saying that the Server JVM is better than the Client JVM is *not* enough.

I want to know where the C++ overhead comes from, which Java manages to avoid - does the JVM do better optimization because it is given a better intermediate code (bytecode)? Is it better at doing back/front end optimizations (unlikely given gcc's maturity).

I tried to look for possible discrepancies in the results, but the analysis will definitely take more time - and I think it's the job of the experimenter to do a proper analysis of the results. Liked his choice of benchmarks though.

Java is dying (-1, Troll)

Anonymous Coward | more than 10 years ago | (#9435134)

It is official; Yahoo confirms: Java is dying

One more crippling bombshell hit the already beleaguered Java community when IDC confirmed that Java market share has dropped yet again, now down to less than a fraction of 1 percent of all programming language use. Coming on the heels of a recent Yahoo report [yahoo.com] which plainly states that Java has lost more market share, this news serves to reinforce what we've known all along. Java is collapsing in complete disarray, as fittingly exemplified by failing dead last [samag.com] in the recent Sys Admin comprehensive networking test.

You don't need to be a Kreskin [amazingkreskin.com] to predict Java's future. The hand writing is on the wall: Java faces a bleak future. In fact there won't be any future at all for Java because Java is dying. Things are looking very bad for Java. As many of us are already aware, Java continues to lose market share. Red ink flows like a river of blood.

Let's keep to the facts and look at the numbers.

Sun leader Scott McNealy states that there are 7000 users of J2EE. How many users of J2ME are there? Let's see. The number of J2EE versus J2ME posts on Usenet is roughly in ratio of 5 to 1. Therefore there are about 7000/5 = 1400 J2ME users. GCJ posts on Usenet are about half of the volume of J2ME posts. Therefore there are about 700 users of GCJ. A recent article put J2SE at about 80 percent of the Java market. Therefore there are (7000+1400+700)*4 = 36400 J2SE users. This is consistent with the number of J2SE usenet posts.

Due to the troubles of Java, abysmal sales and so on, Sun went out of business and will probably be taken over by IBM who sell another troubled programming language. Now IBM is also dead, its corpse turned over to yet another charnel house.

All major surveys show that Java has steadily declined in market share. Java is very sick and its long term survival prospects are very dim. If Java is to survive at all it will be among programming dilettante dabblers. Java continues to decay. Nothing short of a miracle could save it at this point in time. For all practical purposes, Java is dead.

Fact: Java is dying

New benchmarks show... (0)

Anonymous Coward | more than 10 years ago | (#9435138)

Java is now faster than machine code!

But seriously...this is entirely dependent on code design. Java people and C++ people are terrible at it (else how could they like these languages?). And I'm not about to RTFC to find out how they cooked this one up.

the more people... (1)

bsDaemon (87307) | more than 10 years ago | (#9435139)

that know about present-day java performance, the more people will use java. is that really "the better?"

Riiiiiiight (1, Flamebait)

SmallFurryCreature (593017) | more than 10 years ago | (#9435140)

I only know one thing. That the 2 java programs I use, freenet and azureus, are horrible monsters, nice ideas but badly implemented.

Compared to similar applications written in real languages (meaning any language that is not java) they are crash prone, give idiotic debug statements, suck up memory and easily get the "too many open files" error on linux.

I guess this is like "Windows nowadays is very stable" bit. You can show all the benchmarks and tests but I will let my daily experience be the judge and use reports such as this as the toilet paper it is.

To be fair, freenet does work on linux and windows as does Azureus. This is for me the only selling point.

Perhaps java is faster then C++, it is hard for me too judge. But until Java developers start writing better programs, Sun makes sure Java is really cross platform, and games (the ultimated performance applications) start being written in java I will file this with all the other reports on how java will take over the world and is the best, fastest, easiest.

Expert results (5, Insightful)

otterpop81 (784896) | more than 10 years ago | (#9435145)

Some of the C++ tests would not compile. I've never been very good at decoding GCC's error messages, so if I couldn't fix a test with a trivial modification, I didn't include it in my benchmarks.

That's Great! I can't figure out GCC's error messages, but I offer definitive proof that Java is faster than C++. Nice.

Largest Prime (0, Flamebait)

Boyceterous (596732) | more than 10 years ago | (#9435166)

ever discovered with Java: 1 (still waiting on that next one, I guess it's garbage-collecting) Can we build a grid-based garbage collector?

I don't actually care hugely about performance (5, Interesting)

Omnifarious (11933) | more than 10 years ago | (#9435169)

I care that Java is an inconvenient pain to develop in and use. I care that I have to start a mini-OS just to run a Java program. I care that the language is under the control of one vendor. I care that the 'intialization == resource allocation' model doesn't work in Java. I care that the type system is too anemic to support some of the more powerful generic programming constructs. I care that I don't get a choice about garbage collection. I care that I don't get to fiddle bits in particular memory locations, even if I want to.

I think Java is highly overrated. I would prefer that a better C++ (a C-like memory model, powerful generic programming, inheritance, and polymorphism) that lacked C++'s current nightmare of strangely interacting features and syntax.

I use Python when I don't need C++s speed or low-level memory model, and I'm happier for it. It's more flexible than Java, much quicker to develop in, and faster for running small programs. Java doesn't play well with others, and it was seemingly designed not to.

Besides, I suspect that someone who knew and like C++ really well could tweak his benchmarks to make C++ come out faster again anyway. That's something I've noticed about several benchmarks that compare languages in various ways.

C++ has some shortcomings. (1)

Krapangor (533950) | more than 10 years ago | (#9435174)

Because of the enforced compatibility with C the object system consists basically of structs with a virtual method array instead of a real object system. As we have no object orientated instructions at pseudo-code level there is no possibility of optimizing at object call dispatch level we can only tackle with the lower stack calls and register handling. And at this point the 2 decades old architecture of the Intel processors shoots the compiler into the foot.
I wouldn't be surprised if the same results would be completely different on a mac, possibly running Yellow Dog Linux (Java couldn't exploit the threading system so much in this configuration).
Further I think that the exessive use of function inlining used in C++ is harming. It blows the code up s.th. it doesn't fit into the cache anymore which leads to tremendous slowdowns. This won't happen with Java as people aren't so inline-fixated there.

Java vs. C++ (1)

sameerdesai (654894) | more than 10 years ago | (#9435176)

We used to simulate our computer architecture projects in our graduate studies and often noticed java code to be very very slower than C++. Even the superscalar processor [simplescalar.com] code is written in C++. Ultimately I feel whatever these tests show people find C++ easier and faster to develop good simulation software and overall much better.

Flawed Test (3, Insightful)

Emperor Shaddam IV (199709) | more than 10 years ago | (#9435182)

Comparing one C++ compiler (gcc) against the Java JVM on one operating system is not much of a test. I love Java, but this is almost something like microsoft would do. Test one specific OS, compiler, and configuration, and then make a blind, far-reaching statement. A fair test would include several platforms and compilers.

Some problems I had using Java (2, Funny)

Anonymous Coward | more than 10 years ago | (#9435191)

I don't want to start a holy war here, but what is the deal with you Java fanatics? I've been sitting here at my freelance gig in front of a Java program (running on a PIII 800 w/512 Megs of RAM) for about 20 minutes now while it attempts to copy a 17 Meg file from one folder on the hard drive to another folder. 20 minutes. At home, running an equivalent Visual Basic program on my Pentium Pro 200 with NT 4, which by all standards should be a lot slower than this Java program, the same operation would take about 2 minutes. If that. In addition, while it is running, Netscape will not work. And everything else has ground to a halt. Even jEdit Lite is straining to keep up as I type this.

I won't bore you with the laundry list of other problems that I've encountered while working on various Java programs, but suffice it to say there have been many, not the least of which is I've never seen a Java program that has run faster than its VB counterpart, despite Java's faster runtime system. My 486/66 with 8 megs of ram runs VB programs faster than this 800 mhz machine runs Java at times. From a productivity standpoint, I don't get how people can claim that Java is a "superior" language.

Java addicts, flame me if you'd like, but I'd rather hear some intelligent reasons why anyone would choose to use a Java over other faster, cheaper, more stable systems.
Load More Comments
Slashdot Login

Need an Account?

Forgot your password?