What is the "runtime environment" really?

15

Studying a little bit about ASP.NET 5 I came across something that I did not quite understand. To use it you need to install KVM (K Version Manager) and KPM (K Package Manager). KVM is responsible for managing KRE (K Runtime Environment) versions. In Powerhsell when using

kvm list

I have an answer more or less like this

Active Version     Runtime Architecture Location                    Alias
------ -------     ------- ------------ --------                    -----
       1.0.0-beta1 CLR     amd64        C:\Users\User\.kre\packages
       1.0.0-beta1 CLR     x86          C:\Users\User\.kre\packages default
       1.0.0-beta1 CoreCLR amd64        C:\Users\User\.kre\packages
       1.0.0-beta1 CoreCLR x86          C:\Users\User\.kre\packages

From what I understand then this KVM manages different versions of the CLR. But the fact is that to this day I do not quite understand what is runtime. My understanding of CLR today is well over, I understand: when developing an application using C # the compiler turns the code into an intermediate language called CIL (Common Intermediate Language) and then the CLR is responsible for interpreting this intermediate code.

In this way, although the C # code is compiled, the CLR still has to interpret an intermediate code. My understanding is that the "Runtime Environment" is the environment in which the CLR interprets this intermediate code.

I do not know if that's right. So, what is this "Runtime Environment" really? How does it really work? And why are there so many different versions now?

    
asked by anonymous 19.02.2015 / 18:51

1 answer

11

The CLR is the runtime environment . R is just runtime . It is the infrastructure responsible for running the program.

In a way we can say that every program needs a runtime system. Some need very little - just plain simple things written in assembly (your best chance of runtime being light or nonexistent) and C, others need a lot - interpreted languages.

The fact that you need to order things for the operating system (a memory allocation for example) already requires a runtime . It is nothing more than a set of codes that allow the program to do basic things.

In the case of .Net the runtime is not trivial at all. He is responsible for:

  • accommodate the entire code;
  • Just in Time compilation (which is a little different than just interpreting CIL's bytecode );
  • take care of security;
  • manage memory (GC);
  • handle exceptions;
  • provide reflection;
  • provide and control interoperability between your languages and native foreign code, including operating system services (memory, processes, access to resources, etc.);
  • has a part of the standard library that is required for the basic operation of any application;
  • and still have subsystems that allow monitoring and diagnostics of the application (I probably forgot something).

So you already knew part of what the CLR is.

Note that the CLR exists for a specific platform. It is the .Net platform. So we did not need (or did not need to) worry about which platform to run on. He cares about us but at the lowest level there has to be something specific.

There are different versions because there are different evolutions and needs. Before the motto was to have only one thing that suited everything, now it seems that it is better to have specialized versions that best suit only what you need. Each approach has its advantages.

.Net already had some versions of the CLR but you did not have to worry about it. The one that best attended was selected. Now for better feature optimization you need to worry if you want.

Some variation information can be found at blog .

Official CoreCLR open source for you to try to understand everything inside it :) Have fun.

    
19.02.2015 / 19:17