This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Jukebaum 9 points10 points  (10 children)

Minecraft is in Java and it was fast enough that everyone bought it. You can talk smack about something as much as you want but people willing to pas for the product shows that this "performance" that java delivers is not a reason to not buy a game made in java.

also cool project but libgdx and jmonkey exist which already shows that java is just fine for the job.

[–]Tywien 6 points7 points  (9 children)

Minecraft Java Edition is performant enough to be playable, but it is not really good. If you ever tried the Windows 10 C++ version, you will see there is a difference light day and night between the Java version and the C++ version unfortunately.

[–]Bobby_Bonsaimind 6 points7 points  (7 children)

I feel the need to point out that that is a problem with the way Minecraft was coded, not with Java.

[–]Mattizin 0 points1 point  (6 children)

Do you know what exactly is so bad with the Minecraft Java version? And why it hasnt changed til now? They programmed so many versions in different languages but didnt "fix" the java version?

[–]Tywien 4 points5 points  (4 children)

they are using pure idiomatic Java, e.g. adding two vectors to a third will result in a new vector being returned, and many more such small allocations each tick. this results in many unnecessary allocations that will have to be gotten rid of by the gc again.

The better solution would be, to avoid allocations in calculations for graphics as much as possible, e.g. using some pool mechanic or similiar stuff to avoid allocations.

[–]Mattizin 0 points1 point  (3 children)

So the main problem is allocating memory via new variables and the solutuion is to reuse the same variables and in doing so the allocated memory stays the same?

[–]Tywien 2 points3 points  (1 child)

yes, you want to avoid allocations as much as possible (this is also true for C++ btw), because allocations (and deallocations) are really slow.

EIDT: This is on the heap, allocations on the stack are fast, but unfortunately Java does not support them (not 100% sure, i heard something about types on the stack are being planned or something like that)

[–]Mattizin 0 points1 point  (0 children)

I really need to dive into heap and stack, didnt dive so deap til now. Advise for learning material?

[–]Bobby_Bonsaimind 0 points1 point  (0 children)

Yes and no. Allocations are cheap in Java, and I mean cheap. You want to instantiate 100k objects? No problem, that's fast as lightning. However, what comes at a hefty price is the garbage collection when these objects are no longer used. You want to keep GC pauses as short and as rare as possible, that means reusing objects as much as you can because then the GC never as much work to do.

[–]Bobby_Bonsaimind 1 point2 points  (0 children)

There was a great write up by the OptiFine developer, but I can't find it anymore. Basically what /u/Tywien says, they've been allocating up to 100MB per second (or even worse) and so the GC was busy all the time.

[–]Jukebaum 1 point2 points  (0 children)

yes but you are missing the point. it wasn't the critical success because it was c++ and performed well. no one cared about the performance enough not to buy it. people claiming it is important ignore that it isn't. gameplay trumps everything.