Java vs. C++ for my game?

Started by
14 comments, last by redshock 6 years, 10 months ago

It seems like this sort of questions is amazingly popular. I see two similar ones just in the first page here.

But I am so excited about this that I'd like to share my own situation and get some personal advice from you in this crucial first step.

Please :)
__________________

I would like to develop my own game. I have a game idea which I like and I am also acquainted with programming to some level.
I am a QA engineer and my boss would love it if I learned Java.
My game will be a 2D top view spacecraft fighter. Initially, single player but I have ideas for multiplayer.
Imagine: Asteroids but with capital ships, alien ships, moving between universes.
PROBABLY swap the vector graphics for raster... That rotate and scale as the player is moving around and
zooming in and out.
It will graphically be quite old fashioned. There's a semi-complete game from 20 years ago that inspired me: Hell Fighter
I don't know much of any programming language. I use Java here and there but it's mostly googling around for ready code.
Do I need to learn C++ or Java?
The upside of Java is that it is going to be useful at work and it is easy to learn and work with.
The upside of C++ - and maybe I am wrong!!! - is that it performs much better and my code will be protected from copying.
I fear that eventually I'd have to use C++, because of performance. But how much performance do I actually need?
Projectiles will be plenty and they will be free, with genuine collision detection (not like Warcraft, where projectiles are
merely animation)

2006-2007: Game Designer, Ubisoft (King Kong, Brothers in Arms, Rayman Raving Rabbits and a few more shipped titles)

Advertisement

Maybe start out with Java and eventually port to C++, when game features and load exceed Java's performance limits?

2006-2007: Game Designer, Ubisoft (King Kong, Brothers in Arms, Rayman Raving Rabbits and a few more shipped titles)

Java will be fine for the type of game you suggest. You can probably use that with LibGDX for what you want. https://libgdx.badlogicgames.com/

Java will be fine for the type of game you suggest. You can probably use that with LibGDX for what you want. https://libgdx.badlogicgames.com/

What about code security? If I keep the game in Java, wouldn't people be able to read the code, clone the game, induce cheats?

2006-2007: Game Designer, Ubisoft (King Kong, Brothers in Arms, Rayman Raving Rabbits and a few more shipped titles)

They can do most of that with C++ too, it's just a bit harder, and requires different tools. It should be the least of your worries, to be honest. Most games will never be popular enough to inspire cheats. Any singleplayers that are popular enough don't matter, because the player is only cheating themselves. And if it's a multiplayer game, you would protect against cheating by other means (such as running the main game on a server, or by checking that all players are synchronised).

Sounds like Java is the way for you to go, if it's useful to you professionally then that's a big deal and Java will do the job just fine (do you know Minecraft was coded in Java?). As Kylotan mentioned, look into using LibGDX, it's a game library for Java.

Compiled code security is virtually a non-concern for the vast majority of applications for the vast majority of developers. And because Java is compiled (and so is C++) the original source code is not available to be read. Of course if you go and host your source on github then anyone can see it anyway.

And because Java is compiled (and so is C++) the original source code is not available to be read.

This is only partially true. You can decompile Java and get something very similar to the original source code. Obfuscating can help, but I don't know how well that works in practice (there are tools for de-obfuscating Java). C++ is, practically speaking, impossible to decompile. You can disassemble it, which could be enough for a cheater, but actually turning the executable back into working code is a huge task that I don't think any cheater will care to try.

You can disassemble it, which could be enough for a cheater, but actually turning the executable back into working code is a huge task that I don't think any cheater will care to try.
He/she doesn't need to, the disaasmbly shows the byte values of the program, so you can easily find that in the binary, and change the code by changing that to whatever instruction it should do instead.

You can decompile Java and get something very similar to the original source code.

Yes it is true that certain original symbols (e.g classnames and method names) are maintained in the compiled .class files and because Java maps pretty well to the underlying bytecode it means that decompiling bytecode to Java can produce a fairly faithful reproduction of the logic structure.

What I should have been saying is more along the lines of: Because Java is compiled to bytecode rather than interpreted from source, it means the original sourcecode including all symbols, comments, use of generics, etc is not shipped as-is to the client in plaintext for anyone to trivially read in their favourite text editor.

It's quite true that via decompilers you can get fairly workable code out of .class (or .dex) files. Which is much better than what you can get from say, a decompiler and a native lib, which basically will just declare a bunch of variables with register names, assemble something resembling a function declaration with a bunch of void*, and call it a day.

With that said, even if you're making a native game, you have to work out a way so the server can verify the information the client is sending. You can't rely in "oh it's a native file so users wont modify it!" and not check what the client is telling you. So whatever you chose, you'll have to do the legwork all the same and make up a scheme that lets you verify what the client is telling you.

Now if the game is single player, do you honestly care that much that people modify the game? Let them eat cake.

"I AM ZE EMPRAH OPENGL 3.3 THE CORE, I DEMAND FROM THEE ZE SHADERZ AND MATRIXEZ"

My journals: dustArtemis ECS framework and Making a Terrain Generator

This topic is closed to new replies.

Advertisement