You know that Java and c# convert (Phase 1) your source code into IL bytecode, but it must still become (Phase 2) machine code before it can run on the processor, under supervision of the VM.
In Phase 1, the Intermediate Language compiler (javac or csc.exe) converts source code into platform-Independent IL bytecode, packaged into physical files — class files, jars or assemblies in extended PE [1] format. Note Phase 2 would produces no file.
** Unlike a C++ object file the IL files aren’t strictly executable on the Real Machine. Executable on the VM installed in the Real Machine.
**The most attractive feature of the JVM lies in the platform-independent bytecode. Write once run anywhere (including Mac, Linux, etc) with decent performance comparable to C. That’s why we could (unbelievable at first) build jars on windows and run them on unix.
In Phase 2, the JIT compiler converts IL bytecode into platform-dependent, CPU-specific machine code.
** presumably, happens at run time, each time you execute the IL files
** Is there a command line tool to run JIT compilers and produce the native executable file? Look at ngen.exe. Even if you can get the native code it is designed to execute within the VM
Phase 2 is less visible. When app developers talk about compilation, they mean Phase 1
Phase 2 is platform-specific. Phase 1 is platform-independent.
Regular assembly file holds IL code on disk. Upon first use each method is JIT-compiled to platform-dependent machine code. So if you monitor the execution speed of such a method, you see
app launch – slow – fast – fast – fast …app launch – slow – fast – fast …app launch – slow – fast – fast …
Now, ngen.exe dose a pro-active JIT, so the native machine code is saved on disk in the GAC and/or native image cache. The same method would show no “slow” —
app launch – fast – fast – fast …app launch – fast – fast – fast …app launch – fast – fast – fast …
It’s interesting to compare perl. I believe perl also compiles source code into bytecode, which gets interpreted.
For python, see http://stackoverflow.com/questions/471191/why-compile-python-code
[1] for the PE format extended for dotnet, see other posts in this blog, or see http://www.informit.com/articles/article.aspx?p=25350