The Role of the .NET Platform
Bill Gates once said that the .NET platform is the best Microsoft has ever created. Perhaps he was right. The .NET framework provides a powerful framework for building applications. The following main features can be distinguished:
- When compiled;
- Powerful class library;
- Variety of technologies;
- Add to this the actively developing and growing popularity of Blazor, a framework that runs on top of .NET and which allows you to create web applications on both the server and client side;
- Performance. In a number of tests;
- Also, one should also note such a feature of the C # language and the .NET framework as automatic garbage collection..
When you hear the phrase “.NET Platform”, you should know that behind this concept is a collection of many services and components that ultimately allow an application developed in c # (as well as any other .NET-supported) application to run on the Windows environment. For now, we will only talk about the Windows operating system. The two basic building blocks of the .NET platform are the Common Language Runtime (CLR) and the Common Class Library.
A class library is a huge collection of all sorts of classes that, in the process of using them as a developer, ultimately provide the necessary functionality for your application being developed. Accordingly, all classes are strictly structured and divided into groups, because each of them encapsulates some unique functionality. Separate groups include those classes, the functionality of which is similar, or refers to the same topic, or on some other grounds.
The CLR is some kind of shell that controls the execution of your code. This control manifests itself in memory, in application threads, in remote communication, and also in strict control of the compliance of the executable with a set of requirements. In short, the CLR is a collection of some services that execute your code. This leads to one important conclusion: not every code can be executed under the control of the CLR. Naturally, there are a great many programming languages and each of them is somehow connected with a certain platform. In view of this, they say that the code that was developed to run the CLR (that is, the .NET platform) is called managed. And the one that was not designed to run under .NET is called unmanaged. But these concepts only apply to .NET itself.
.NET Framework and .NET Core / .NET 5
It is worth mentioning the Mono platform, which was created back in 2004 and provided an open source version of the .NET Framework for Linux and MacOS by Fireart. Using Mono, it was possible to create cross-platform C # applications. Mono is still in use. For example, Xamarin, a technology for building mobile apps for Android and iOS using C #, uses Mono. However, in the future, when a new version is released – .NET 6 next year, it is planned that .NET 6 will incorporate the Mono platform.
Managed and unmanaged code
An application written in C # is often referred to as managed code. What does it mean? This means that this application is built on the .NET platform and therefore is controlled by the common language runtime (CLR), which loads the application and cleans up memory as needed.
As mentioned above, C # code is compiled into applications or assemblies with exe or dll extensions in CIL. Further, when such an application is launched for execution, JIT compilation (Just-In-Time) occurs into machine code, which is then executed. At the same time, since our application can be large and contain a bunch of instructions, at the current time only the part of the application that is being accessed will be compiled. If we turn to another part of the code, then it will be compiled from CIL to machine code. Moreover, the already compiled part of the application is saved until the program terminates. This ultimately improves productivity.
In fact, this is all there is to know briefly about the .NET platform and the C # language. Now let’s create our first application.