Back to results for “Fundamentals”
C# Programming › .NET Framework Fundamentals

What is the Just-In-Time (JIT) compilation?

Intermediate

Answer

Just In Time compilation is the process where the Common Language Runtime converts intermediate language code, called CIL, into native machine code at the moment a method is actually called during program execution, rather than compiling the entire application ahead of time. This approach allows the JIT compiler to optimize the generated machine code specifically for the exact processor and environment the application is running on, and once a method has been compiled, that native code is cached and reused for subsequent calls to the same method, improving performance.
// The method is JIT compiled the first time it is called at runtime
public int Add(int a, int b) {
    return a + b;
}
Real-world example A dot NET application deployed to different customer machines with different processor types automatically benefits from JIT compilation, since each machine gets machine code optimized specifically for its own hardware rather than a single generic build.

Common follow-ups: What is the difference between JIT compilation and Ahead Of Time compilation?;Does JIT compilation cause a startup performance cost?