For creating a game, is Java or C++ better?
Me and a friend what to team up and program together.
The problem is I primarily know Java, he C++. Note we're both still newbies - better than somebody who's just taken a programming course - but still far away from being experienced programmers.
Our current plan is to first program a 2d game together, and then we'll see what we feel like doing next (I personally think it would be cool to take a loot at some open source engines).
So the question is, what are the pros and cons of each language considering the circumstances I just described?
16 comments
[ 4.4 ms ] story [ 60.0 ms ] thread2. Java, because it is way easier. C++ is an expert only language.
It's what most game engines are done in. You get more control over performance. You can go all the way down to the metal if you want/need to.
Use anything. Finish a game. Worry about the best technology next time.
I know because i've done tutorials and started projects far too complicated to finish in Unity, Gamemaker and C++. I wasn't even aware of how counterproductive it was to actually finishing a project because in the moment it feels like you're making progress, but you're usually not, at least as far as finishing the game is concerned.
For Java, http://libgdx.badlogicgames.com/ is really popular these days. For C++, you have unreal engine, but you can just roll your own with SDL or SFML.
The /r/GameDev community on reddit has a wealth of information if you are just starting out, I'd start with http://www.reddit.com/r/gamedev/wiki/getting_started and http://www.reddit.com/r/gamedev/wiki/engine_faq
Although, if you care more about education than shipping, why not try building the same game in both? You would each learn how it's done in both languages and you could test which seems better.
If you can develop a game in a garbage collected strongly typed language with a [mostly] cross platform run time that sometimes allows you to forgo porting when moving between platforms and minimizes the amount of porting when it is required, then that seems like a good way to go.
Selecting a "faster" language only matters if there is a performance bottleneck and the "faster" language happens to be faster in exactly a way that removes the bottleneck. Most performance bottlenecks are IO or algorithmically based.
Even deeper, I'd consider prototyping in a scripting language because scripting languages make it easier to iterate quickly than enterprise class compiled languages. For a game, gameplay rules and a fast game with gameplay that sucks still sucks. And the scripting language game may be good enough.
Carmac used C++ for Doom. It was the first game I stayed up all night playing. My rig had a 160 megabyte Hard drive, 5 megabytes of RAM, and a 25 megahertz AMD CPU. These days I download 160 megabyte files without a pause and there are webpages with 5 megabytes of JavaScript...and Quake [not Doom] can run in a Browser.
Focus on shipping. Choose tools for that purpose.
Good luck.
If you want something more efficient/performance, C++. If you really want to get into game programming: C++. If you're still learning basics about programming: Java. If you want something that's memory managed, and easier to write: Java.
So boil it down to what you need to do and what you are both more capable of doing. Likely Java will happen faster and get it launched, which is usually more important initially than raw performance. So maybe that is the way to go at least initially.
I generally focus mostly in C/C++, Javascript (some Go now) and the like, no Java anymore. Just putting my bias out there so you know.
Java pros: memory safety, documentation, it just f'ing works.
C++ pros: not relevant to your situation.
Particularly read frau_dh's comment.
1. http://gameprogrammingpatterns.com/game-loop.html