C++ V.S Java for game programming.

Started by
31 comments, last by SimonForsman 12 years, 2 months ago
This should satisfy your benchmark source request, and it should give you an ample number of languages to do additional comparisons.
http://shootout.alio...rg/u32/java.php

First Java7 has vastly improved from Java6 but that's 5 years of updated given in 1 version.

Java 7 beats C++ and C in the the K-Nucliotide benchmark by 4 to 5 seconds.
http://shootout.alio...=java&lang2=gcc
Java 7 beats C++ in the fasta benchmark by ~1 second but loses to C by .1 seconds
http://shootout.alio...=java&lang2=gpp

C flat out wins or nearly ties vs C++ in everything except the K-Nucliotide test
http://shootout.alio...g=gcc&lang2=gpp

C when written properly beats C++ hands down.
The drawback of C is really that some more complex tasks are a pain to write without objects.

Java's main drawback is usually memory, but it's not as bad as most people think. Sure you have some where the Binary-Tree test ends up with Java taking nearly 5x the amount of memory C does, and on even small tests it still has to load a 10-15 meg virtual machine. However, somethings like the reverse complement test it takes nearly the same amount of memory as C does.

Java also attracted every programmer who was incapable of managing memory properly in C and C++ so there are a lot of bad memory structures out their in Java because at least it doesn't do the delayed crash thing C and C++ does when you mess with the memory the wrong way. Just because java has a garbage collector doesn't mean you can ignore memory, but that's what a lot of Java programmers do.
Advertisement
For the love of all things holy,

[size=7]WHO CARES?

You can't even benchmark a language. You can only benchmark a particular implementation of a language and a particular usage of that language, both of which are highly sensitive to change (use a different language implementation or a different programmer, and BAM! all the numbers change).

Can we please, please let this thread die?

[size=2][ I was ninja'd 71 times before I stopped counting a long time ago ] [ f.k.a. MikeTacular ] [ My Blog ] [ SWFer: Gaplessly looped MP3s in your Flash games ]

This should satisfy your benchmark source request, and it should give you an ample number of languages to do additional comparisons.
http://shootout.alio...rg/u32/java.php

First Java7 has vastly improved from Java6 but that's 5 years of updated given in 1 version.

Java 7 beats C++ and C in the the K-Nucliotide benchmark by 4 to 5 seconds.
http://shootout.alio...=java&lang2=gcc
Java 7 beats C++ in the fasta benchmark by ~1 second but loses to C by .1 seconds
http://shootout.alio...=java&lang2=gpp

C flat out wins or nearly ties vs C++ in everything except the K-Nucliotide test
http://shootout.alio...g=gcc&lang2=gpp

C when written properly beats C++ hands down.
The drawback of C is really that some more complex tasks are a pain to write without objects.

Java's main drawback is usually memory, but it's not as bad as most people think. Sure you have some where the Binary-Tree test ends up with Java taking nearly 5x the amount of memory C does, and on even small tests it still has to load a 10-15 meg virtual machine. However, somethings like the reverse complement test it takes nearly the same amount of memory as C does.

Java also attracted every programmer who was incapable of managing memory properly in C and C++ so there are a lot of bad memory structures out their in Java because at least it doesn't do the delayed crash thing C and C++ does when you mess with the memory the wrong way. Just because java has a garbage collector doesn't mean you can ignore memory, but that's what a lot of Java programmers do.


You have to remember that it is still not a language benchmark, its a benchmark of various benchmark programs for a set of language implementations and while it does give you an idea of how fast something can be done with a specific implementation you really have to look at the code to see why the results are the way they are. (the C(GCC) implementation of binary trees for example uses OpenMP for parallell for loops while the Java implementation is singlethreaded.
For the K-Nucliotide benchmark both Java and C have multithreaded implementations but use fairly different approaches to the multithreading itself (Which has a huge impact, I'm guessing that the Java version wins simply due to the difference in threading methods used (Writing safe and well performing multithreaded code is alot easier in Java than it is in C))

C has both the fastest and the slowest implementations in alot of the tests, (CINT being the big loser and GCC usually the winner (both are C implementations)).

Performance have very little to do with the language (Allthough Javas fairly strict precision requirements does give it a disadvantage on platforms such as x86 and ARM for some operations), the code you write will always be the most important part followed by the quality of the compiler/VM/runtime you use to build/run the application.
[size="1"]I don't suffer from insanity, I'm enjoying every minute of it.
The voices in my head may not be real, but they have some good ideas!

This topic is closed to new replies.

Advertisement