Learn about Components Of .NET

.NET Introduction

.NET is not a programming language but it is a tool that provides an environment to write the code and run the applications. .NET supports 63 programming languages in 11 languages developed by Microsoft and 52 programming languages developed by another organization.

The components of .NET are CLR, Garbage Collector, JIT Compiler and base class library,

.NET Introduction

CLR (Common Language Runtime)

CLR is responsible for providing common syntax, automatic memory management, and common data types. Also, the responsibility of CLR is to generate native code from MSIL Code.

CLS (Common Language Specification)

As we know .NET supports 63 programming languages and also we know that each and every language has its own syntax for writing code and one language does not support the syntax of another language. That means .NET has features of common syntax which are supported by all 63 programming languages.

CTS (Common Type System)

As we know .NET supports 63 programming languages and also we know that each and every language has its own data type system and One language does not support the data type of another language. That means .NET has features of Common Data type which is supported by all 63 programming languages.

Example

There is an integer data type in C# .NET,

int i = 123;

There is an Integer data type in J# .NET

Dim I As Integer

As we are looking both languages have their own data type system. But these languages will support the common data type of .NET which is.

Int32

Garbage Collector

The Garbage Collector is responsible for the automatic memory management of objects. Also, the responsibility of the garbage collector is to remove the object from memory that has no use. In Garbage Collector Memory is divided into 3 generations and these generations are Generation 0, Generation 1, and Generation 2.

When a new object is created it gets stored in Generation 0 and the process gets repeated till Generation 0 is full. When Generation 0 size gets full then there 2 processes will be performed. The first Process is marking the object which is not reachable for a long time. In the Second process object will be removed from the memory that has been marked early and the remaining object will be transferred to Generation 1. This process will repeat also for Generation 2. There are 3 methods for removing objects from Memory. These methods are (1) Dispose () (2) Finalize () (3) GC. Collect ().

  • Dispose Method: Dispose method is used to remove the object from memory that has no reference this method gets called by the User.
  • Finalize Method: The finalize method is used to clean up the object from memory. This method is called by System.
  • Gc. Collect Method: This method is used for removing the object from memory forcefully.

JIT Compiler: JIT Compiler is responsible for compiling the MSIL Code and generating the Native Code. There are the following 3 types of JIT compiler,

  • Normal Jitter: Normal jitter is a Default jitter that compiles the code line by line and it stores the cache of compiled code.
  • Echono Jitter: Echono jitter compiles the selected line of code and it does not contain the cache of compiled code.
  • Pre Jitter: Pre Jitter Compiles the code from top to button and also it stores the cache of compiled code.

Why do we use ngen.exe?

Ngen.exe is a tool that is used to compile the MSIL code and generate native code. We use the ngen.exe tool because it stores all the compiled code in a separate disk which is known as image generation files. The code compiled by ngen.exe can be reused but the JIT compiler does not store compiled data.

Code Compilation in .NET

.NET supports 63 programming languages and each and every language has its own compiler. Language compiler the source code and generate MSIL (Microsoft Intermediate Language) then MSIL code gets transferred to CLR and JIT compiler compiles this code and generates native code.

Code Compilation in .NET

In .NET there are 2 phases of a compilation of code. In the first phase, source code gets compiled by the source code language compiler and generates IL code and in the second phase, IL code gets compiled and generates native code. This 1st Phase is slower than the 2nd Phase. Code compilation in .NET is graphically represented above.


Similar Articles