Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and the Yahoo Answers website is now in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

What is JIT compiling exactly and how is it related to Java?

Please start from the beginning,

What is it?

How does the compiler work

and

How does this differ from normal compiling in C or C++ compiling (this is a language I started learning and am learning about the linking and loading phases of the compiler here, so I thought if I could contrast from a C/C++ aspect then JIT might make more sense because I don't understand what it means to "just in time" when compared to normal compiled languages?)

Thanks

2 Answers

Relevance
  • 7 years ago
    Favorite Answer

    A Just-In-Time (JIT) compiler is a feature of the run-time interpreter, that instead of interpreting bytecode every time a method is invoked, will compile the bytecode into the machine code instructions of the running machine, and then invoke this object code instead.

    Generally a Java program first compiled to byte code (usually bytecode or some kind of VM instructions). A JIT compiler runs after the program has started and compiles the byte (or similar) code on the fly (or just-in-time, as it's called) into a form that's usually faster, typically the host CPU's native instruction set.

    A JIT has access to dynamic runtime information whereas a standard compiler doesn't and can make better optimizations like inlining functions that are used frequently.

  • 7 years ago

    The compiled C/C++ byte code will read from the hard drive into RAM. The C compiler linked to the vast libraries and included that code from the libraries that has calls from the programmer's code.

    JIT will compile in RAM from the bytecode. Bytecode is different from bytes in that bytecode is universal to run the various flavors of the engine layer previously installed across hardware platforms. The bytecode is optimized as compiled in RAM as bytes. JavaFX may at some point in the future have a revised technique that will bypass the JIT and run like a C program. Also, future Java may have a revised, smaller API that will download any needed additions from the internet.

    You understand that C/C++ has optimized libraries for the various CPU / OS combinations? If you want to make revisions for an older C program, the linking becomes problematic as there is no documentation about which links, which libraries were used. NetBeans IDE does keep a links history for a C project, but if you were compiling from Terminal, then you would need a notebook to keep handwritten notes.

    C /C++ compiled programs have a very small footprint. Java requires a 13-megabyte JRE. Microsoft .NET requires a 9 GIGAbyte runtime engine. The basic, minimal C library to install if C ran like Java or C# would be 5.7 megabytes and we would also include 37.5 megabytes of library to do all of the additional hardware capabilities that C can address. But, then we would also need for this hypothetical C programming technique the library for AMD64 processor, the x8086, the P-II, the Quad8, Xenon, and the list goes on and on.

Still have questions? Get your answers by asking now.