Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


C++ V.S Java for game programming.


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
32 replies to this topic

#21 Cornstalks   Crossbones+   -  Reputation: 6991

Like
0Likes
Like

Posted 24 January 2012 - 03:03 PM

Meanwhile, most C++ apps made using Visual Studio need to install a 12 to 32 MB Visual Studio runtime package...


It's a 4.8 MB Download, which is hardly significant...
[ 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 ]

Sponsor:

#22 alnite   Crossbones+   -  Reputation: 2133

Like
0Likes
Like

Posted 24 January 2012 - 03:45 PM

Why would download size be a problem to a programming language? If anything, I'd say that's platform's issues. If Windows doesn't ship with VC++ runtime by default, then that's kind of Windows fault. If Windows doesn't ship with a JRE, then that's Windows fault, which is obvious since they are promoting .NET.

If I write an application for Mac OS X, whether that be in Java or C++, I'd use the most compatible libraries for Mac OS X, right?
If I develop for Android, hey use Java, unless I want to go deeper to the native, then I'd use C++.

#23 medv4380   Members   -  Reputation: 98

Like
-4Likes
Like

Posted 24 January 2012 - 04:19 PM

C is best if you're going for speed.

C++ has many of the same slowdowns as Java does now. In fact today Java7 is about as fast as C++.

Java is in limbo in terms of support. The buyout of Sun by Oracle resulted in several years of Java 6 and left Java 7's updates out in the cold. Nothing like having to wait 5 years for a JSR updates that were ready to go to be integrated in. If Java 8 is released on time then that drawback is over, but if I have to wait 5 years again I will be upset.

Java tends to have outdated API's that people insist on trying to use in games, and API's that weren't tailored for games. For example Key Listeners that were intended for Swing Gui's don't work well in games. Java Sound has been neglected for years, and because of legal issues the JMF was abandoned along with MP3 support.

You'll need to get a real game api for java like lwjgl. Otherwise you're asking Java to do things in a way it wasn't designed for.

C and C++ is easier to port to consoles. XBox, Wii and PS3 do not have a real JVM supported for games. The PS3 has a slimmed down JVM for Blue-Ray functionality only.

#24 Antheus   Members   -  Reputation: 2397

Like
0Likes
Like

Posted 24 January 2012 - 04:21 PM

If Windows doesn't ship with VC++ runtime by default, then that's kind of Windows fault.
...
then that's Windows fault, which is obvious since they are promoting .NET.


A related topic was once discussed regarding steam installs, where each game installs its own DX and runtime.

In short, each application will almost certainly install VC or DX runtime due to licensing reasons. Microsoft forbids distribution of certain files in any form, except for the one provided by them.

So even on Windows, when using DX, your application will need to deliver stock MS installer for DX and VC redist. One cannot, for example, modify the installer to download only the missing dlls. Same for .Net.

For DX or .Net, it's even more important since legacy versions (ones required, tested or supported by a release) might no longer be easily available for end user download.

Silly, but that's the way it is.

#25 medv4380   Members   -  Reputation: 98

Like
0Likes
Like

Posted 24 January 2012 - 04:29 PM

If Windows doesn't ship with a JRE, then that's Windows fault, which is obvious since they are promoting .NET.


No Microsoft is forbidden from bundling a Java Virtual Machine with Windows due to being caught being evil. http://en.wikipedia.org/wiki/Microsoft_Java_Virtual_Machine

#26 Hodgman   Moderators   -  Reputation: 31920

Like
1Likes
Like

Posted 24 January 2012 - 05:51 PM

C is best if you're going for speed.
C++ has many of the same slowdowns as Java does now. In fact today Java7 is about as fast as C++.

Uh, [citation needed]
I'd like to see a benchmark proving this, where it wasn't simply because someone had written crappy C++ code.
You should be able to get the same assembly out of a C and C++ solution to a problem...

#27 SimonForsman   Crossbones+   -  Reputation: 6318

Like
0Likes
Like

Posted 24 January 2012 - 05:52 PM


If Windows doesn't ship with a JRE, then that's Windows fault, which is obvious since they are promoting .NET.


No Microsoft is forbidden from bundling a Java Virtual Machine with Windows due to being caught being evil. http://en.wikipedia....Virtual_Machine


They are forbidden from bundling their own incompatible JVM, They could license Oracles (But they don't want to do that, as the court case showed they intentionally made their version incompatible in an attempt to make many Java applets non portable and thus reduce the threat of crossplatform applications)
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!

#28 alnite   Crossbones+   -  Reputation: 2133

Like
0Likes
Like

Posted 24 January 2012 - 05:53 PM


If Windows doesn't ship with a JRE, then that's Windows fault, which is obvious since they are promoting .NET.


No Microsoft is forbidden from bundling a Java Virtual Machine with Windows due to being caught being evil. http://en.wikipedia....Virtual_Machine

Interesting, especially the embrace, extend, extinguish strategy.

Is there any anti-trust law that's preventing Microsoft from installing the same JRE that's provided by Sun/Oracle (rather than creating their own)?

#29 Álvaro   Crossbones+   -  Reputation: 13933

Like
0Likes
Like

Posted 24 January 2012 - 07:44 PM


C is best if you're going for speed.
C++ has many of the same slowdowns as Java does now. In fact today Java7 is about as fast as C++.

Uh, [citation needed]
I'd like to see a benchmark proving this, where it wasn't simply because someone had written crappy C++ code.
You should be able to get the same assembly out of a C and C++ solution to a problem...


Here: http://shootout.alioth.debian.org/

If you don't like the crappy C++ code of any of the implementations, I think there are ways for you to submit a better one. But C and C++ are pretty much the same in that comparison.

#30 Hodgman   Moderators   -  Reputation: 31920

Like
0Likes
Like

Posted 24 January 2012 - 09:00 PM

Here: http://shootout.alioth.debian.org/
If you don't like the crappy C++ code of any of the implementations, I think there are ways for you to submit a better one. But C and C++ are pretty much the same in that comparison.

Yeah the C/C++ ones are almost the same, and Java is generally much more RAM heavy...
However, I just picked the "binary trees" test at random to look at the C and C++ versions, and this isn't a benchmark of C vs C++ at all! It's actually a benchmark of Apache pools vs Boost pools, seeing as the choice of memory pool API is the only significant difference between the two versions of the code.

You could say that APR is more idiomatic for C, and Boost is more idiomatic for C++ (in which case, you're still benchmarking "idiomatic libraries" instead of benchmarking the actual languages), but both versions of the code are using malloc/free/sprintf, instead of their idiomatic equivalents... so this benchmark isn't at all valid as a way to compare languages, or even as a way to compare "typical" usage of languages!

#31 medv4380   Members   -  Reputation: 98

Like
0Likes
Like

Posted 24 January 2012 - 11:08 PM

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.

#32 Cornstalks   Crossbones+   -  Reputation: 6991

Like
0Likes
Like

Posted 25 January 2012 - 12:34 AM

For the love of all things holy,

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?
[ 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 ]

#33 SimonForsman   Crossbones+   -  Reputation: 6318

Like
1Likes
Like

Posted 25 January 2012 - 12:49 AM

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




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS