Live data from Hacker News

For creating a game, is Java or C++ better?

news.ycombinator.com

11–17 of 17 posts

Re: For creating a game, is Java or C++ better?

#11
post #7
post #4

C++ 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.

It's a bit of a cliche for newbie game developers to get instantly sucked into engine-development/performance-concerns and then never actually birth their _game_ idea. Use anything. Finish a game. Worry about the best technology next time.

I maybe should have mentioned we both have already made a simple game (coincidentally both of us did Space Invader). The 2D game idea is supposed to be a stepping stone getting us to the same level before we try 3D, and we both are the type of person who thinks it's cool to optimize things. ;)

Re: For creating a game, is Java or C++ better?

#12
My two cents:

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.

Re: For creating a game, is Java or C++ better?

#14
Honestly, either is possible to build a game in. However, if you want to or will need to use the GPU you will likely want to stick with C/C++. There is nothing that says Java is bad or evil, implemented properly it is a completely viable language and tool. C++ is just closer to the hardware and will be more performant most of the time, but not always. You can implement some real crap in C/C++ that will perform worse than Java would. And speed to market generally favors languages like Java and C#.

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.

Re: For creating a game, is Java or C++ better?

#15
I'd go with Java. I wrote a bot in Java back when I barely knew any programming, and it wasn't really that hard. C++, on the other hand, would have cripplingly slowed me down -- because it already had, when I tried it as a newbie. Keep in mind, that's when I knew almost nothing and a "LinkedList" was an abstract novelty to me -- I'd written a few games in TI-BASIC and QBASIC 4.5. A few years later, when I was more clueful, I used Java for what was essentially a 2D game and it was nice.

Java pros: memory safety, documentation, it just f'ing works.

C++ pros: not relevant to your situation.

Particularly read frau_dh's comment.

Re: For creating a game, is Java or C++ better?

#16
Proper usage of C++14 should remove the "expert" and "difficult" mystique surrounding it. In fact, I would say that nowadays, it's easier than Java. But that's not really what you should be looking at. Instead, consider what library you want to use. In the end, that is what will make it easy or hard for you.

Re: For creating a game, is Java or C++ better?

#17
About 5-6 years ago, I chose Java when I was in a similar position and writing a game. It's a much easier language (I don't feel like justifying this claim, others have done so) and the final product is easier to share with friends (package your code in a runnable jar when you're done). One other word of advice, I found it simpler to write my own basic engine rather than learn another. If I had my current level of experience, I would definitely start by learning an engine. However, if you don't have a lot of experience coding, it might be easier to write it yourself. For example, you won't need to figure out the documentation for plugging into the game loop because you will have written your own game loop. (1)

1. http://gameprogrammingpatterns.com/game-loop.html

Post reply on HN