• Advertisement
Sign in to follow this  

java versus c++ for a 3d game

This topic is 4254 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hello, this professor at a college near me said to learn java for my game program even though i've read that C++ is the standard for games. anyone know if there's any reason to learn java? or if 3d games are going to be programmed in java? he said that c++ is not necessarily faster than java.

Share this post


Link to post
Share on other sites
Advertisement
Personally, I have little experience with programming in Java. From what I hear from other, more experienced members of GD, Java might be a little slower because it runs on a virual machine, but in the end, the limiting factor will be the way you program it, and any slow-down from the java virtual machine won't matter.

I haven't heard of a game being programmed in java, but, again, I have little experience with these things.

I did I search of devmaster.net's database of engines. I searched for 'Java' as the programming language and came up with 14 engines. On the other hand, I then searched for 'C/C++' as the language and came up with 205 engines.

Share this post


Link to post
Share on other sites
Uhhg. I hate professors like that.

And lets not get into the realm of performance discussion; I think its irrelevent.

While yes, you can program games in Java, since most development is in C++ there are many more resources (documentation, libraries, etc) which deal specifically with C++ rather than Java. I'd personally recommend using C++, simply because programming in Java makes me want to drink a bottle of lye while committing seppuku as I'm being drawn and quartered after having been set on fire while being stretched on the rack with bamboo up my nails and pinecones up my butt.

If you do go the Java route, you'll probably want to take a look at JOGL (Java bindings for OpenGL). AFAIK, its the best Java graphical API that I've seen so far. There's SDL bindings somewhere too, but I've heard they're pretty crap.

But yeah. Yuck, Java.

Share this post


Link to post
Share on other sites
You can make a 3D game in almost any language. C++, Java, VB, Python, etc are all perfctly valid. However, all of these languages will have advantages and disadvantages. C++ has been around a while and most commercial games are programmed in C++. That being said, java is still an excellent choice. Java is slightly slower than C++, but is also easier to use. There are tons of libraries, engines, and resources availablke for both languages.

Which language do you have more experience with? Programming a 3D game is going to require a strong knowledge of your language, so I would pick the one you are most familiar with.

Share this post


Link to post
Share on other sites
i have experience with C++, i have never programmed in java before. maybe he said java because id be more marketable? who knows, im not sure why he said java, but he said that the students basically all learn java.

Share this post


Link to post
Share on other sites
Well, I can't speak for anyone in particular, but at my uni they teach all of the introduction to programming courses in Java for some reason. I guess Java has become the "introductory" language, probably because its "safe". Meh.

What I've seen happen to a lot of people is they become over pragmatic about the language and try to force its use in every situation. Need to write toaster firmware? WHY NOT USE JAVA!

The fact of the matter is, though, that most of the infrastructure for game development is in the realm of C/C++. This is due to the history of games - for the past decade most of the development has been in C/C++, so that's where all the resources are.

I'd recommend to just stick to whatever language you're most comfortable with. One problem with game development is that it takes a massive knowledge base - not only how to program, but many other techniques (engine design, graphics, blah) which can be difficult to master if you're still just learning the in's and out's of a language.

But yeah, follow your heart? Something like that. I need to stop watching Disney movies...

Share this post


Link to post
Share on other sites
Quote:
Original post by MushuWhat I've seen happen to a lot of people is they become over pragmatic about the language and try to force its use in every situation. Need to write toaster firmware? WHY NOT USE JAVA!


Actually, that's exactly the sort of thing Java was originally developed for.

Share this post


Link to post
Share on other sites
I might just be a weird person(probably) but I find C++ easier than Java. I've used both quite a bit also.

Share this post


Link to post
Share on other sites
Quote:
Original post by Surg
I might just be a weird person(probably) but I find C++ easier than Java. I've used both quite a bit also.


Obviously, if you have more experience with C++, then that is what you will be more comfortable with. With my day job, I have focused on being a Java developer for the past 6 years, so I happen to like Java more. (Although, I did create a simple 2D asteroids game using directx and MS Visual C++ six years ago - but I would never by choice program in C++ again. Although using the new APIs like the SDL library seems like it would make things easier than they were then.) For Java developers who are interested in 3D programming, I would recommend going to www.jmonkeyengine.com. It is one of the best Java 3D scene graph engines available. It is easy to learn and use. I think most people would be surprised what Java can do (compared to C++ or other languages). What matters to me is how fast I can prototype something, and develop it. So far, I am happy with the Java Monkey Engine. It seems to be just the right tool/engine to do this. ( In the same way, I also like Wings 3D, compared to other 3d modelers - seems to be very easy to learn and efficient as a modeling tool - but that is off topic)

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
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.

Share this post


Link to post
Share on other sites
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? :)

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
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++.

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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"

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Hi, the JMonkey 3d java engine is quite good, and although it couldn't propably compete with Ogre, it has it's features.

You aren't necessarily stuck with C++ and while the performance issues with Java are sometimes true, the downfall of learning a complex language is something you'd best avoid at first.

I've programmed a C++ engine from the ground up (failed horribly) and if you're just a beginner like me, that's a pitfall to avoid.

JMonkey Engine
Screenshots

Share this post


Link to post
Share on other sites
Quote:
Original post by Spoonbender
Except many of the "limitations" are merely limitations in how many bugs the compiler will fail to detect. Limiting that is a *good* thing.


I don't think coexistence of dynamic typing would limit the capablities to detect errors of the compiler. Limiting without exception is the most evil thing what language designer can do in order to cripple language users who knows what they want.

Quote:
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++.


You propably find these features implemented already if you look around enough. And it is not that much.

Quote:
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.


I'm not saying C++ is better. Just propose using it because it provides you more tools to use. If somebody hangs itself with those tools because doesn't know how to use them, it is not the issue.

Share this post


Link to post
Share on other sites
Just to add to people's comments. You say you already have C++ experience, so I say you should stick with C++. Java has some disadvantages such as timers aren't brilliant compared to C++. However, advantages include auto grabage collection and no need to worry about pointers (although this might be a disadvantage sometimes). But as mentioned before, games can be created in either. Google "Tribal Trouble". It's a 3D games and IIRC it was made in Java, and I havent had any problems with speed or anything. The main reason I'd recommend C++ is the vast amount of resources available, and the fact that your already familiar with it.

Share this post


Link to post
Share on other sites
Quote:
Original post by phi
Java has some disadvantages such as timers aren't brilliant compared to C++.

System.nanoTime() is pretty accurate:

Returns the current value of the most precise available system timer, in nanoseconds.

I doubt you could make a more accurate in timer in C++.

Share this post


Link to post
Share on other sites
Quote:
Original post by Fred304
Quote:
Original post by phi
Java has some disadvantages such as timers aren't brilliant compared to C++.

System.nanoTime() is pretty accurate:

Returns the current value of the most precise available system timer, in nanoseconds.

I doubt you could make a more accurate in timer in C++.


Is that only implemented in the latest version? From what I read, Java had a lack of high-precision timers that could be used in games, and that dev's usually put the main thread to sleep. If that's no longer the case, I stand corrected.

Share this post


Link to post
Share on other sites

This topic is 4254 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Guest
This topic is now closed to further replies.
Sign in to follow this  

  • Advertisement