r/ProgrammerHumor • • 9d ago

Meme minecraftException

Post image
9.2k Upvotes

828 comments sorted by

2.2k

u/Daniikk1012 9d ago

Slay the Spire (The first one), Mindustry, Pixel Dungeon, Unciv

492

u/SunshineSeattle 9d ago

Starsector

99

u/Saint_of_Grey 9d ago edited 9d ago

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!

31

u/Inprobamur 9d ago

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.

6

u/Kantas 9d ago

I may need to look into that.

Starsector is a great game that I suck at

→ More replies (3)

6

u/hgwaz 9d ago

It also runs a lot better if you update its java

→ More replies (1)

186

u/Kcmichalson 9d ago

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.

57

u/PegasusPizza 9d ago

Not familiar with Starsector at all. What kind of schizophrenia are the modders up to?

135

u/UncleRichardson 9d ago

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.

21

u/TheGrandBabaloo 9d ago

Wtf, did they add that somewhat recently? I had Armatura installed when playing a few years ago but don't recall that at all.

15

u/UncleRichardson 9d ago

Sometime last year, I think? They've really focused on the story elements of the mod lately, rather than just the added mechs.

→ More replies (1)

18

u/Russian_Bot1337 9d ago

From waifus to war crimes. Starsector modders are the best.

15

u/Mepharias 9d ago

God I love Starsector

→ More replies (1)
→ More replies (3)

82

u/whichwayisgauche 9d ago

Runescape

42

u/LBGW_experiment 9d ago

Surprised you only said this 12 min ago. I almost left a comment saying it.

Company name Jagex -> JaGeX -> Java Gaming Experts

3

u/rsnJ3 8d ago

For what it's worth jagex has not stood for that for quite a few years.

3

u/LBGW_experiment 8d ago

That's fine. Why they created the name in the first place that is really the purpose of my comment

→ More replies (1)

63

u/shadow9876543210 9d ago

Wait 780 hours and I had no idea mindustry was made in Java!

36

u/SunshineSeattle 9d ago

Theres actually a gir repo for the game  you can read the code and everything 

→ More replies (1)
→ More replies (2)

72

u/2580374 9d ago

I had no idea about slay the spire, that's crazy

130

u/WeirdIndividualGuy 9d ago

And it worked out so well, the dev decided not to use Java ever again in their games

26

u/BrodatyBear 9d ago

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)).

15

u/CAPS_LOCK_OR_DIE 9d ago

Its actually very cool to poke around in if you have the opportunity. There's some spaghetti, but overall its a pretty clever codebase.

→ More replies (2)
→ More replies (2)

25

u/OohBleh 9d ago

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.

5

u/ArtOfWarfare 9d ago

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.

4

u/Ma4r 8d ago

No, people who design languages loves FP, it's the business people that love OOP because it makes them think they can understand code

8

u/Suvtropics 9d ago

Pixel dungeon mentioned! Watabou and Evan 👑

17

u/Jhuyt 9d ago

Is STS2 not written in Java?

80

u/Daniikk1012 9d ago

It uses Godot cause the devs wanted an editor instead of doing everything from code

6

u/Jhuyt 9d ago

Huh, TIL, assumed it was Java as well

57

u/sjphilsphan 9d ago

It was supposed to be Unity, but then Unity decided to punch itself in the face

34

u/CptMisterNibbles 9d ago

The STS devs were one of the first more major folks (iii at least) to immediately and publicly announce “wow Unity, that’s fucked. You know what, we are out” and went and made a test game to see if they wanted to switch to Godot.

3

u/Named_after_color 9d ago

What's unity's deal?

19

u/Thenderick 9d ago

Unity got greedy and changed their ToS to charge based on install instead of purchase. They reverted, but the StS devs had enough and changed engines to godot, which is open source

→ More replies (6)
→ More replies (3)
→ More replies (16)

161

u/grandalfxx 9d ago

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.

37

u/coolraiman2 9d ago

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

32

u/Lithl 9d ago

JDK 28 adds inline classes, which give you the kind of memory allocation you'd expect from a struct.

It's not released yet, but the early access build is available. Build 18 came out last week.

29

u/coolraiman2 8d ago

20 years later but nice

10

u/LutimoDancer3459 9d ago

May i introduce you to project Valhallas value classes? Java is going stronger every release. Not long and the missing struct wont be an issue anymore

6

u/warpspeedSCP 8d ago

If they can get the damn thing released maybe, its been what, a decade?

3

u/Cebular 8d ago

I'm a C++ dev so struct/class really only differ in that class is private by default. What do you mean that java does not have struct?

→ More replies (2)
→ More replies (2)
→ More replies (1)

639

u/mi-figue-mi-raisin 9d ago

Mindustry

130

u/Successful_Day2479 9d ago

Hell yeah came here to say this

If I ever learn java it'd be to mod this game. And Minecraft.

113

u/sup3rdr01d 9d ago

I learned Java as a kid to mod Minecraft. Which got me to do CS in college

Which has now ended up in me writing AI slop bullshit every day :(

29

u/Hattrickher0 9d ago

Are you the dude who sits in the cube next to me at work?

WeirdThatItHappenedTwice.jpg

21

u/Aethenosity 9d ago

I mean... that is a SUPER common path. It probably describes a significant portion of all CS grads at this point.

→ More replies (1)

25

u/Facosa99 9d ago

Beat me to it

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

→ More replies (7)

292

u/W_Seed 9d ago

RuneScape

18

u/_PM_ME_PANGOLINS_ 9d ago

JAva Gaming EXperts

143

u/DmitriRussian 9d ago

They have moved to C++ a long while ago, which means that it wasn't good

50

u/Awes0meEman 9d ago

That was just the client. I'm pretty sure their game engine is still written in Java.

12

u/Kovarian 9d ago

The game engine is written in RuneScript (not a joke). Also known as spaghetti (joke, but true).

21

u/Awes0meEman 9d ago

Runescript is a scripting language that they use for actual game scripting and logic, the underlying engine that RuneScript actually interfaces with is all Java.

35

u/Apalapa 9d ago

Osrs too? Fairly sure that’s still legacy on Java. Maybe not the client though…

25

u/randomjberry 9d ago

official client has been c++ for a few yeats at least but they maintain java for runelite

49

u/Vimda 9d ago

Just the client though. Game Engine and Server are still Java

8

u/Tury345 9d ago

I think mobile uses c++ otherwise virtually nobody uses the PC c++ client

16

u/TohveliDev 9d ago

That's just the client. The game and the engine is still written in Java.

8

u/polaarbear 9d ago

Minecraft was also rewritten in C++ for cross-platform compatibility. That's why there is a Minecraft: Java Edition now

6

u/Bomberlt 9d ago

Ironically Java was created to be cross platform

→ More replies (1)

12

u/W_Seed 9d ago

Fuck I didn't know that

→ More replies (5)

167

u/josHi_iZ_qLt 9d ago

Its also not a good choice for minecraft. Its just what it was build on.

The way minecraft came to be is not at all related to "what platform to use for a successfull huge game".

Its like saying "garages arent great to create a billion dollar business" and countering with steve jobs who started in one.

50

u/PresidentSkillz 9d ago

Then they tried to fix it with the bedrock edition which is c++ or c# (forgot which one) but instead they made a buggy mess that people only play bc the Java version is pc exclusive 

24

u/josHi_iZ_qLt 9d ago

Which is kinda funny given java is inherently made to be able to run on almost everything

7

u/Fewtex 8d ago

Having a jdk on a console would make homebrewing it easier, and these companies would rather die then have someone easily crack there personal console.

24

u/danfish_77 9d ago

Yeah they also let it diverge from the original for some reason instead of focusing on getting it identical so they could retire Java

14

u/Fewtex 9d ago

Its only pc exclusive because consoles dont have JRE, because java is bad for games

Someone would have to make a custom jdk for consoles for java to be a viable option for games

→ More replies (5)
→ More replies (6)

204

u/NitronHX 9d ago

Osrs

29

u/SuitableDragonfly 9d ago

Didn't the company name Jagex originally come from something like "Java Games [something]" or did I hallucinate that?

42

u/TohveliDev 9d ago

Java Gaming Experts yeah

→ More replies (1)
→ More replies (1)
→ More replies (9)

564

u/ArkoSammy12 9d ago edited 9d ago

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.

323

u/jbar3640 9d ago

I get your point, but technically Java is a compiled language.

146

u/ArkoSammy12 9d ago

Yeah. Just shorthand to "not compiled directly to machine code".

111

u/Level0Up 9d ago

Well, technically it compiles to machine code for the JVM which is known as bytecode.

36

u/BlackHatMagic1545 9d ago

Bytecode and machine code are not interchangeable. They mean different things. You wouldn't call a Rust binary "x86/ARM bytecode," would you? Would you say Python gets compiled to machine code because it gets parsed into CPython bytecode? No, you wouldn't. Calling something like Java bytecode or a WASM binary "machine code" only serves to confuse things so you can feel smart.

And most implementations of the JVM generally don't transpile Java bytecode to machine code; the only exception I'm aware of is GraalVM. So Java bytecode (usually) never becomes machine code.

4

u/BakuhatsuK 8d ago

Semantics about bytecode aside, specifically Java bytecode is pretty high level, which makes it easier for modding. This is not the case with e.g. Webassembly, which is also bytecode, but much lower level and would give you a harder time modding it

27

u/CptGia 9d ago

Which is interpreted by the JVM, until profiling data show that that piece of code is run slowing down the application, and then it gets compiled (twice) to actual instructions 

29

u/JangoDarkSaber 9d ago

I think the point yall are missing is that the code is shipped only obfuscated (until recently) instead of compiled which is what has enabled Javas massive mod community. Yes Java uses JIT compilation but that’s irrelevant to the original point being made

→ More replies (12)
→ More replies (2)

4

u/Mojert 9d ago

Bytecode is not machine code

3

u/Eruantiel 9d ago
  1. It’s compiled to generic byte code that machine cannot understand
  2. then it is interpreted (converted to real machine code that is different per machine) by JVM (Java virtual machine)
  3. 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.
→ More replies (2)

23

u/DrStalker 9d ago

C# compiled to ILCode is just as good for modding.  Easy to view the code, and easy to modify existing functions  using Harmony patching.

This is why Unity games are great for modders, unless the devs compile using IL2cpp.  

5

u/ArkoSammy12 9d ago

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.

→ More replies (2)

39

u/Segenam 9d ago edited 9d ago

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.

27

u/hithroc 9d ago edited 9d ago

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).

9

u/Segenam 9d ago edited 9d ago

It does very much depend on what you are doing, yes. But that kinda goes a bit against what I'm explaining here. Though I will admit Factorio is a bit of an odd one out in the group, but it is still designed for modding from the beginning.


The a lot of people going "away from the core game" depends more on the number of people playing the game and has less to do with how difficult the game is to mod. The majority of minecraft mods don't actually go against the grain, they add simple things that can easily be done with only a few minor details, however due to it's massive fan base there are a lot of "large scale" mods that go far beyond what minecraft does normally. There is also a bit of survivorship bias as most mods that make it into modpacks tend to be the larger well made mods that change up the game because the default of minecraft is rather boring (hence everyone's 2 week binge).

But the majority of mods are primarally "this block drops something when mined", "put this in crafting grid to make thing" and "magic blocks" (you put item in, get new item out). It wasn't until Create came along that really threw a wrench into that idea and in the grad scheme of minecraft's entire life it's honestly pretty new.

And even then these mods need a core (forge, fabric, etc.) which are all made by a large team to make it even plausible to do such things.


A prime example of people will force things to do things they aren't designed to do if there is enough of an audience is Skyrim, which is an absolute pain in the arse to mod, it's not mod friendly at all and you are constantly fighting it every step of the way and is a buggy mess, and yet there are lots of large scale mods for the game that go far beyond what the game was designed for.

Just because something has larger scale mods that go against what it was designed for, on it's own doesn't mean much.

5

u/hithroc 9d ago

My point primarily was that for games with modding support you are bound by what is possible within the modding API, thus the domain of possibilities is lower.

It is much less so for cases like Minecraft. But the tradeoff here is that modding at all is a mess compared to a game provided API.

→ More replies (2)
→ More replies (2)
→ More replies (7)
→ More replies (4)

137

u/Toutanus 9d ago

Wakfu

40

u/ajnozari 9d ago

unexpected Wakfu reference

13

u/Aelrift 9d ago

I legit did a double take

10

u/Toutanus 9d ago

I worked a few years in the same town as Wakfu studio

→ More replies (2)

129

u/Alokir 9d ago

Hundreds of pre-smartphone mobile games

98

u/da_Aresinger 9d ago

Not pre smartphone. Pre kotlin.

Most applications on Android, before 2019 were written in Java.

14

u/Tyrus1235 9d ago

Well, technically you could spin up something in Unity using C# and it’d somehow run on Android and iOS (if you were on a Mac).

14

u/r3dm0nk 9d ago

The vast ocean of symbian games

3

u/mordacthedenier 9d ago

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++.

368

u/daniil007a 9d ago

Zomboid

341

u/Western_Sentence_943 9d ago

This is an antiexample tbh Zomboid suffers so much from its own engine

106

u/daniil007a 9d ago

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

29

u/Layton_Jr 9d ago

Low FPS with zombies nearby is a feature, this way you know when to be careful

16

u/conundorum 9d ago

Ah, yes, the Space Invaders difficulty scaling: The more enemies are on screen, the more the game switches into easy-lag mode.

→ More replies (3)
→ More replies (2)

27

u/harelzz 9d ago

Tbf so does minecraft

7

u/Topikk 9d ago

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.

→ More replies (2)

3

u/ForgedIronMadeIt 9d ago

They're actively rewriting parts in C++ last I checked.

→ More replies (12)

37

u/can_prog 9d 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.

13

u/loufurman 9d ago

The classic Ark: Survival Evolved problem

→ More replies (1)
→ More replies (5)

22

u/OneArmedFarmer 9d ago

I thought that was written in Lua but apparently it's both!

18

u/jojos38 9d ago

Lua it's just a scripting langage in itself

18

u/Abcdefgdude 9d ago

Balatro is written fully in Lua

→ More replies (4)
→ More replies (2)

34

u/Cocoatrice 9d ago

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.

39

u/ShakeForProtein 9d ago

You can pry the Java edition from my cold dead hands. I will never use Bedrock edition.

→ More replies (9)

19

u/Ma4r 8d ago

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

16

u/mrderp1212 8d ago

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 

3

u/Ty_Rymer 7d ago

funnily enough a bunch of different optimization mods are really focussed around garbage collection and memory optimizations, calling C bindings instead of doing the same operation in java, or offloading things to other threads so you can spread the load over multiple frames. these optimisations being needed at all is a direct consequence of the jvm

→ More replies (4)
→ More replies (10)

27

u/zacyzacy 9d ago

Slay the spire 1

45

u/Conman636 9d ago

Songs of Syx.

6

u/LittleMlem 9d ago

That's java? Man's insane

→ More replies (2)

16

u/Ok_Confusion4764 8d ago

Runesca- oh no wait, they switched to C++ as well because it was so bad...

→ More replies (15)

13

u/SupportDangerous8207 9d ago

Supreme commander

7

u/Metallkiller 9d ago

Oh damn really? That's a hell of a game to build in Java.

4

u/Peakomegaflare 9d ago

The absolutely baller spiritual successor to Total Annihilation

6

u/TemporaryFearless482 9d ago

For those looking to scratch the original Total Annihilation itch, look up “Beyond All Reason”.

→ More replies (3)

32

u/girlfriendsbloodyvag 9d ago

RuneScape? One of the longest running MMOs out there?

20

u/facie97 9d ago

So much spaghetti it might as well have been written in italian instead of java. I love it though

3

u/dodgyhashbrown 9d ago

Does the newer versions still run on Java or is that just the old school version?

6

u/rsandio 9d ago edited 9d ago

RS3 client is written in C++. OSRS is also transitioning to C++.

Backends are still Java.

→ More replies (2)
→ More replies (1)

4

u/Sol33t303 9d ago edited 9d ago

Project Zomboid is great.

Edit: forgot about slay the spire, that's another great one.

→ More replies (1)

10

u/Banalian 9d ago

Spiral Knights

19

u/Cheezyrock 9d ago

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.

8

u/Rework_Aramusha 9d ago

I wonder how much more efficient a huge minecraft modpack would run if minecraft would be built on like C or so

9

u/ashsabre 8d ago

minecraft bedrock (consoles, pc, ios and android) is built in c++ though it's modding capabilities isn't as good as java..

7

u/GrampaSwood 8d ago

Question is, is that because of C++ or because they want to sell you mods on the store?

7

u/StructureSimilar312 8d ago

Its cause they want your money. If they wanted bedrock could support mods.

4

u/morosis1982 8d ago

Yes and no. Because bedrock is native code, modding it would require explicit support from Mojang.

Because java can be decompiled and you can plugin stuff that transforms the original bytecode to add capabilities, literally anyone can create a modding API. That's why we have forge, fabric, bukkit, etc.

→ More replies (1)

5

u/ashsabre 8d ago

I'm thinking it is both since bedrock is the majn cashcow of Minecraft

→ More replies (4)

5

u/HolyElephantMG 8d ago

Didn’t Minecraft deobfuscate a good bit of Java’s code a while back while simultaneously making Bedrock’s much harder to access?

→ More replies (3)

8

u/Brickybooii 4d ago

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

34

u/userhwon 9d ago

It's kinda shit for Minecraft as well.

24

u/Revolutionary_Crew80 9d ago

Not like the version they made in c++ is better

17

u/sarcb 9d ago

It is in many ways, and worse in others. They did not make it in c++ for parity that much is clear..

→ More replies (9)

8

u/F3mshep 9d ago

Slay the Spire, indie darling of 2019 was written in Java.

6

u/LittleMlem 9d ago

While it's a fantastic game, it doesn't exactly require much performance. They could have written it in python and it still would have ran smoothly

→ More replies (1)

8

u/Negitive545 9d ago

Minecraft, Zomboid, Starsector

All three of which are bangers. All three of which suffer heavily from the fact that they run on Java.

9

u/randomlemon9192 9d ago

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.

21

u/Cebular 9d ago

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.

10

u/A_Canadian_boi 9d ago

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

4

u/21839 9d ago

In most games like Unity games C# only runs the business logic, the game engine being in C++. Minecraft is so unoptimized because everything was coded in Java from the ground up.

→ More replies (6)
→ More replies (7)
→ More replies (1)

10

u/atzedanjo 9d ago

It was the language that Notch was most proficient in.

12

u/Robocop613 9d ago

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.

6

u/LatvianCake 9d ago

Before Minecraft was a thing, he worked on Wurm Online. That game is still around and is also written in Java.

→ More replies (3)

6

u/c1e0c72c69e5406abf55 9d ago

Puzzle Pirates, written in Java

14

u/not_some_username 9d ago

You’re clearly too young to know the great Java games era

5

u/marvology 9d ago

Didn't Java power all those classic Yahoo games back before Marissa Mayer did her Manchurian candidate job on them?

151

u/johnnybgooderer 9d ago

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.

50

u/lastog9 9d ago

Can you explain why garbage collection is bad for games? Not challenging the fact just asking because I don't know

69

u/captainAwesomePants 9d ago

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.

13

u/Jim_skywalker 9d ago

So that’s why modded Minecraft can have reoccurring lag spikes.

12

u/trash-_-boat 9d ago

It's also why you don't want to give Minecraft TOO much RAM. Because then it will do the GC in bigger chunks, which will cause an even longer pause.

5

u/FabioTheFox 9d ago

I feel like this is more of a Java specific quirk, I've not seen this with other languages

→ More replies (3)
→ More replies (1)
→ More replies (3)

3

u/rocket_randall 9d ago

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 really shows how understanding the implementation and what's going on in the background is still vital. I point this out because back in the late 90s/early 00s the C++ greybeards liked to tell us newcomers and learners that classes/OOP/STL meant that we could focus on writing code and that we didn't need to concern ourselves with the implementation. That was not correct. C# has/had some of the same issues with its scheduled tier 2 GC (I think that's what MS calls them? I can't remember offhand).

There were ways around it, like pre-allocating arrays of whatever objects you needed and then "freeing" them meant clearing state without sending them to the GC to be reused again. Of course this could mean allocating a bunch of memory that could lay fallow for a large portion of the runtime and thus unavailable for other needs, and if you're actively trying to work around the GC then perhaps a language without GC is a more straightforward solution.

→ More replies (1)

3

u/lastog9 9d ago

Thanks for the explanation!

→ More replies (4)

19

u/exhaustedcheese 9d ago

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

18

u/Bubbaluke 9d ago

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.

→ More replies (4)
→ More replies (2)

12

u/Lyshaka 9d ago

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.

7

u/DuploJamaal 9d ago

Without any configuration they are unpredictable and stop the world.

But in time-critical applications you would use a low-pause GC like ZGC or Shenandoah.

You can regularly call them manually and they'll do their work in another thread without causing any noticeable drops on performance.

26

u/SmuJamesB 9d ago

performance overhead, mainly

games need to run a lot of complex logic many times a second. the fewer the bottlenecks on the speed at which that logic can run, the better

31

u/Drugbird 9d ago

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.

→ More replies (4)

4

u/Tyfyter2002 9d ago

And that performance overhead is possible to reduce substantially as long as you remember to avoid heap allocations and garbage creation when possible.

→ More replies (1)
→ More replies (3)
→ More replies (8)

136

u/ComputerWhiz_ 9d ago

cough Unity uses C# cough

66

u/im-a-guy-like-me 9d ago

No it doesn't. Unity uses C++. It just let's devs use c# as a scripting language.

53

u/ComputerWhiz_ 9d ago

Still uses garbage collection though

55

u/potzko2552 9d ago

When your engine is cpp and most of your mem is chandled in cpp, having a scripting language that is GCed doesn't change the majority of the project's behaviour. Like adding lua embedding doesn't mean your project is no longer strongly typed

4

u/kondorb 9d ago

Tell it to KSP devs - that thing freezes for GC every 5 seconds even with barely anything spawned.

9

u/cpt_melon 9d ago

Unity developers' habit of attaching a million scripts to everything instead consolidating their code and building larger systems wouldn't work any better even if the language used was C++

→ More replies (1)

8

u/3131961357 9d ago

And the code you write is most un-C# C# you'll ever see.

https://i.imgflip.com/b2xjwp.jpg

→ More replies (2)
→ More replies (24)

14

u/cbehopkins 9d ago

Dyson Sphere Program is c#

(A massive open world/universe factory game)

3

u/rosuav 9d ago

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.

8

u/mrianj 9d ago

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.

→ More replies (6)

41

u/gallyroi 9d ago

This is... straight up not true, and bad advice.

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.

→ More replies (3)

8

u/Teanut 9d ago

Isn't C# used in a lot of games?

→ More replies (8)

6

u/grandalfxx 9d ago

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

3

u/johnnybgooderer 9d ago

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.

5

u/TheStatusPoe 9d ago

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/

→ More replies (2)

3

u/Eastern_Equal_8191 9d ago

> Java garbage collectors were fast enough to make it playable.

So like, the exact opposite of the point you're trying to make?

→ More replies (1)
→ More replies (2)

10

u/rosuav 9d ago

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.

→ More replies (9)

4

u/SupportDangerous8207 9d ago

Supreme commander and Dyson sphere program disagree

→ More replies (1)

6

u/FabioTheFox 9d ago

GC isn't inherently bad for performance ngl

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)

→ More replies (11)
→ More replies (33)

11

u/anoppinionatedbunny 9d ago

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.

→ More replies (1)

4

u/Heavy-Ad6017 9d ago

Hey dont forget my Snake game I wrote in Java with Swing UI

5

u/Feuzme 9d ago

Binding of Isaac

8

u/LordOmbro 9d ago

Project Zomboid is written in Java :)

→ More replies (6)

3

u/MentalFS 9d ago

At least we got a more secure Log4J now

→ More replies (1)

4

u/thejokerofunfic 9d ago

Hey Java is excellent for game dev! I always drink a fresh cup before I sit down to code in Python

3

u/BI00dSh0t 9d ago

runescape my guy. one of the ogs

3

u/WaffleWalk 9d ago

Protect Zomboid

3

u/SidNYC 9d ago

Slay the spire was also written in Java