Being a hardcore C developer, I always doubted whether JIT is actually performance centric or not. But guys! It is awesome. Kudos to Microsoft for this wonderful creation.

So, today’s post is actually on JIT. So how is it better? Hmmm..

  • An unmanaged compiler emits code specific to your processor i.e. Intel Pentium II, III, IV, Duo Core, Core 2 etc; but JIT doesn’t. The JIT compiler knows precisely which CPU the user has installed in their computer causing the JIT compiler to produce native instructions that are specific to the user’s machine. 
  • The JIT compiler is smart to know whether a machine has a single CPU or multiple CPUs installed. If a single CPU is installed, JIT does not employ certain multi-threaded operations. 

So this pretty neat compared to old-age compilers. What also ships with it is NGEN (Native Code Generator).

NGEN, as Microsoft says, is a tool that improves the performance of managed applications. Ngen.exe creates native images, which are files containing compiled processor-specific machine code, and installs them into the native image cache on the local computer.

The runtime can use native images from the cache instead using the just-in-time (JIT) compiler to compile the original assembly.

So now developers have two options. Use NGEN to have processor specific executables or JIT to have a executable for any processor. Difference? Its the speed of execution vs inter-operability. (Smart, isn’t it 😉 ) But there are some disadvantages of NGEN.. Explore this link http://msdn.microsoft.com/en-us/library/6t9t5wcf(VS.80).aspx