Would it be worth porting to c++?

So after reading a lot on this forum a lot of people are intent that for game programming you SHOULD go with c++ , I am thinking about doing it but it seems like a lot of effort for a very small gain. The reasons for it is that its more efficient and that it’s more well used however the reason why I don’t want to do it is because I can see that java as a language in a whole is getting a lot more powerful , 8 years ago no doubt I would’ve switched to c++ but I can see from now that high quality games built purely in java that are able to implement hardware acceleration more and more efficiently.

What do you think if of course you kept with the way that java is going and its performance is it worth porting over?

Would it really matter for anything other than an AAA level game?

Exactly. Are you going to be able to create a game of better quality if you take that route?

Most likely not. Java is perfectly fine for indie games

The question you have to ask yourself is how much performance do you need, and will switching to C++ allow you to get that extra performance where Java didn’t.

Simply having control over the memory you’re using can allow you to make pretty decent optimisations, but at the same time you have to be very careful to not make mistakes.

Unless you are looking to get intimate the industry I would not bother.

Add I’ve said to others before, for the sake of learning go for it. For practicality stick with what you know.

You will probably get no performance gain by switching to C++. I got a performance gain (about 5%) when switching from C/C++ with GLUT to Java with JOGL and I have never looked back. I’m still surprised by those who complain about the garbage collection because you get some problems when you do something seriously wrong and it has nothing to do with the language itself. I admit that I don’t use any physics engine yet.

Even 8 years ago I wouldn’t have switched to C++.

In my humble opinion, port it only to target platforms that you can’t target with Java but then, is it worth the efforts??

What about using LibGDX? From what I’ve read, LibGDX does the performance critical stuff in C/C++. And you get the added benefits of automatically handling ports to mobile devices (Android, iOS, and Blackberry).

There is also jnigen, which allows you to write native methods with c++ code right next to the native method for anything that could have improved performance with native code.

I think there’s a pretty big overhead in the JVM for calling native functions.

A few nanoseconds per JNI calls, this isn’t what I would call “a big overhead”.

There is also GlueGen, used in JogAmp (JOGL, JOAL, JOCL, …).

I prefer to write my own implemented engine in opengl , it allows me to write it much more freely and I can create the functions as I would like.

A lot of you are missing the point: performance doesn’t need to have anything to do with choosing C++ over Java. By writing your game in Java you are restricting yourself to platforms that run the JVM. You have to rewrite your entire project if you want it to run elsewhere. However, if your game is written in C++, all platforms become viable because C++ compilers are ubiquitous. If you have carefully designed your project, the bulk of your code will not need to be ported, and you will only have to make adjustments for different graphics/audio/input libraries. This is not trivial, but it is manageable.

Also, if you ever want your game to appear on a console–aside from the OUYA–you can’t write it in Java.

In defense of Java and portability, you can target all Desktops, android, ios and html5 and it is easy to set up with libgdx. So unless you are developing something more than a spare time project that would do well on console then it probably doesn’t mater if you use Java or not. Should you have a break out success then port to C++ to get on consoles or pay someone to do it.

C++ is bloody hard to write fast code in. Really. Java is much more forgiving in this respect.

Portability is indeed something to consider. But if your not trying to sell out to a console out of a gate, it is probably not such a concern. If you are, use the native tools for that console, or give unity a go. C# is not all gold, but i would work with it sooner than C++.

BTW i did a lot of contract C++ work back in the day. And i shudder every time i recollect those days.