javagccjvm

Java is interpreted on runtime?


Java compiler compiles to binary like gcc compiles C code ? or it just compile to another type of "language" that will be interpreted by another thing? I can't run it. It must be , I guess, the JVM right?

So, Java is not actually a true compiled language, is interpreted?


Solution

  • Java is not actually a true compiled language, is interpreted?

    Well...

    Java is compiled. But not to machine code, it is compiled to bytecode. Which the JVM can interpret. Or, it can in turn compile it further to machine code. That actually happens (at least for parts of the code) with the so-called Hotspot Just-In-Time compiler that is part of your standard JVM.

    What sets it apart from "real" interpreted languages like Perl or Python (even though those, too, "compile" to an internal representation) is that the code that you ship does not need the compiler to run anymore, just the runtime. Perl and Python on the other hand need to be capable to "eval" new programs at runtime.