Tuesday, January 13, 2009

What is Common language runtime?

What is CLR?
CLR (Common language runtime) is one of the major key components or core of .NET.
It provides an operating layer between .NET applications and the operating system available in specific machine.



.NET source codes which are builded by .NET compilers are very abstract, such that which leads to language inter operable.




From the above diagram, we can identify the compiled output from the c# source code is been referred in VB source code.
It is not like every language (java, c, etc….) compiled output can be reused in .NeT to re use there functionalities or logics.
There are very specific languages whose compiled output can be reused and such languages need to satisfy a set of rules called “Common Language Specification” (CLS).
So languages which satisfy the set of rules defined in CLS can be in set of interoperability of .NET applications.

So there is an abstract or conceptual representation of .NET applications which need to be understood by CLR to tell to operating system to perform such kind of tasks.
.NET Application abstract



Module

Managed code represents the functionality or implementation of the logic encoded in abstract binary form called Microsoft intermediate language (MSIL), or common intermediate language (CIL). This is also referred as intermediate language (IL).
This IL code from above abstract is managed at run time.
A .NET application may constitute of more than 1 managed executables.
Each managed executable consists of Meta data and Managed code.

CLR consists of 2 imperative components such as loader and Just in Time compiler (JIT Compiler).
Loader dynamically reads the Meta data of required module and creates in memory an internal representation and layout of the classes and members.
Only classes those are referred are loaded but not the entire module.
JIT Compiler compiles the methods encoded in IL into the native code of the underlying plat form.

This IL Code is then converted to native code and executable. There could be situations where this compiled native code is cached in CLR, such that next time when the same module was expected to be loaded, instead of again compiling IL to native code, only the Meta data of module is read by loader to create internal representation and layout.




Common Language Runtime (CLR)
The pre compiled code of the .NET frame work is saved into local disk, such that the pre compiled files are executed directly when required instead of again using JTI compiler to create native code.
Also, we need the original file as well as the pre compiled native code does not have meta data to create internal representation of classes or layout.

1 comment:

johnstany said...

I wondered upon your blog and wanted to say that I have really enjoyed reading your blog posts. Any way I’ll be subscribing to your feed and I hope you post again soon.