Common Language Runtime (CLR)

Common Language Runtime (CLR)

image 65

The Common Language Runtime (CLR) is an Execution Environment . 

It works as a layer between Operating Systems and the applications written in .Net languages that conforms to the Common Language Specification (CLS).  

The CLR execution perform in two steps

1. In the first step the appropriate Language compiler converts the code in IL or MSIL (Microsoft Intermediate Code) which is also code as assembly code …

2. In the Second step the Common Language Runtime (CLR) ‘s Just In Time (JIT) compilation converts Intermediate Language (MSIL) to native code on demand at application run time.

The main function of Common Language Runtime (CLR) is to convert the Managed Code into native code and then execute the Program. 

The Managed Code compiled only when it needed, that is it converts the appropriate instructions when each function is called. 

That means all .NET programming languages use the same representation for common Data Types, so Common Language Runtime (CLR) is a language-independent runtime environment.

The Common Language Runtime (CLR) environment is also referred to as a managed environment because during the execution of a program it also controls the interaction with the Operating System. 

The CLR has the following key features:

1. Exception Handling

Exceptions are errors which occur when the application is executed. 

Examples of exceptions are: 

If an application tries to open a file on the local machine, but the file is not present.

If the application tries to fetch some records from a database, but the connection to the database is not valid. 

2. Garbage Collection

Garbage collection is the process of removing unwanted resources when they are no longer required. 

Examples of garbage collection are 

A File handle which is no longer required. If the application has finished all operations on a file, then the file handle may no longer be required. 

The database connection is no longer required. If the application has finished all operations on a database, then the database connection may no longer be required. 

3. Type Safety

CLR provide type safety by the CLS in this it will check type safety feature

4. Thread Management

ClR also support multi-threading environment.

5. Working with Various programming languages

As noted in an earlier section, a developer can develop an application in a variety of .Net programming languages. 

A. Language

The first level is the programming language itself, the most common ones are VB.Net and C#. 

B. Compiler

There is a compiler that will be separate for each programming language. So underlying the VB.Net language, there will be a separate VB.Net compiler. Similarly for C#, you will have another compiler. 

C. Common Language Interpreter

This is the final layer in .Net which would be used to run a .net program developed in any programming language. So the subsequent compiler will send the program to the CLI layer to run the .Net application.

Leave a Comment

Crypto logo

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus cursus rutrum est nec suscipit. Ut et ultrices nisi. Vivamus id nisl ligula. Nulla sed iaculis ipsum.

Contact

Company Name

Address