Runtime, in computer terms, is the time in which the computer program is actively executing the written code. The Common Language Runtime is a platform where a managed program executes.
There are many advantages when a managed program is run in this environment. For example:
- Easy usage of components written in other programming languages
- Garbage Collection
- The ability to compile once and run on any CPU or OS which supports the CLR
- Interoperability with unmanaged code
- Very strong type safety
- Creation of multi-threaded programs
- Uniform exception handling support
To use the CLR you must perform the below steps.
- Use a compiler which targets the CLR environment. Using any of the Visual Studio languages (C#, Visual Basic, Visual C++, etc…), plus others such as Eiffel, Perl or COBOL will result in a program being compiled into Common Intermediate Language (CIL). See my posting about CIL here for more information on that specific topic here.
- Using a program called Ngen, the bytecode can be compiled into native code for the target machine. In my opinion, using Ngen ahead of time is much better than waiting for JIT compilation. This is due to performance gains and allows for sharing of the program across multiple processes within the assembly.
- Run the program on the targeted machine. When run, the managed program receives all the benefits previously listed in the first bullet list.