Skip to main content
GameDev.net gamedev.net
🔒 Locked

A Benchmark, C++ vs Java

Started by nakor May 20, 2004 at 12:56 PM 79 replies 8.4k views
Original Post
nakor
nakor
http://www.kano.net/javabench/ I found this on google today, and I thought I would share. Any thoughts on this? I mean I always hear about how Java is _SO_ slow compared to C++. Please don''t turn this into a Java vs C++ flamewar.
Palidine
Palidine
quote:
Original post by nakor
Please don''t turn this into a Java vs C++ flamewar.



um...perhaps if you didn''t want a flamewar you shouldn''t have posted an article titled: "The Java is Faster than C++ and C++ Sucks Unbiased Benchmark". how this cannot become a flamewar escapes me.

-me
antareus
antareus
quote:
Please don''t turn this into a Java vs C++ flamewar.

Too late, you used "vs" in the title.

The guy that runs kano.net is a Java apologist, for what it''s worth.
--God has paid us the intolerable compliment of loving us, in the deepest, most tragic, most inexorable sense.- C.S. Lewis
zoggo
zoggo
Java/C++ benchmarks are hardly worth the time it takes you to read them. People can always argue stats both ways or say they are unfair or just talk plain bullshit.

One way to test Java''s performance: Build an app using it and try it yourself. Experiance is worth a thousand benchmarks.

The Java/C++ perpetual-flamewar-machine has always been fueled by idiots with either little or inaccurate information. (Often both) What Java needs more than anything is someone have faith and prove that fast apps can be written by writing one.

Speaking of which, advert time: My Amateur Game Project
dmikesell
dmikesell
Well, I''m convinced. Time to port my Nested Loop (tm) application to Java...
Zipster
Zipster
This is almost turning into a flame war on how this is destined to turn into a flame war. The irony is bittersweet.

For future reference to everyone, just because you put "please don''t turn this into a flame war" at the bottom of your post doesn''t make you any less responsible when a flame war does begin You can''t feign innocence, the proof is in the pudding! Muahaha!
_DarkWIng_
_DarkWIng_
Get your azbestous suits and falmethrowers here for just 19.99€.

You should never let your fears become the boundaries of your dreams.
You should never let your fears become the boundaries of your dreams.
Matei
Matei
Has anyone actually tried running this benchmark themselves?
nonnus29
nonnus29
quote:
Original post by zoggo
What Java needs more than anything is someone have faith and prove that fast apps can be written by writing one.

Speaking of which, advert time: My Amateur Game Project


Dude, your page is a poor advert; you could at least wait until you have some screen shots to show...

gommo
gommo
I find benchmarks like this so funny. It was even linked to from an intro to soft eng course at the uni I went to (they teach java). The way academics talk you''d think all programs just consisted of algorithms you learn in 1st year university.

As some of the previous posters have said, show us a Java (GUI) application that runs as fast a native app and we''ll start believing you!! Why people think Java HAS to be fast in this department eludes me though, Java is great for what it does, and is great for server components etc.. For games and real time applications I''ll go c/c++ anyday.
the Speed Bump
the Speed Bump
I feel as though I am validating myself by getting in on this soon-to-be stunning intellectual debate while it''s only a single page long.
"There is only one everything"
Last Attacker
Last Attacker
quote:
Original post by Anonymous Poster
It''s completely obvious that this guy has no idea how to program in C++...he couldn''t even decipher and fix errors listed by gcc for simple programs; how are we supposed to expect that he knows how to optimize a C++ program?



Back stabber!
Only cowards hide behind "Anonymous Poster" posts to say anything they want to in a bad light! Besides, there''s no reason to brag that you know more about c++ than him. Give the poor guy a break, he just asked for a benchmark, not a FLAME-mark!


// Last Attacker \\---=( LA )=---// LA Extreme \\

ICQ Number : 120585863

E-mail: laextr@icqmail.com

"Take delight in the Lord and He will give you your heart's desires" - Psalm 37:4My Blog
zoggo
zoggo
quote:
Dude, your page is a poor advert; you could at least wait until you have some screen shots to show...


Yea I know! Sorry, but I am still trying to recruit people. I have a number of volunteers now, but at the time of that post I was desparate for a new way of saying *bump*. Sorry for any harm done to the Java cause.
Rishtar
Rishtar
Yeah, just reading that page makes me think that the person who made it might not be the most reliable source of information there is. On the other hand, he does have very pretty graphs...

Anyway, correct me if I''m wrong, but isn''t Java based entirely C with the added overhead of being an interpreted language? It seems to me that Java shouldn''t be any faster than C or C++ in any test.
Arild Fines
Arild Fines
@ AP:

He stated explicitly several times that he used the server VM. You didn''t.
--AnkhSVN - A Visual Studio .NET Addin for the Subversion version control system.[Project site] [IRC channel] [Blog]
zoggo
zoggo
The latest "hotspot" vm from Sun, picks the most used (hotspots) in code to JIT compile. This has the odd effect of meaning that loops will run slowly for the first few iterations and then, as hotspot realises its importance, it will be compiled to native machine code. Not only that, the loop doesn''t have to finish for the hotspot JIT to work, it can replace currently executing code with a JIT compiled version. Very clever.
Alpha_ProgDes
Alpha_ProgDes
JITs convert the bytecode to machine code correct?
so that would make the game "non-cross platfrom". right?

so (going by this assumption) would the benchmark be more valid or correct if it was based on the bytecode produced by Java vs. the C++ object code (i guess it would be machine code)?

i hope i made sense....
Beginner in Game Development?  Read here. And read here.  
Zahlman
Zahlman
No, it converts the bytecode to the machine code of *the current platform*, *while it is running*. This is possible because the VM for each platform is programmed to be aware of the local machine code. Run the Java code on a Mac, it executes bytecode and then seamlessly compiles parts of it into PPC machine code, on the fly, substituting these bits into the execution path. Similarly on x86, creating x86 machine code.

I have no idea how they make all of that work, though.

FWIW, the C++ object files aren''t particularly cross-platform either.
Arild Fines
Arild Fines
quote:
Original post by Zahlman
I have no idea how they make all of that work, though.


This book goes into quite some details on how the .NET JIT engine works. I assume the principles are pretty much the same for Java.

--
AnkhSVN - A Visual Studio .NET Addin for the Subversion version control system.
[Project site] [Blog] [RSS] [Browse the source] [IRC channel]
--AnkhSVN - A Visual Studio .NET Addin for the Subversion version control system.[Project site] [IRC channel] [Blog]
Etnu
Etnu
Java VM''s are written mostly in C with some ASM thrown in.

Hence, there is absolutely no reason at all why a C / ASM should run slower than a Java program.

The obvious explanations exist for why the benchmarks were slower:

1.) The person doing the benchmarks is biased (somewhat likely)

2.) The person doing the benchmarks didn''t use ''equivilent'' algorithms for each program (highly likely)

3.) The benchmarks being used are too "simple" - that is, the JVM is capable of executing the generated bytecode (or machine code) with virtually no bytecode overhead, hence running at the exact same speed as native languages. Again, this should only provide for performance that is (at best) equivilent of the native code (very likely, as the VM''s are well designed for the most part).

4.) The guys writing the benchmarks are complete hacks and/or just aren''t anywhere near as good as the programmers writing the VM''s (also very likely).

The fastest execution you will EVER get is by compiling to native languages - period. You simply can''t get any faster, because this is the best the processor can do.

That isn''t to say that C#, VB, or Java aren''t "fast enough", because for many applications, they are. But to say that they''re "just as fast as" or even "faster than" C/C++ is a statement that only a very stupid individual would make.
---------------------------Hello, and Welcome to some arbitrary temporal location in the space-time continuum.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.