Comments on Java for games, pros and cons

8 Comments.

One place where Java performance is still problematic is if you have to do any sort of low-level pixel-pushing or bit-fiddling, but fortunately those use cases are pretty rare nowadays, especially now with widespread GPU support and programmable pixel shaders.

Personally I do think that the standard Sun Java APIs are pretty craptastic, and it would be nice if there were a way to do direct pass-by-reference on POD without cumbersome hacks like sending one-element arrays down, but as a language goes, yeah, Java’s not bad.

-- fluffy 2017-09-22 12:31 UTC


If by “standard Sun Java APIs” you mean Swing, then I have to agree. Fortunately you don’t need it to make a game. Or do you mean JOGL? I’m yet to do any OpenGL in Java.

-- Felix 2017-09-22 12:31 UTC


I have been working on my own pet project (in java using jogl libraries) for some time, and I have to admit it – the main reason I use it (besides the fact that is the language I know best) is the easiness of handling stuff which otherwise would take “centuries” for one man to put together – in other words: it saves a LOT of time.

I have been doing a small prototype in C++ a while ago(using ogl libraries with win 32 api to be more precise), so I do see the difference in how much of the things are done in a decent amount of time (by one person).

If we are talking about speed… yeah, I guess you will not have Crysis any time soon in java at full details 😊. However, all the other stuff (mostly older OGL versions) goes pretty smooth. There are some ports for things done in C with OGL which are running at almost same speed (give or take 10%). So, unless you want some top benchmark performance – I am good with java/OGL performances, thank you very much 🙂

My current build for the java/OGL engine I am working on runs pretty smooth (that would be 30+ frame rate) on craptastic computer here at work, with an on-board Intel video card that is pretty much ancient. And I am not rendering just 3 vertices on the screen, so to speak 🙂 (well, of course I have some visual optimizations, you can’t have a visual engine without them, can you? no matter the language you are using, 3 million points on the screen will slow you down a LOT).

Of course, you could do same stuff in C# I guess (XNA rulz, and of course it saves time). But guess what – I have a really old version of windows here at work, and since I change computers a lot I can’t exactly afford to install every time .net or the stuff needed for the C# applications every goddamn time (not to mention, their examples crash on me every time, dunno why). On the other hand the java/JOGL stuff NEVER crashed. As in – nevar. Not once. Very stable stuff. And I love stable. Did I mention that? Oh, yeah – I love fast & stable. So that is why for now I will stick to my little JOGL project.

-- Nightwrath 2017-09-22 12:32 UTC


I mean the various standard platform libraries, like J2ME/MIDP, but also things like certain aspects of the base object types. Having Integer, Float, Boolean, etc. be immutable is silly (why not use those as a pass-by-reference mechanism?) and I don’t like how you can’t resize arrays (but I realize Java probably has something like std::vector now) and how strings are immutable (but I realize that helps with pooling and that most uses of mutable strings are better served by StringBuilder anyway),

Still, it feels like much of the base class design is just legacy from when Java was a “theoretically-pure” language that was trying to appease academics, rather than trying to be an actual practical language that real programmers were going to use.

On the other hand, there’s plenty Java got right. Single inheritance with interface aggregation (which is the only sane way to deal with multiple inheritance on C++) and a single base class, class-as-object, reflection, etc. are all very nice for bridging the OO/imperative gap while maintaining strong typing (unlike e.g. Python, JavaScript, etc. which try to go way too far in providing an academically-pure OO in the name of “flexibility”), and recent developments have made Java a nice language for supporting the ad-hoc hacks that C++ has enjoyed in a cumbersome manner for a while (collections, iterators, weak references, etc.).

All that said, right now my favorite language concept is Vala – basically they took C and added all the good parts of C++ and C# while keeping it simple and syntactically-clean.

-- fluffy 2017-09-22 12:32 UTC


Oh, and I *almost* like Java’s compile-time managed exceptions, although personally I’d prefer if the ‘throws’ list were generated implicitly and if the lack of catching were done as a link-level warning. Having it a compile error just encourages crap like

try { … } catch (Exception e) {}

which is worse than useless. If it instead did a link-time warning like:

Warning: Exception NoSuchWidget thrown from someComplexClass.java:47 never caught

I think that people would be better about managing exceptions where they need to be managed. (I realize that this is also fundamentally incompatible with much of how Java’s link model works, but it’s not an intractable problem.)

-- fluffy 2017-09-22 12:33 UTC


Um, fluffy, Java has always had an equivalent of std::Vector, in java.util.Vector (though there is a newer, better version of it called ArrayList). And I’d say managed exception suck, period. 🙂

Vala is indeed nice as a concept. But I fear that conservatism on the part of the programming community will keep it from seeing as much use as it deserves.

-- Felix 2017-09-22 12:34 UTC


😉 Dacă ai timp poate vei testa https://wonderland.dev.java.net/ Te asigur că nu vei regreta.

… And, my english is too bad to be used in a conversation with a romanian. I like Your site; is nice and useful.

😉

-- suntonline 2017-09-22 12:34 UTC


Funny you made the joke about Oracle’s law suit, I came across this article two years after you posted it, and after Googling the Oracle-Google suit discovered today’s the exact day that they start their billion dollar legal battle in court. It’ll be interesting to watch unfold…

And oh yeah…Java’s awesome!

-- NT 2017-09-22 12:34 UTC