Breaking News

Monday, 16 February 2015

Common Language Runtime


CLR is the heart of the .NET framework. .NET applications are compiled to a common language known as Microsoft Intermediate Language or “IL”. The CLR, then, handles the compiling the IL to machine language, at which point the program is executed. The CLR environment is also referred to as a managed environment, in which common services, such as garbage collection and security, are automatically provided.

The CLR allows objects created in one language be treated as equal citizens by code written in a completely different language. To make this possible, Microsoft has defined a Common Language Specification (CLS) that details for compiler vendors the minimum set of features that their compilers must support if they are to target the runtime. Any language that conforms to the CLS can run on the CLR. In the .NET framework, Microsoft provides Visual Basic, Visual C++, Visual C#, and JScript support.
The CLR simplifies application development, provides a robust and secure execution environment, supports multiple languages and simplifies application deployment and management.

Common Type System

The Common Type System defines how data types are declared, used, and managed in the runtime, and is also an important part of the runtime’s support for the Cross- Language Integration. The common type system performs the following functions:
• Establishes a framework that enables cross-language integration, type safety, and high performance code execution.
• Provides an object-oriented model that supports the complete implementation of many programming languages.
• Defines rules that languages must follow, which helps ensure that objects written in different languages can interact with each other.

The Common Type System can be divided into two general categories of types, Reference type and Value type each of which is further divided into subcategories. 


Garbage Collector
Now let us discuss about an important feature of the CLR called Automatic Memory Management. A major feature of .NET framework CLR is that the runtime automatically handles the allocation and release of an object’s memory resources. Automatic memory management enhances code quality and developer productivity without negatively impacting expressiveness or performance.

The Garbage Collector (GC) is responsible for collecting the objects no longer referenced by the application. The GC may automatically be invoked by the CLR or the application may explicitly invoke the GC by calling GC.Collect. Objects are not released from memory until the GC is invoked and setting an object reference to Nothing does not invoke the GC, a period of time often elapses between when the object is no longer referenced by the application and when the GC collects it.

Just-In-Time Compilation (JIT)

The MSIL is the language that all of the .NET languages compile down to. After they are in this intermediate language, a process called Just-In-Time (JIT) compilation occurs when resources are used from your application at runtime. JIT allows “parts” of your application to execute when they are needed, which means that if something
is never needed, it will never compile down to the native code. By using the JIT, the CLR can cache code that is used more than once and reuse it for subsequent calls, without going through the compilation process again.

JIT Compilation Process

The JIT process enables a secure environment by making certain assumptions:
• Type references are compatible with the type being referenced.
• Operations are invoked on an object only if they are within the execution
parameters for that object.
• Identities within the application are accurate.

No comments:

Post a Comment

Designed By Blogger Templates