The heart to the .net frame work is its runtime execution environment that is called CLR or Common Language Runtime.As the name suggests it is a common runtime being used by variety of programming languages.The common features of CLR ie memory management,security,assembly loading,error handling is available to all languages that target the runtime.For example runtime uses "exception" to report errors.Thus all the languages that target runtime use exception to report errors. The code that runs under CLR is called managed code.
how ever before running under CLR any code that we write has to be compiled. And this compilation is a two step process in .net.
>Compilation of the source code to the microsoft intermediate language code MSIL(by the corresponding language compiler)
>compilation of il to machine specific code by the clr
This two stage compilation is very important because many of the .net key features is being provided by the intermediate language.IL is a low-level language that can be easily converted to the machine specific language.Having an universal syntax for the IL code gives the following advantage
Platform Independence
This means the same file containing the byte code instruction can be placed on any platform,the final stage of compilation can be easily accomplished so that it can run on that particular platform.Hence compiling the .net code to IL we achieve the same platform independence that compiling to java byte code,java has achieved.However complete platform independence for .net is theoretical.
Performance Improvement
IL is just in time compiled.Instead of compiling the entire application in one go JIT compiles each portion of the code as it is called.When a code is compiled the native executable is stored until the application exits so that it does not need to be recompiled the next time this portion of the code is executed.
Microsoft argues that this process is more efficient than compiling the entire code at the start of the application because a large portion of the code is not executed at any given run.This explains why the execution of managed IL is as fast as executing the native machine code.
But what Microsoft explains for the real performance improvement is:as the final stage of compilation takes place at runtime JIT is aware of what processor type the program will run on.that means it can optimize the final executable to take the advantage of any feature that the processor provides
Language Interoperability
We can compile to IL from one language and this code can be inter-operable with the code that has been compiled to IL from another language.
how ever before running under CLR any code that we write has to be compiled. And this compilation is a two step process in .net.
>Compilation of the source code to the microsoft intermediate language code MSIL(by the corresponding language compiler)
>compilation of il to machine specific code by the clr
This two stage compilation is very important because many of the .net key features is being provided by the intermediate language.IL is a low-level language that can be easily converted to the machine specific language.Having an universal syntax for the IL code gives the following advantage
Platform Independence
This means the same file containing the byte code instruction can be placed on any platform,the final stage of compilation can be easily accomplished so that it can run on that particular platform.Hence compiling the .net code to IL we achieve the same platform independence that compiling to java byte code,java has achieved.However complete platform independence for .net is theoretical.
Performance Improvement
IL is just in time compiled.Instead of compiling the entire application in one go JIT compiles each portion of the code as it is called.When a code is compiled the native executable is stored until the application exits so that it does not need to be recompiled the next time this portion of the code is executed.
Microsoft argues that this process is more efficient than compiling the entire code at the start of the application because a large portion of the code is not executed at any given run.This explains why the execution of managed IL is as fast as executing the native machine code.
But what Microsoft explains for the real performance improvement is:as the final stage of compilation takes place at runtime JIT is aware of what processor type the program will run on.that means it can optimize the final executable to take the advantage of any feature that the processor provides
Language Interoperability
We can compile to IL from one language and this code can be inter-operable with the code that has been compiled to IL from another language.
No comments:
Post a Comment