Before understand what CLR is and why we need it let me explain a little bit about the history of c-sharp before c-sharp we had two languages in the C family the C language and C++ with either of these languages when we compiled our application the compiler translated our code into the native code for the machine on which it was running which means if I wrote an application in C++ on a Windows machine with 8086 processor architecture the compiler would translate my code into the native code for that machine that is a Windows machine with an 8086 processor now we know we have different hardware's and we have different operating systems so if I took the application that compile the application on the computer with a different architecture that would not run so when Microsoft was designing the c-sharp language and the dotnet framework they came up with an idea that they borrowed from the Java community in Java when you compile your code it's not translated directly into the machine code it's translated into an intermediate language called bytecode and we have the exact same concept in c-sharp so when you compile your c-sharp code the result is what we call IL or intermediate language code is independent of the computer on which it's running now we need something that would translate that il code into the native code or the machine that is running the application and that is the job of CLR or a common language runtime so CLR is essentially an application that is sitting in the memory whose job is to translate the il code into the machine code and this process is called just-in-time compilation or JIT so with this architecture you can write an application in c-sharp and you don't have to worry about compiling that into the native code for different machines as long as a machine has CLR that can run your application
Post a Comment
If you have any doubt please let me know