I've been using Java mostly for stuff that runs from the terminal and I always wondered why there are almost no games developed with it. I know this submission is not about games but it's related.

The very few games that run on the Java platform are very resource hungry, even more than some alternatives made in JS which is supposed to have a worse performance.

All that while C# is booming on indie game dev.

C# is better for gamedev for quite a lot of reasons, but most importantly because it has value types (structs) that aren’t boxed. In gamedev you use a lot of small-size types such as Vector3 or Vector4 for all sorts of math, but if you implement them naively in Java you have to always heap-allocate them, which brings severe penalties in terms of cache locality and GC. Modern Java gamedev libraries like JOML tries to avoid this by using NIO buffers (JVM provides some utilities to manually alloc/dealloc memory), but the API is quite finicky as a result. (Plus, there is no operator overloading in Java, which is another bummer.) Project Valhalla is trying to add proper value types to the JVM, but sadly as of today the project seems a bit abandoned... (See https://wiki.openjdk.java.net/display/valhalla/Main)

> Project Valhalla is trying to add proper value types to the JVM, but sadly as of today the project seems a bit abandoned...

The repo seems to have very recent activity, has commits from today! https://github.com/openjdk/valhalla