java versus c++ for a 3d game

Started by
34 comments, last by Ravuya 17 years, 11 months ago
Performance is your primary concern in game programming. Remember, your big game in the future will need the ultra-high performance as possible, so as even the market suggests, C++ is the way to go. Java/C# make excellent web games, retro games, fantastic toolmaker languages, etc., so know where your audience is, then take the appropriate calls.
Advertisement
Quote:Original post by Anonymous Poster
your big game in the future will need the ultra-high performance as possible

Erm, what kind of a game is the OP actually going to program? A MMORPG? :)
I use both languages professionally and I have to recommend that you learn both :)

Java is easier to learn than C++, so that's a good place to start. If you know java, it's not hard at all to switch to C++ since the syntax is basically the same anyway.

Java (j2me) is the standard language when making games for mobile phones, which is a booming market ... right now it's slow as hell, but that has more to do with the phones and how they implement java, than the language itself.

And ... the biggest hurdle when you're making 3D-games is not actually learning a programming language, it's mastering the math needed.
JAVA and C++ are both good, as for preformance I've seen both JAVA and C++ programs running at equal perfromance, depends on exactly what you are doing. JAVA is faster at some things, C++ for others. Don't let people arguning the perfromance band wagon convince you that either JAVA or C++ are bad languages, they are both good for making games, commercial or otherwise. I've seen good games written in JAVA and crap ones in C++. As the others said use which you are most familiar with, you can always port later if performance is such a big issue. Well written code is far more important than performance, optimisation should *always* be the last thing you do.

If you want to see some commercial games written in JAVA check out most cell phone games :). Also you should look into LWJGL. There are many non cell phone games written with this if you look on the projects page.
Quote:Original post by Mushu
Need to write toaster firmware? WHY NOT USE JAVA!


Oh god, I just had a vision of my first full-time job. It was painful.
[size="2"][size=2]Mort, Duke of Sto Helit: NON TIMETIS MESSOR -- Don't Fear The Reaper
I have experience in both C++ and Java, and definitively go for C++.
C++ will always be faster and smaller than Java, simply because a Java program will run inside a Java Virtual Machine which is written in ... C++.
Quote:Original post by Anonymous Poster
C++ will always be faster and smaller than Java, simply because a Java program will run inside a Java Virtual Machine which is written in ... C++.

That's fine, and it is something that I believe, but isn't the point how much faster it is?

I mean if there's an algorithm, which takes 5ms to run in C++ and 6ms to run in java, what's the point of favoring C++ over java with the reason being "C++ is faster."

Does anyone have actual figures on this?
[size="2"][size=2]Mort, Duke of Sto Helit: NON TIMETIS MESSOR -- Don't Fear The Reaper
Quote:Original post by Endar
Quote:Original post by Anonymous Poster
C++ will always be faster and smaller than Java, simply because a Java program will run inside a Java Virtual Machine which is written in ... C++.

That's fine, and it is something that I believe, but isn't the point how much faster it is?

I mean if there's an algorithm, which takes 5ms to run in C++ and 6ms to run in java, what's the point of favoring C++ over java with the reason being "C++ is faster."

Does anyone have actual figures on this?


"I wrote a linear algorithm for factoring integers in Java!"
"Pfft, I bet it's as slow as"
[ search: google ][ programming: msdn | boost | opengl ][ languages: nihongo ]
If we can choose only from these two... One should retain away from java. C++ is better choice because java introduces more new limitations than actual features, and it's few good features you can implement in C++ too.

If you consider yourself being so stupid that you hurt yourself when you get free hands, I'd propose using java, otherwise use c++. You just need better understanding from theory and computers in c++, but it pays off.

It's weird people are calling java a high level language. I've not even seen it's interactive interpreter, even that's best thing in many high level languages, thought, it doesn't seem to exist in java. And java guys didn't seem to know that dynamic typing can coexist with static typing.
~ person who has nothing to say feels itself naked in enviroment where nonsense is hard to camouflage into the nonexistent myriad of noises. ~
Quote:Original post by derekpainter1
after much googling, ive found that c++ is the correct choicce, and java just for smaller games.

No, there isn't a "correct" choice. May beginners assume that C++ is the best choice, because it's widely used. In reality, the only "correct" choice is to use a langauge that:
A: Has support for the features and libraries you need, and
B: you feel comfortable using. If you have experience with C++, but have never used Java, well, I'd suggest using C++.
If you've been using Java for the last 8 years, and love the language? Use that!

Quote:
C++ will always be faster and smaller than Java, simply because a Java program will run inside a Java Virtual Machine which is written in ... C++.

Er, so? A C++ compiler is typically written in... C/C++ as well. What does that prove?
Misinformation overload!

A Java program will *typically* be a bit slower than a C++ program, but it doesn't have to be.
Java is JIT compiled, which in theory allows for *more* efficient code than C++. But as always, it depends on your code, on whatr exactly you need, which compiler you use and so on and so on. But C++ is not "faster" tha Java. Your C++ program, using a specific compiler at specific settings might be faster than your Java program using another specific compiler with specific settings, that's true. And it will often be the case. But that does not mean the lagauge C++ is in itself "faster".

Quote:
C++ is better choice because java introduces more new limitations than actual features, and it's few good features you can implement in C++ too.

Except many of the "limitations" are merely limitations in how many bugs the compiler will fail to detect. Limiting that is a *good* thing. Yes, you *could* implement all the same features in C++ as well, but it'd be much more error-prone, because *you'd be implementing it all yourself, rather than relying on a widely used framework that has been tested to death*. What's more, you could write your entire game in Java in the time it'd take to implement these few features in C++.

I'm not a big fan of Java, but it's ridiculous to say that C++ is a "better" language because you *could* implement other langauges features using it. You could do the opposite as well.
Java has plenty of shortcomings. Stick to using those if you want to criticise the language.

This topic is closed to new replies.

Advertisement