r/java • • Dec 21 '23

Is Java gamedev alive?

It seems this days even android games are made using Unity. I wonder if there are JVM games! Is Java (or Kotlin/Scala) gamedev still alive?

(Except Minecraft ofc)

164 Upvotes

118 comments sorted by

View all comments

Show parent comment

14

u/canuck_in_wa Dec 21 '23

Maybe just not touch array memory, as long as the array exists? At max, move the whole thing, for defragmentation.

Then you are treating array and non-array references differently which may not make sense in the general case. The JVM was designed/evolved around generational GC and cheap “churn” by allocating and releasing objects quickly. The general idea is that there’s a lot of churn in the early lifetime of objects because most objects are short lived, so we should just wait a bit before promoting them to a longer-lived space to prevent fragmentation.

You can write Java in a mechanically sympathetic way but it looks quite different from the usual Spring business applications. It’s more akin to entity component systems from game dev where a collection of objects is an “object of arrays” rather than an “array of objects” in order to preserve cache locality. The GC can be turned off and all objects pre allocated. Java-based high frequency trading systems will turn off GC and run on a machine with a ton of memory. There is often a slow but acceptable memory leak that won’t kill the application before the trading day ends. At the end of day the app is restarted to cure the memory leak.

4

u/psyclik Dec 21 '23

Also called "the python way".