Home > Article > Backend Development > C# Compilers
A C# Complier can be defined as an in-built component that is used for turning the C# programmed code into a machine readable language code, which returns the output files in the form of .dll files or .exe files. C# has two different types of compiling methods, namely Common Language Runtime compiling (CLR) and Just in time compiling (JIT). The JIT compilers are further classified as Pre JIT compiler, Normal JIT compiler and Econo JIT compiler. A few of the commonly used tools for this compilation purposes are C# compiler 2.0, C# compiler 3.5, C# compiler 4.x, Roslyn and Mono Compilers.
So, after the intermediate language generated we required to convert this IL to machine codes because processor only understood machine codes. So we used CLR (Common Language Runtime) for this conversion. CLR is a program that runs on the computer and changes the IL code to machine codes with the help of Just-In-Time (commonly called JIT). When we double-clicked on the .exe file JIT compiler is invoked and compiles the IL code at that part of the time, so that’s why it is named JUST-IN-TIME(JIT).
Compilation can be done implicitly or explicitly. The implicit compilation is twice compilation in which first, it is compiled IS and after that, it is compiled to machine language. This process is called JIT compilation or JUST-In-Time compilation. JIT supports multiple platforms and speeds up the execution of the code.
There are three different Just-In-Time Compiler
1. Pre JIT compiler
In this compiler, there is only a single compilation process as the whole source code is compiled into the native code.
2. Normal JIT compiler
In this compiler, only those methods are compiled into machine code, which is required at run time. The compiler compiles those methods, stores them in the cache, and used the same method again.
3. Econo JIT compiler
In this compiler, only those methods are compiled into machine code which is required at a run time however these methods are removed if they are not required. In JIT, only the required method is compiled at run time, therefore, it requires less memory usage.
In the above diagram
1-3 steps will execute at the compile time
3-5 steps will execute at the run time.
So, when we run these two types of error occurs.
Earlier Microsoft compilers were named as .Net Framework like C# compiler 2.0, C# compiler 3.5, C# compiler 4.x, etc. These compilers were not written in C# or we can say C# was not compiled by C#. The other compilers which came into existence after this are:
Earlier the compiler was written in C/C++. Roslyn is open source .Net compiler in which the C++ code is replaced. It fetches the types of elements in code, their relation with each other. As C# and VB teams wrote the compiler, therefore, visual studio templates available for both. It allows us to write code which parses a source file and It is easy for us to modify source code.
The following are the four API layers of Roslyn
Mono C# compiler based on ECMA standards for C#. It has multiple versions with a framework like C# 1.0, 2.0, 3.0, 4.0. The mono compiler mcs targets framework 1.1, gmcs targets framework 2.0 whereas smcs and dmcs target framework 2.1 and 4.0 respectively.
The other compiler like RemObjects C# compiler which follows C# standard as per EMCA specification and other than that there are GNU C# compilers that implements C# and .Net.
C# compiler is just like any other compiler which compiles code into machine code so that the processor can understand the process.
The above is the detailed content of C# Compilers. For more information, please follow other related articles on the PHP Chinese website!