C++ and Java on Game Programming

I am opening this topic simply because I just feel like discussing some advantages and disadvantages that both C++ and Java have for Games. I want to see some interesting arguments but I swear I don't want this to grow a battle between guys who like only C++ or Java even though I prefer C++ over Java, I do not want to start a random argument of "Java is awesome, C++ sucks" or "C++ is awesome, Java sucks" because that is how it always turns out unless someone yells to stop it like an expert or something (which I believe almost never happens, not sure I don't pay attention to the forums as much as I should). Now lets start off with some of my current contributions:

Java disadvantages C++ advantages:
C++ uses optional access to classes while Java requires classes. (Not a big deal for some but I just don't like it being forced on me)

Java is based off of both C++ and C (originally) so much of the syntax is similar

Java has no struct or unions

Java advantages C++ disadvantages:
Java has a larger and more rounded library so you do not need to write for everything you need as it probably already exists

Java ports between anything with Java Binaries installed on it and while C++ could probably have this with the right library, the differences between systems since C++ directly accesses the Processors are so varied almost anything you write will end up subjective according to the Computer running it.

The primitives of C++ are not objectively defined of which could cause issues with cross platforming anything.

Those were what I could name and even though that was not game programing based I want to hear the differences in relation to Game Programing. Good Luck with what you have to say.
First, this should really go to the Lounge: Click 'Edit Post' and move it.

How is Java being based off C a disadvantage? If anything, it just means that it is just as easy to use either.

Java has a larger and more rounded standard library so you do not need to write for everything you need as it probably already exists

Just because Java's standard library is larger doesn't mean that C++ has a larger library in general - last time I checked, there was a far larger code base of useful things written for C and C++ than for Java.

Java ports between anything with Java Binaries installed on it and while C++ could probably have this with the right library, the differences between systems since C++ directly accesses the Processors are so varied almost anything you write will end up subjective according to the Computer running it.

The primitives of C++ are not objectively defined of which could cause issues with cross platforming anything.

This is Java's main advantage, but you seem to have misunderstood it. C and C++ were designed so as to be inherently cross-platform (in the original sense of the word) - as in, the programmer doesn't need to know anything about the system to program for it, all of that stuff is left to the compiler vendors. Nevertheless, there are some parts that have to be platform dependent in game programming, such as when your optimization gets to the stage of throwing in Assembly, but mostly your problems can be avoided by using cross-platform libraries rather than the native windowing system (e.g. SFML over XLib).

Java has no struct or unions

Unions are an optimization technique that isn't used very much at all, so I would say it isn't a great loss. However, why does it matter that it doesn't have a struct? The only difference between a struct and a class in C++ is that one is public by default and the other private, and this makes no difference in Java because you have to explicitly specify anyway.

Now I'll add some of my own considerations:

C++ has more optimization techniques available, partly due to it being able to access the underlying mechanisms of the machine, though it doesn't have to.

Java is more RAD than C++ - you can generally create the same application faster in Java than C++ due to the amount that you have to set up in C++, though this can be mitigated with cross-platform libraries. The downside is less control, which is optimization possibilities lost, though you only need to optimize where your profiler tell you!

Java encourages good programming behaviour, and in my experience it is harder to accidentally make problematic bugs in Java than in C++, due to it limiting what you can do (and thus stopping you from using unsafe or confusing language mechanics).

These are just a few things I though of off the top of my head. Its been too long since I programmed in Java...
Topic archived. No new replies allowed.