r/GoldenAgeMinecraft • Developer • Aug 05 '26

Discussion The decay of the Java source code

The source code of the Java Edition is in decay. We can all experience it by looking at how unplayable modern versions are without performance mods.

But performance is not the only thing. Bad performance is a result of overengineered code.

When I was making mods for Indev and Infdev during the beginning of my career the codebase was very simple and well-structured. The main class contained a lot more than it ideally should, but it's the fate of all Java codebases and there is no running away from it.

A few weeks ago I was revisiting 1.11.2 Far Lands and I noticed that the code was now a bunch of Factories.

I haven't seen the latest source code (why would I?) but seeing the dramatic change I'd bet it's ridden with layers upon layers of abstraction, factories, and so on.

String IDs are a huge part of it. Old Minecraft used numeric IDs. Later, in 1.8 I believe, shortcuts were added, but they still just pointed to those numeric IDs.

In 1.13, everyone's least favourite version, the numeric IDs went away for the most part, replaced by stringId's which are by definition much slower.

Bad performance is a byproduct of "good code".

And, on a sidenote, the reason the LCE runs so well on such old hardware is partly because 4J didn't give a phick about good code.

In Java when they ran out of space in the texture atlas they removed it, implemented automatic atlas generation, and all that nonsense which only wastes CPU cycles and makes the thing slower.

4J just increased the size of the texture atlas. Yeah.

Old Minecraft had two classes. Iirc their names were Block and Item, and they stored the static instances of every single block and item in the game along with their IDs and such.

Modern Minecraft probably has registries instead of this. And yes, for mods it is a godsent, but not so for performance.

That's been some yapping about things most people don't care about, so sorry about that.

0 Upvotes

38 comments sorted by

View all comments

Show parent comments

-15

u/gargamel1497 Developer Aug 05 '26

I agreen't.

Good code is bad as while it makes you feel good it's most often terribly slow.

Fast code taken to the extreme, in the meanwhile, is often completely unreadable and unmaintainable.

That's why a balance needs to be maintained, and that's what Notch's code did.

There were no factories, no unnecessary strings.

There were performance issues, of course, but it wasn't due to the "good code overhead" as there is now.

And while yes, chunk loading and entities are crucial, the rest is also important. Even with the most efficient rendering and worldgen mods I can still feel that modern Minecraft is just slower than old Minecraft.

4

u/helicophell Aug 05 '26

Said "unnecessary strings" make the game more comprehensible, debug-able and easier to extend

Just tell me you dislike OOP and be done with it

I've coded in Java before. I don't necessarily like the language much. I'm currently taking a course on code maintainability that utilizes Java 7 (25 years old)
Unmaintainable code is a nightmare. Because I've written it before

-4

u/gargamel1497 Developer Aug 05 '26

They absolutely do. But at the same time they are a performance nightmare. That's just what they are.

Especially on-the-fly-resizable garbage-collected strings languages like Java and C# provide. Character buffers in C are worse than integers, but they are still better than this GC-ed mess.

I don't dislike OOP. I might surprise you, but Objective-C is one of my favourite languages. I'd do a lot more stuff in it if its runtime was faster though...

Java 7 is not 25 years old. Java 7 was released in like 2011. 15 years ago. Or are you 25?

Unmaintainable code is indeed a nightmare as I recently witnessed myself, but so is overly good code.

I spent six months remaking an old mobile game for PCs. I used Java for that, and for the most part I followed Notch's principles of not going head on with all what abstraction can offer but in a few instances (including the aforementioned save system) I couldn't restrain myself and wrote gorgeous abominations.

And a while back I ran this game on a Pentium 4 computer which is eight years older than the computer I wrote the game on.

It runs like crap. I made some optimizations but the core cannot be changed without rewriting the whole thing from scratch which I'm not willing to do right now.

Good code is too good to be good.

3

u/helicophell Aug 05 '26

15 not 25, my bad, still a long time (and no stringbuilder or improved switch case). Pfft, funny you mention because I'm not even 25 yet

Still, using strings over ints isn't that big of a deal. You're using some 6-20x the clockcycles for an O(n) process

In a vacuum that's bad. In context where you have chunk loading happening, it's insignificant. Barely a factor

You know Minecraft would have much better chunk loading if Notch did it right. That's tech debt permanently scarring Java Minecraft's core. God's the issues early minecraft has carried onto today

I'm never building a game engine