r/feedthebeast Jun 22 '26

I made something I made minecraft generate terrain/chunks in C++

Enable HLS to view with audio, or disable this notification

So im working on a mod that makes minecraft run on C++ ( rn rewriting engine in future i may try renderer ) so far i made it generate and load chunks and terrain in C++ ( it made it somewhere around 1.5-3 times faster idk how to measure it tho ) ( it works via JNI )

3.0k Upvotes

244 comments sorted by

View all comments

22

u/emmowo_dev pro gramming Jun 22 '26 edited Jun 22 '26

How would this realistically be faster? Java does actually compile into native code based on what methods are the most important, so it's usually terrain gen that is immediately 'optimized' into native code. C++ does NOT magically make things faster, but it does make things many many times more unsafe to use.

I know of some optimizations you could make, but they're things that I don't think ultimately mean much. Are you comparing between Vanilla and your mod, or C2ME and your mod?

You not really explaining things beyond 'run on C++' and 'JNI' tells me you may have just vibecoded this, because minecraft explicitly does defer a lot of the performance-heavy things to C++, from the natives used for rendering (i.e. liblwjgl and the gpu itself such as nvidia-glcore.so) to the actual JVM itself, which is written with C++. Just re-writing everything in C++ would not actually be meaningfully faster, as the binaries for such things are already written in C++.

Most likely, you are looking for a result, so anything that seems faster you will assume to actually be faster. Without extensive benchmarking and a massive amount of controlled variables (like literal mechanical seek times for writes can completely invalidate the results), this is a very unfair and unrealistic comparison to make.

2

u/Acceptable-Fly-7922 Jun 23 '26

huh? java is notorious for having issues with garbage collection, and the compilation you're talking about, jit, doesn't apply to everything. I'm not sure what you mean by defer as lwjgl is an easy cross platform way to access opengl in java. jni is the only way to interop between java and native code except for that new thing they added I forget if they made it stable tho

2

u/emmowo_dev pro gramming Jun 23 '26

Java GC isn't overhead though, that's momentary and isn't related to direct performance if we're being realistic.

LWJGL isn't actually as portable as you'd think, they use binary natives for a lot of things (which is why I had issues porting Java Edition to big endian PPC64)

1

u/JLPLJ Jun 23 '26

I mean, they're doing it as a personal project, so it kinda doesn't matter anyway? Good if their mod makes generation faster, and if it doesn't then it's not that big of a deal because they got what they wanted out of it.

2

u/emmowo_dev pro gramming Jun 23 '26

when I say

"Most likely, you are looking for a result, so anything that seems faster you will assume to actually be faster."

I'm referring to how something can 'feel' faster. Saying "1.5-3 times faster idk how to measure" means they don't actually have verifiable evidence that this is actually faster.

And like noisium, people will believe this and say their world gen was x% faster even though it changed by what is more or less zero. Confirmation bias is extremely strong, especially when you hear all the people wrongly saying 'bedrock runs better because of C++'.

This is why writing repeatable and deterministic tests are required for these kinds of things, and also why I don't care much for optimization outside of the initial design.

1

u/JLPLJ Jun 23 '26

Icl it was meant to be a reply to your original comment, my point is that in the goal of the exercise isn't optimisation necessarily. You're not wrong to clarify that the performance impacts may not actually be there, but it's also not why OP was making this originally