r/ProgrammerHumor • • Oct 07 '26

Meme minecraftException

Post image
9.3k Upvotes

830 comments sorted by

View all comments

Show parent comment

149

u/ArkoSammy12 Oct 07 '26

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

110

u/Level0Up Oct 07 '26

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

37

u/BlackHatMagic1545 Oct 08 '26

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 Oct 08 '26

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 Oct 07 '26

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 Oct 07 '26

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

-2

u/winauer Oct 07 '26

the code is shipped only obfuscated (until recently) instead of compiled

The code is shipped compiled. Or did you ever need to compile it yourself before running the game?

-2

u/JangoDarkSaber Oct 07 '26

The code is not shipped compiled. Java engine compiles its code at runtime.

https://en.wikipedia.org/wiki/Just-in-time_compilation

12

u/winauer Oct 07 '26

The code is compiled to JVM bytecode before shipping. The JVM compiles that to platform specific machinecode.

1

u/21839 Oct 08 '26

That only happens for a selected few hot spots in the program. The normal flow is that the JVM interprets bytecode on the fly.

7

u/Imaginary_Yak4336 Oct 07 '26

Java is compiled into Java bytecode, which is then compiled to machine code by the JVM at runtime.

Compilation doesn't exclusively refer to compilation to machine code.

-3

u/JangoDarkSaber Oct 07 '26

I never said it wasn’t compiled and I specified the details of the JIT compilation many times.

I’m refuting him because he specifically said the code is shipped compiled which is just straight up false.

5

u/Imaginary_Yak4336 Oct 07 '26

We seem to have a different understanding of shipped means. Is it a technical term in this context? The code is compiled, it is distributed that way. I don't see how it being compiled again makes the statement "the code is shipped compiled" incorrect

-4

u/JangoDarkSaber Oct 07 '26

Shipped means “is the code the developer gives you (Minecraft.jar) compiled?” The answer is no. The .jar file you download from Minecraft’s website is not compiled. It’s obfuscated but it’s not shipped as machine code.

When you run Minecraft, the Java engine turns the code into machine code using JIT compilation.

This differs from a game like counterstrike where the devs compile the source code and ship an executable.

Minecraft’s code isn’t compiled twice. The compilation happens while you’re running the game and only exists as machine code for the duration of the process run time.

This is relevant to the original point of this whole thread because the topic started on Minecraft modding.

Players could essentially see the raw source code as the devs see it where if Minecraft had been written in C++, players would have had to figure out a way to reverse engineer the machine code first.

→ More replies

1

u/mirhagk Oct 08 '26

Well technically machine code is also compiled down to microcode in a similar vein.

4

u/Mojert Oct 07 '26

Bytecode is not machine code