Java is fast?

Started by
110 comments, last by rip-off 17 years, 11 months ago
Quote:Original post by MasterQ
Java vs. C++

Or use this link:
http://java.sys-con.com/read/45250.htm?CFID=388847&CFTOKEN=9460D898-B6BB-AC8B-3C74121E272A4D92

In these tests java outperforms optimized C++ even with the initial JIT delay at the beginning.

For every fact I think you can find one webpage disclaiming that fact. That doesn't prove (or disprove) anything.
Quote:The results he got were that Java is significantly faster than optimized C++ in many cases.

I'd like to hear ONE reason why that is even possible. An EXPLANATION, not just a statement.
Quote:Some of the C++ tests would not compile. "I've never been very good at decoding GCC's error messages," he admits, "so if I couldn't fix a test with a trivial modification, I didn't include it in my benchmarks."

Ok so what we have here is a lame C++ programmer claiming Java is faster? Give me a break. He probably also doesn't know how to turn inlining on or off (to start with).
Advertisement
And none of the games listed are very impressive. A java "port" of quake2 that take advantage of modern graphics hardware, where the original version was written before the time of GPUs (so not optimized for T&L at all, and probably dont do any batching). Yeah thats a really fair comparison.

Why do java game programmers go on about how great java is for game development, while nobody actually make any modern-looking games? It this just a general lack of good java programmers? Hobby teams can achieve very impressive games when using c,c++ etc, and if java is actually so much more productive, wouldnt similar teams using java create even more impressive games?
Quote:Original post by MasterQ
Java vs. C++

Or use this link:
http://java.sys-con.com/read/45250.htm?CFID=388847&CFTOKEN=9460D898-B6BB-AC8B-3C74121E272A4D92

In these tests java outperforms optimized C++ even with the initial JIT delay at the beginning.


Java is not faster than C++, how can it be? C++ can always be optimised down to the fastest code possible, whereas Java is always going to contain extra overhead.

Ignoring the worst Java/C++ comparison page I have ever seen, for any real world application writing it in C++ will almost always produce a faster application than a Java one. In my experience writing graphical applications with Swing always seem to run *painfully* slowly, especially when compared to a C++ version written in QT or something.

I don't mind people discussing how Java can be as fast as a C++ application. It pains me inside however when somebody comes out with a comment like:

Quote:Original post by MasterQ
I already know that java outperforms C++...
"Leave it to the computer programmers to shorten the "Year 2000 Millennium Bug" to "Y2K." Isn't that what caused this problem in the first place?"
Quote:Original post by MasterQ
Java vs. C++

I tried the methcall tests, which they claim is about 7 times faster with Java versus C++.

My results were that the C++ version ran for 7 seconds, while the Java version took 14 seconds, for n = 1000000000 on an Athlon 64 2.4 GHz. I'm actually impressed by that, seriously, but it's still 14 times slower than what they claim. And it makes me wonder how the other tests really compare. Some of them should be more than 14 times slower with Java, using the same math...

The C++ test was built with Visual Studio 2005, default Release build with no extra optimizations! The Java version was built using NetBeans 4.1 and the runtime that came with it.
Quote:Original post by C0D1F1ED
The C++ test was built with Visual Studio 2005, default Release build with no extra optimizations! The Java version was built using NetBeans 4.1 and the runtime that came with it.


To be 'fair', you should use the server Java VM, because it is reportedly faster than the client version.
Quote:Why do java game programmers go on about how great java is for game development, while nobody actually make any modern-looking games? It this just a general lack of good java programmers? Hobby teams can achieve very impressive games when using c,c++ etc, and if java is actually so much more productive, wouldnt similar teams using java create even more impressive games?


I believe that is because most people is worried about getting a job in the industry. Java developers usually have a normal job and program games in their spare time.

I really believe Java is a better way of developing software in this current point in time (things may change in the future) because it provides a complete environment: excellent tools, an impressive standard library which is 100% sure to be found in all platforms that runs a JVM, loads of open source software, etc.

My personal opinion regarding game programming is that in a more dynamic environment like the JVM we can move on from the "engine" paradigm (I'll build ALL you will ever want for programming a game) to a more service oriented paradigm.

This is not putting functions in DLLs, this is providing self contained services.

This is the advantage of Java that can be used in game programming, and I'm doing it in my spare time.

PS.: Please don't come with "we can do it in language X", you can do it in assembly if you want, that's not the point. The point is that in Java we can explore its technological characteristics in game development. Instead of being "as fast as C++" we should use Java by its own merits.
Arguing about the speed of a language (rather than the code) is like arguing about the speed of a road (rather than the car).
But both the performance and code associated with java are lackluster ;)

*No const modifier.
*No operator overloading (except for the String class, which in itself should convice you that the language is really badly designed).
*Really bad support for generic programming (cant use it with primitives, generic classes storing different object types are actually same type etc).
*No support for call by reference on primitive types, so you need to wrap everything in objects.
*Lots of calls to new (like initializing an array, where you need to loop and use new afaik).
*Only very recent support for enumerations and not very flexible compared to c++ afaik ( I like to use enumerations when indexing arrays, makes everything much nicer to read and easier to comprehend).

I could go on...
And the design of the language largly dictates the performance you can get, since it influences the programming style and the possible optimizations.
Hi,

There are many claims flying around this topic. Figured it is time to add my own!

- Java is easy to reverse engineer

It is true Java Bytecode is easier to reverse engineer but Bytecode Obfuscators exist which make this a lot harder. Really good Obfuscators can even reduce the size of the Bytecode and make it more efficient.

- Java is easier to program

Studies (IDC 1998) have shown using Java as opposed to C++ resulted in a 25% overall time/cost saving which is about a 30% productivity increase.

- Java is faster!

As others have pointed out it can be, but generally is not. The newer JVMs are ridiculously clever using hotspot and JIT compilation on Bytecode. The real benefit comes because the JVMs are able to perform optimisations that could never be performed at compile time.

"You don't have to search through too many blogs or Slashdot postings to find confidently worded statements like "Garbage collection will never be as efficient as direct memory management." And, in a way, those statements are right -- dynamic memory management is not as fast -- it's often considerably faster."

http://www-128.ibm.com/developerworks/java/library/j-jtp09275.html


- Chris

"More computing sins are committed in the name of efficiency than for any other single reason - including blind stupidity" - William Wulf

"Any fool can write code that a computer can understand. Good programmers write code that a human can understand"

This topic is closed to new replies.

Advertisement