What really is the “runtime environment”

netprogramming-languagesruntimeterminology

This is a very basic question but is something I've never completely understood and recently, when studying .NET Core and ASP.NET 5 I felt the need of a more complete understanding of the topic.

Reading the article Introduction to the Common Language Runtime (CLR) there we find the following piece of text:

Every program has a surprising number of dependencies on its runtime environment. Most obviously, the program is written in a particular programming language, but that is only the first of many assumptions a programmer weaves into the program. All interesting programs need some runtime library that allows them to interact with the other resources of the machine (such as user input, disk files, network communications, etc). The program also needs to be converted in some way (either by interpretation or compilation) to a form that the native hardware can execute directly.

Now, this idea of runtime environment seems to be very basic, but still very important, not just when working with .NET but when dealing with programming in general. It seems to be a general concept which is quite important to understand.

Until today I always had one intuitive and simple understanding about it: runtime environment is the environment on which the code will run. But this is a quite loose way to understand it. There is probably much more to it as can be infered from the above text.

In that setting: what really is the runtime environment in general? Not just for .NET, but in programming in general, what is the runtime environment? Is it just something conceptual or is it some piece of software, like the CLR for .NET? In summary, how should we properly understand the idea of runtime environment?

Best Answer

There are a few components that make up the runtime environment. Not all components are applicable to all environments (e.g. assembler, C++, and C# all have different runtime facilities), but they generally comprise the following:

  • The CPU and hardware platform on which the program runs.
  • The operating system that runs the program, including device drivers that interface with the hardware.
  • Standard libraries available to the language and platform. Certain environments (e.g. embedded) may pare down the relevant standard library due to space concerns.
  • Frameworks and other libraries linked into the program either statically or dynamically.
  • Any interpreter that sits between the program and the operating system, such as the CLR, JVM, shell (for e.g. a Bash script), Perl/Python interpreter, et al.

Remember, computers are all about layers and abstractions. As you can gather from the list above, a runtime is pretty much a collection of abstractions that sit between the bare metal and the running program.

Related Topic