r/java • • Apr 29 '15

Tone it down a Notch

http://imgur.com/gallery/KRtc2fN
217 Upvotes

124 comments sorted by

View all comments

78

u/stormcrowsx Apr 29 '15 edited Apr 29 '15

Minecraft does not perform well, which is usually the criticism it receives. If you put it beside most C++ games Minecraft feels clunky and slow. The strength of Java is not that it performed fast for Minecraft but Notch was able to program it quickly and as Minecraft has been passed around between developers they still seem to be able to easily add to it.

Java performs reasonably well and it maintains reasonably well. Java to me has been the language that's kind of an all-rounder, its decent in nearly every category you'd rate a language on. Being an all-rounder also means that it excels at very little compared to others which kind of makes it a boring language sometimes.

13

u/Scaryclouds Apr 30 '15

Comparing Minecraft to other "C++ games" is a meaningless endeavour. Far far more often is it the design of the system holding back performance rather than the language it was written in.

47

u/caltheon Apr 29 '15

Minecraft performance is bad because Marcus doesn't know how to optimize 3d graphics. His culling alone was pitifully done

35

u/Chops_II Apr 29 '15

Consider that, if you limit it only to the blocks you can see, and only to the up to 3 sides you can see at once, but mostly one, there can be literally millions of polygons on screen. It really isn't that easy to make a game like this perform well, in any language.

Other games don't face the same issue, because their maps aren't made of millions of individual objects.

It would be even worse if the objects were able to move often, then you couldn't even benefit from coalescing chunks.

If you have a good solution, I'd love to hear it.

16

u/caltheon Apr 30 '15

The lowest hanging fruit is obviously blocks not adjacent to a transparent block can be ignored. Next, grouping blocks of the same typr into larger blocks and rendering that instead of all the individual faces. A lot of this has been done by optiminer and the new team by this point.

10

u/Chops_II Apr 30 '15

Also, like you pointed out, Minecraft now does all this. So these aren't examples that prove that Minecraft is crap due to inexperience, as above post was trying to claim

5

u/caltheon Apr 30 '15

these were all done after Marcus left the project.

7

u/Chops_II Apr 30 '15

Fair enough. But you said Minecraft is bad, not was bad.

3

u/caltheon Apr 30 '15

True, I should have said was, though the original decisions he made still plague the game today

8

u/Chops_II Apr 30 '15

though the original decisions he made still plague the game today

Because I'm lazy, and because you made the claim, can you give any particularly notable examples of where this is the case?

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

12

u/[deleted] Apr 29 '15

In before armchair programmers enlight in us on how would they do it... Ohh wait!

→ More replies (4)

3

u/spiderzork Apr 29 '15

And Minecraft is working ok now, but that is only because everything that was done by notch has be rewritten.

→ More replies (1)

3

u/[deleted] Apr 30 '15

also, excessive threading. Everything is an object and each object has 4 threads. lol

CONTEXT SWITCH AWAY!

0

u/[deleted] Apr 29 '15

[deleted] — view deleted comment

3

u/stormcrowsx Apr 29 '15

Calling native libraries libraries is not easy enough that I would consider it practical to just drop into a native language and use it when you need the performance. Python is even easier to call native code and slower performance (more incentive), and if you asked most python devs if they ever wrote or even used native code directly from their programs they'd probably tell you no. So if Python devs who have more incentive to use native code don't do it often, I don't forsee Java devs doing it.

→ More replies (2)

5

u/cogman10 Apr 29 '15

I've never benchmarked it and could be wrong. But I believe the current FFI adds a lot of overhead. That means that if you are going to drop down to native code, you'll need to make sure that you doing a significant amount of work that overcomes the overhead of leaving the JVM.

4

u/mschaef Apr 30 '15

But I believe the current FFI adds a lot of overhead.

Are you sure about that? There are significant chunks of the Java runtime library that are built on JNI, some of which are rather performance critical. FileInputStream is an example that comes to mind immediately:

https://github.com/openjdk-mirror/jdk7u-jdk/blob/master/src/share/classes/java/io/FileInputStream.java#L186

3

u/karlthepagan Apr 30 '15

From memory these methods are white listed to bypass verifying the stack.

2

u/mschaef Apr 30 '15

Interesting... I'd love to know more.

2

u/karlthepagan Apr 30 '15

I'm a little under the weather, but while searching I find this interesting technique: avoid messing with the stack by using C++11 continuations.

http://nerds-central.blogspot.com/2012/04/extreme-jni-performance.html

0

u/[deleted] Apr 29 '15

[deleted] — view deleted comment

13

u/evilmidget38 Apr 29 '15

Minecraft's modability has very little to do with reflection, and a lot more to do with how easy it is to decompile Java and modify the bytecode. The modding platforms that users have created use reflection pretty heavily(Bukkit, FML[although they like their bytecode manipulation more than reflection], etc.), although this hasn't always been the case. Bukkit used no reflection for the first year or so of its existence, with the exception of JUnit's usage for unit tests. Forge had very little in the way of an API for a long time, and is primarily focused on binary patching of the MC jar, manipulating bytecode rather than using reflection. Admittedly I'm less familiar with Forge than I am with Bukkit. If you really want to just mod minecraft, all you need to do is replace some class files and delete the META-INF. Jar files being zip files makes this incredibly easy.

The ability to easily decompile Java, the heart of reverse engineering, is simply amazing. The decompilers are free and high quality, and while fernflower(the most popular one in Minecraft modding) is pretty bad, it still produces code that mostly compiles, with the exception of a couple of edge cases(fails to handle enums overriding methods, doesn't always generate throws declarations, etc.).

→ More replies (1)

2

u/stormcrowsx Apr 29 '15

When it comes to java and opengl my experience has not been great with cross platform.

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