I mean, Minecraft is enough to prove that. It's the best selling game in the world. And a lot of people play Java Edition, not Bedrock Edition. If game works great in Java, it means it's possible to make games in Java. It has its limitations, though.
Here's the thing tho, Minecraft java notoriously does not run well at all, especially when you want to build more complex contraptions, the you need a LOT of mods optimizing how minecraft runs. Sure it runs well enough for most people, but you can't say that minecraft written in a more suitable language would be capable of so much more
Yea but these mods are written in Java, so it's a Mojang issue not java. The JVM and javac have gotten much better in the last few years, it's no longer as slow as it used to be. Tbf idk what version Minecraft runs, but assuming it's somewhat recent there wouldn't be that much of a difference between a java or C/cpp/c# implementation
Most programs need to grab memory to do stuff. A hundred enemy robots just spawned in? We need a spot in memory for each of those robots to remember stuff like where it is, which way it's facing, and what it should be doing. If we could use the same spot each time, that'd be great, but we might get lots and lots of robots, so instead we grab space as we need it. The trick to that is that we also need to let that space go when we don't need it anymore. Otherwise, our program will just use up more and more space each time a robot appears until eventually there's no more space and the game breaks.
In most languages without garbage collection, the program decides when and how to free up space. The robot's been destroyed? Great, tell the system that we're done with that particular bit of memory so it can be reused later. The problem is that we are human, and there are a lot of ways to get this wrong. It's easy to forget to free the memory when it's no longer being used (called a "memory leak"), and it's also easy to accidentally free memory that you're still using.
Java provides automatic "garbage collection," which will automatically frees memory once your program no longer has any references to it. After all, if I don't have a way to reference the robot, we can know that I'm done with it. This is fantastic!
However, to do garbage collection, the system needs to figure out which bits of memory don't have references anywhere. Ancient versions of Java did this by simply pausing the entire program, looking at every reference to anything, and then freeing anything with no reference. This was pretty terrible, and you can imagine how a game pausing for maybe a whole second every so often would suck.
It also sucked for businesses, though, and more than 3 billion devices run Java, and so the Java folks worked hard on better ways to do garbage collection. Modern garbage collection is far, far better. However, ultimately, it still needs to briefly pause things. This is tunable, but there are still occasional hiccups when Minecraft's garbage collection runs. Most garbage collection cycles are < 1ms, but if a whole lot is going on, it can become quite noticeable.
my educated guess: garbage collections keeps track of unused/lost data and removes it. However the amount of processing power used to keep track of is enough for developers to do manual garbage collecting. But that can lead to memory leaks? some correct me please
Pretty much nailed it. Garbage collection runs periodically, often without being told to, which could cause hitches. It can also be turned off and run manually, or not run at all. At least in python.
Because GC is unpredictable and runs at random times and can causes frame hitches which can hinder the experience. Also you should clean after yourself.
It's not even the net performance issues that's the issue with garbage collectors. It's the irregular timing of it.
Basically, the garbage collectors runs when it wants to.
So you can easily get into situations where your program starts stuttering (dropping frames) whenever the garbage collectors decides to run.
In non garbage collected languages, the programmer and/or the language itself controls explicitly when memory is cleaned (deallocated), so it's much easier to make sure that doesn't cause excessive stuttering.
That said, there are ways to control the garbage collector too in garbage collected languages so it doesn't interfere too much. But this is generally a lot more finicky than explicitly controlling the memory yourself.
DSP suffers from a bit of a weird problem whereby the game makes itself more frustrating long before performance truly becomes an issue. You basically have to build out large blueprinted sections of factory, except that the way the grid works, you have to micromanage and microadjust to fit things onto the spherical surfaces of celestial bodies. I suspect that, if the grid issues could be solved (which is unlikely since that's kinda core to the game's whole schtick), slowdowns from extremely large factories would become more relevant.
But look at Kerbal Space Program and its spiritual successor Kitten Space Agency. They're both also written in C#. KSP definitely does suffer from issues when you get bajillion part vehicles going, though I suspect that's more of a physics question than garbage collection. KSA is rock solid. As long as you can load up the universe (on an older graphics card, going max graphics quality might run you out of VRAM), nothing else is ever an issue. Vehicle part counts haven't come close to causing issues.
Almost every game engine has a garbage collector, optimized specifically for games, with various controls on how they work and how your code interacts with them.
Unreal Engine, Unity, GameMaker, and more all have garbage collection.
A lot of the non-engine library frameworks for langs like C++, C#, Rust etc. also make use of garbage collection, whether by natural language features or as part of a framework.
There wouldnt be garbage collection in all major game engines and libraries if it wasn't useful for games and game developers.
Modern GC is designed to help optimize your game in real time, not hinder it. It only becomes a hinderance if your game is poorly made and you're otherwise trying to fight the GC rather than work with or around it.
I mean, if you really don't like garbage collection, nothing stopping you from defining a 4GB byte array and managing your memory yourself. Like a psychopath.
Garbage collection is not bad for games, Java 6 gc was bad for games. Modern Java garbage collection is state of the art and most game engines copy it for memory management systems
Its shocking reading essays in these comments from people that have clearly not done any serious work with Java in seemingly 20 plus years
If you’re going for 60fps, then you have 16ms to update state and produce a frame. 16ms is less than the 20+ms gc pauses that frequently occur in g1gc.
It works well for web servers, but for games where you want 60 or even 30fps, it’s a problem.
Using g1gc when trying to minimize pause times goes to the point of u/grandalfxx is making that people aren't familiar with modern Java. The ZGC garbage collector has sub millisecond max pause times. https://inside.java/2023/11/28/gen-zgc-explainer/
That's a bit of an overgeneralization. "Games" includes a vast number of things of all different types. JavaScript is a garbage collected language, and it's actually a very *good* choice for a lot of games, because it means they can be run directly in a web browser. (And I love being able to make a nostalgic reference to Sleuth, look for it, and find that someone's ported the entire game to JS so that it can run on modern systems.) "Bad for games" is a terrible overgeneralization.
The performance modern .NET cranks out is insane, still gets beaten by C++ but this bit of extra performance isn't necessary for most games I'd argue (especially if you program with composition and entities in mind rather than classes and inheritance chains)
Starsector running on an ancient version of java is an active liability for it at this point.
You can see how much memory it requests in process explorer. A solid block of 4 gigs, which windows will instantly virtualize, an OS workaround implemented during the clinton administration.
Edit: I've gotten multiple comments it was updated, guess they finally did something about that!
Alex did bump it up like 10 Java versions last patch.
There is a mod that switches it out for Temurin jdk-27+22 and runs a script to set flags and additional optimizations based on processor architecture. Great for running larger sector sizes with a bunch of extra factions in Nexerelin with smooth 240fps.
Starsector modding is one of the most schizophrenic modding scenes in terms of doing things the game was never intended to do I've seen in a while and I love it.
One that immediately comes to mind is Arma Armatura.
The game's combat takes place on a flat plane where the two fleets of star ships meet roughly in the middle. Top down tactical, pretty simple in basic concepts.
Arma Armatura somehow managed to create missions where you are actually entering a planet's atmosphere, with your reinforcements coming from above and enemy reinforcements coming from below, and enemy defense cannons blasting the entire time. The game was straight up not made with any form of vertical movement, so AA basically created an entirely new system to make these missions work.
To be fair, for those types of games, devs switch from languages like Java and C#/MonoGame (example: Hades switched to custom C++ engine before release), at least before MS introduced solid, native AOT. Not because the language is problematic (it's fine for this type of game) but because porting them is painful or impossible without rewrite or strange hacks. There's no official JVM for consoles, and moreover, platforms themselves just disallow JIT compilation due to security reasons. That's one of the reasons why Unity created IL2CPP (their AOT compiler)).
StS1 has so many amazing bugs that make speedrunning it so cool. On the code side, AbstractDungeon is basically One Big Class That Does Everything. It's common in single player games when you don't have to think about networking and such and can just store everything in the big pile of lists and flags and RNG states. Not sure if the language is to blame, but Java is an inheritance-heavy OOP language and I'm an inheritance-hater.
I'm kinda sad StS2 is so much better coded for speedrun reasons but really glad they made multiplayer such a well-polished treat right out of the box.
Eh, I think inheritance is hated by most developers in most languages.
It seems like people who design languages and frameworks love inheritance, but then regular developers use the language and tend to avoid it like the plague.
Another issue for 3d rendering performance is that java does not have struct, everything is a class.
On the surface level ot does seems minor but a struct and a class are widely different on how its memory is allocated. Without a struct, calls to 3d rendering api are much less efficient
Only problem Mindustry has is, you probably need the 'tism to enjoy it. But when you do.... Oh does it feel good to have the most efficient production line
... What? No, the game engine is Java, with a runescript interpreter for game logic. RuneScript is it's own bonkers programming language that is in no way related to Java
For once I'm glad that Minecraft is written in Java because it makes modding it have such a low barrier of entry compared to games written in compiled languages.
It’s compiled to generic byte code that machine cannot understand
then it is interpreted (converted to real machine code that is different per machine) by JVM (Java virtual machine)
then small snipers of code that are frequently repeated such as loops can be compiled as actual machine code and stored in ram for even faster usage until they are not used anymore.
That's alright. Even if C# exists, Java is still a nice option for modding. Wasn't trying to make a comparison between Java and other languages that compile to some sort of bytecode.
Yes and no. While java made it a bit easier, it caused all sorts of other problems with the modding community.
Compare Minecraft to games which actually have good mod support:
Vintage Story, Rimworld, Starbound, Factorio (Edit: guess people have issues with this one in perticular)
The trick is to not have to have your mod creators program at all by default. Use a data format that is easily able to be learned and have a patch system so that multiple mods don't clash.
I haven't played these other games, but I don't think Factorio is a good comparison.
The domain of what is possible in modded Factorio vs modded Minecraft is extremely different, majority of Factorio mods just extend on what the game already does: here are machines, they convert things to other things. Majority of mods fall into this bucket, including many overhauls. Even when mods do something unusual, it's usually very hacky and sometimes half broken. Looking at you Space Exploration spaceships, nav view, space elevators. For another non-gameplay example graphtorio comes to mind (there are actually several different ways to implement graphtorio-like functionality within limits of what you can do with Factorio API, but all of them are kind of terrible).
A lot (majority?) of mods in Minecraft go so beyond what the game fundamentally does. From game optimizations, shaders, to more big stuff. Thinking IC, BC, AE, or for a more modern example Sable/Create: Simulated (or Create: Aeronautics which uses it).
Symbian supported java through J2ME, which is the same format every non-smartphones ran. There were lots of native Symbian games though, which would've been written in C++.
Still a banger game. But I get it, performance is shit. Can't drive car fast cuz when I do I hit an invisible wall while next chunk is loading. And many zombies tank fps.
From dev standpoint idk if it gives guys any problems
Yep, the mobile version was written from scratch in c++ so it would run on phones, then ported back to PC later where it runs laps around Java to this day. If the versions didn't have so many key differences affecting gameplay, Java likely would have been abandoned long ago.
Project Zomboid is the worst game I love. I hate it. The devs are bad, the engine is clunky and it is missing so many features after 14 years of development. Yet it fascinates me and I can't stop playing it.
Architecture and algorithms matters way more than language. A skilled coder knows the limitations of a language they are working with and designs around hiding the rough edges.
If Bedrock was a 1:1 of java just programmed in C++, I'll bet everyone would like it better. The issue is bedrock was built to monetize what modding had made free
Notch was a Java dev and Minecraft was supposed to be a small project that would take couple weeks, Mojang should've switched to C++ a long time ago but Bedrock is a mess so here we are with game worth literal billions that you need to install basic optimization mods for it to work properly.
Mojang should have switched to C# honestly. It's very similar in principle and style to Java, it's used by probably a solid 1/3 of video games out there, it works on console, it doesn't require much installation, and guess what? It's literally developed by Microsoft
edit: It also is extremely moddable, just like Java
Notch worked with Java at his day job. Java also at the time had web-applets which allowed people to run the game in their browser which helped people play it right away when he posted on TigSource forums.
online games using the Java browser runtime were a dime a dozen back in the day. nowadays, with all these new engines, WASM and WebGL, Java went back to being almost exclusively a backend language. It's fine for most games. If we're honest, most programming languages are fine for most games. the biggest difference is developer skill.
If we're being honest, Java isn't optimized for games like C or C++ is for example
Minecraft was rewritten in C by Microsoft and, if we forget the marketplace and the overall useless cluttering with things that weren't there in the first place, it runs much better
While yes it is less hardware-intensive, I would hesitate to say it runs better. It's been overexaggerated, but there's a reason we call it Bugrock.
Quick point of clarification, it was written in C++, not C.
Back on point, I started out on Bedrock, and while yes, it runs on much less powerful devices, when your computer can run Java Edition, stability is not a concern, with Bedrock Edition I became well acquainted with how to break the game, crash, or corrupt my world. It's not a pleasant experience to be performing normal gameplay and crashing. Not even my modded gameplay (outside of Minecolonies, but that mod is a nightmare in its own right and should be taken with a fat grain of salt) is that unstable.
I would argue bedrock is buggy because of a lack of willingness to spend time fixing the bugs on Microsoft's part, not necessarily due to the programming language used. Microsoft treats bedrock as the cash cow and java as the lure that kids watch on YouTube, who are then expected to play bedrock
I agree that that is the core of the issue, I was just arguing that it's not really a fair comparison to say it "runs better" because it's on C++ when bad bug management is still present. Java, for all it's faults, is known and well-kept, and despite being on paper the worse language for game development, still handily beats a mid-tier at best recreation in C++. If Bedrock were a faithful recreation with the same level of care and polish, it would probably be better, but it just isn't at its current state.
The problem with bedrock is that it is asynchronous. What the server sees (that is still run separately on local world too) and what the player see are desynced far too easily which leads to you randomly dying because the server thought you took damage.
People are talking about memory accesses and GC, but that only shows half of the picture. Java is HEAVILY object oriented. I'm not someone who thinks OOP is complete garbage with zero applications, but our silicon is data and procedure oriented. There's a natural overhead in reorganizing code that is structured in objects and the magical compilers that make this cost zero never became true. In a world where CPUs are OOP, this might be more justified (and even more efficient once someone cracks the design of such a CPU), but in a world of procedural CPUs, problems with translating the approaches grow exponentialy. A game as complex and with systems as detailed as Minecraft should be considered a miracle in Java. Same with parallelism, Minecraft is to this day still very sequential (although much more parallel than before) because just making stuff parallel without careful engineering just make these problems pop at a steeper curve.
Well…just because it was made in Java does not mean it’s good. Minecraft runs like a POS if we’re being honest here, and that is mostly because of Java quirks with garbage collection afaik
If your language choice to run a turn based board game is able to have any kind of impact on performance that is meaningful, that is 100% a skill issue.
35
u/Cocoatrice Oct 07 '26
I mean, Minecraft is enough to prove that. It's the best selling game in the world. And a lot of people play Java Edition, not Bedrock Edition. If game works great in Java, it means it's possible to make games in Java. It has its limitations, though.
149
u/johnnybgooderer Oct 07 '26
Garbage collection is bad for games. Minecraft was playable because Java garbage collectors were fast enough to make it playable.
But don’t use any garbage collected language for games.
2.2k
u/Daniikk1012 Oct 07 '26
Slay the Spire (The first one), Mindustry, Pixel Dungeon, Unciv
162
u/grandalfxx Oct 07 '26
Runescape, project zomboid.
The only reason Java isnt for games is because you'd have to build a custom jdk to run on the consoles and no one wants to do that.
645
u/mi-figue-mi-raisin Oct 07 '26
Mindustry
294
u/W_Seed Oct 07 '26
RuneScape
208
u/NitronHX Oct 07 '26
Osrs
565
u/ArkoSammy12 Oct 07 '26 edited Oct 07 '26
For once I'm glad that Minecraft is written in Java because it makes modding it have such a low barrier of entry compared to games written in compiled languages.
136
u/Toutanus Oct 07 '26
Wakfu
131
u/Alokir Oct 07 '26
Hundreds of pre-smartphone mobile games
371
u/daniil007a Oct 07 '26
Zomboid
29
u/zacyzacy Oct 07 '26
Slay the spire 1
48
u/Conman636 Oct 07 '26
Songs of Syx.
16
u/Ok_Confusion4764 Oct 08 '26
Runesca- oh no wait, they switched to C++ as well because it was so bad...
14
u/Lord_Lorden Oct 07 '26
Starsector
14
u/SupportDangerous8207 Oct 07 '26
Supreme commander
32
u/girlfriendsbloodyvag Oct 07 '26
RuneScape? One of the longest running MMOs out there?
10
u/Banalian Oct 07 '26
Spiral Knights
18
u/Cheezyrock Oct 07 '26
Architecture and algorithms matters way more than language. A skilled coder knows the limitations of a language they are working with and designs around hiding the rough edges.
9
u/Rework_Aramusha Oct 08 '26
I wonder how much more efficient a huge minecraft modpack would run if minecraft would be built on like C or so
9
u/Brickybooii Oct 12 '26
If Bedrock was a 1:1 of java just programmed in C++, I'll bet everyone would like it better. The issue is bedrock was built to monetize what modding had made free
7
u/F3mshep Oct 07 '26
Slay the Spire, indie darling of 2019 was written in Java.
7
u/Negitive545 Oct 07 '26 •
Minecraft, Zomboid, Starsector
All three of which are bangers. All three of which suffer heavily from the fact that they run on Java.
7
u/randomlemon9192 Oct 07 '26
I thought I was in r/Minecraft for a minute lol.
Anyone know the backstory as to why they chose Java to develop the game in? Odd choice given its non use in industry games.
7
u/c1e0c72c69e5406abf55 Oct 07 '26
Puzzle Pirates, written in Java
13
u/not_some_username Oct 07 '26
You’re clearly too young to know the great Java games era
34
u/userhwon Oct 07 '26
It's kinda shit for Minecraft as well.
6
u/marvology Oct 07 '26
Didn't Java power all those classic Yahoo games back before Marissa Mayer did her Manchurian candidate job on them?
11
u/anoppinionatedbunny Oct 07 '26
online games using the Java browser runtime were a dime a dozen back in the day. nowadays, with all these new engines, WASM and WebGL, Java went back to being almost exclusively a backend language. It's fine for most games. If we're honest, most programming languages are fine for most games. the biggest difference is developer skill.
5
u/Heavy-Ad6017 Oct 07 '26
Hey dont forget my Snake game I wrote in Java with Swing UI
5
u/Feuzme Oct 07 '26
Binding of Isaac
9
u/LordOmbro Oct 07 '26
Project Zomboid is written in Java :)
9
u/Iyxara Oct 07 '26
https://en.wikipedia.org/wiki/Category:Java_platform_games
4
u/Wolf_Of_Hearts556 Oct 07 '26
Starsector
4
u/MentalFS Oct 07 '26
At least we got a more secure Log4J now
4
u/wokan Oct 07 '26
Runescape
4
u/amopeyant Oct 07 '26
RuneScape
4
u/thejokerofunfic Oct 07 '26
Hey Java is excellent for game dev! I always drink a fresh cup before I sit down to code in Python
3
u/BI00dSh0t Oct 07 '26
runescape my guy. one of the ogs
3
u/WaffleWalk Oct 07 '26
Protect Zomboid
3
u/SidNYC Oct 07 '26
Slay the spire was also written in Java
21
u/MichaelAceAnderson Oct 07 '26
If we're being honest, Java isn't optimized for games like C or C++ is for example
Minecraft was rewritten in C by Microsoft and, if we forget the marketplace and the overall useless cluttering with things that weren't there in the first place, it runs much better
5
u/KookyDig4769 Oct 07 '26
Every Android game ever?
4
u/stevetures Oct 07 '26
Fwiw the newer Minecraft (bedrock) is written in C++ though ofc all the java mods etc don't natively, ofc you need to use their marketplace etc
4
u/Tarc_Axiiom Oct 07 '26
It's no good for Minecraft either lol.
It's just too late.
2
u/Understanding-Fair Oct 07 '26
RuneScape, apparently
2
u/Rawullf Oct 07 '26
Tibia started on Java iirc
2
u/WillDonJay Oct 07 '26
Runescape!
2
u/MegaScience Oct 07 '26
Façade. Messing with Trip and Grace subtly as they with though their plot. (Facade, for anyone searching comments)
2
u/Athlaeos Oct 07 '26
HyTale?
2
u/Onoulade Oct 07 '26
Mindustry !
2
u/Thiccboi2 Oct 11 '26
project zomboid
6
u/New_Salamander_4592 Oct 07 '26
and the worst part about minecraft is its in Java
3
u/Estrelaura Oct 09 '26
People are talking about memory accesses and GC, but that only shows half of the picture. Java is HEAVILY object oriented. I'm not someone who thinks OOP is complete garbage with zero applications, but our silicon is data and procedure oriented. There's a natural overhead in reorganizing code that is structured in objects and the magical compilers that make this cost zero never became true. In a world where CPUs are OOP, this might be more justified (and even more efficient once someone cracks the design of such a CPU), but in a world of procedural CPUs, problems with translating the approaches grow exponentialy. A game as complex and with systems as detailed as Minecraft should be considered a miracle in Java. Same with parallelism, Minecraft is to this day still very sequential (although much more parallel than before) because just making stuff parallel without careful engineering just make these problems pop at a steeper curve.
2
u/Einkar_E Oct 07 '26
the fact that minecraft exist doesn't prove that java is good for games, minecraft has history of being not exactly well optimized, and a bit buggy
2
u/devilxnux Oct 07 '26
Don't you remember that majority of mobile games are written in Java?
2
u/DogmaticParadigm87 Oct 07 '26
Java is no good for games. It only made the best-selling one ever, and then they rewrote it in C++ just to be sure.
2
u/Terrariant Oct 07 '26
Well…just because it was made in Java does not mean it’s good. Minecraft runs like a POS if we’re being honest here, and that is mostly because of Java quirks with garbage collection afaik
1
u/TheBigGambling Oct 07 '26
Risk
1
u/Tree_Dude Oct 07 '26
Sonic 4 Ep1.... Maybe not the best example....
1
u/STINEPUNCAKE Oct 07 '26
There are quite a few small games made in Java but at scale it sucks and that’s Minecraft moved to C
1
u/RotCrab Oct 07 '26
Most of Nokia games made on Java.
1
u/SeaNational3797 Oct 07 '26
TerraFirmaCraft