Siksha Sarovar

Siksha Sarovar (sikshasarovar.com) is a free educational web application that helps students in India learn programming and prepare for academic and competitive exams. The platform offers structured coding courses (C, C++, Python, Java, HTML, CSS, PHP, Power BI, AI, Machine Learning, Data Science), complete university curriculum notes for BCA/MCA students with previous year question papers, Class 10 and Class 12 CBSE/HBSE school notes, and dedicated preparation material for SSC, UPSC, Banking, Railway and other government exams. Browsing the site is completely free and requires no account. Users may optionally sign in with Google solely to save their learning progress, quiz scores and personal preferences across devices.

Privacy Policy | Terms of Service | Contact Siksha Sarovar | About Siksha Sarovar

v4.0.9 · PWA
Siksha Sarovar logo
Siksha Sarovar
Your Learning Universe

Siksha Sarovar is a free e-learning platform for coding courses, BCA university notes and competitive exam preparation. Optional Google sign-in saves your learning progress across devices.

Initializing knowledge base…
Compiling modules 0%

IL and JIT Compilation

Lesson 8 of 27 in the free C# Programming notes on Siksha Sarovar, written by Rohit Jangra.

Intermediate Language (IL)

When you click "Build" in Visual Studio, your C# compiler (csc.exe) does NOT create machine code. It creates MSIL (Microsoft Intermediate Language).

  • Why? This allows the binary to be platform-independent. The same .dll can contain instructions that can be understood by a 32-bit, 64-bit, or even ARM processor, provided there is a CLR for that platform.

Study Deep: The Three Types of JIT Compilers

The CLR actually supports three ways to perform JIT compilation:

  1. Normal JIT (Default): Compiles methods only when they are called and caches the result in RAM. Fast and efficient.
  2. Econo-JIT: Compiles methods when called but doesn't cache them. Good for low-memory devices (rarely used now).
  3. Pre-JIT (Ngen.exe): Compiles the entire assembly into native code before execution (at install time). This speeds up application startup but sacrifices platform independence for that specific binary.

JIT (Just-In-Time) Compiler

Since the CPU cannot understand IL directly, someone needs to translate it into the native language of the CPU (0s and 1s specific to the chip structure). This is the job of the JIT Compiler.

Why "Just-In-Time"? It doesn't compile the entire program at once (which would slow down startup). It compiles methods only when they are called.

Types of JIT Compilers

TypeDescriptionPros/Cons
Pre-JITCompiles the whole assembly to native code before execution (using tool Ngen.exe).Pros: Faster startup. Cons: Code isn't optimized for current runtime conditions.
Normal JITCompiles methods on demand (the first time they are called). Caches the result.Pros: Best balance of startup speed and runtime performance. Cons: Slight delay on first method call.
Econo-JITCompiles on demand but discards the native code after execution to save memory. (Obsolete).Pros: Saves memory on constrained devices. Cons: Very slow performance (re-compiles loops).