Distinguish .NET Core, .NET Framework, .NET Standard

Tram Ho

.NET Core was born in 2016 and has been released to version 3. Currently, .NET Core also won the priority over the .NET Framework – a traditional platform that was born in 2001.

In recent times, many important changes have occurred to .NET Core, especially .NET Core 3.0 (September 2019) and 3.1 (November 2019). These big changes make many .NET programmers confused.

It is even more confusing for those of you who are new to .NET technologies and eager to learn this technology.

In this article we will try to explain in the simplest way the relationship between the .NET Core and .NET Framework platforms as well as the future development trend of these platforms.

.NET Framework – platform, framework, library .NET Framework is a platform (Platform) + frameworks and library system (Library) developed by Microsoft since 2001.

Do not put the word “Framework” in a confusing name. The .NET Framework actually covers many definitions.

First, the .NET Framework is a platform for executing applications. The program you write in any .NET programming language will translate into intermediate code (Intermediate Language) whether the program is in the form of a DLL library or executable exe itself.

When run, the IL code will be converted by a compiler called Just-in-Time (JIT) compiler into a machine instruction format and executed in a closed environment managed by .NET . Each of these enforcement fields is called the Common Language Runtime. The entire process of code – translating into IL code – translating into machine code – thus executing is called the toolchain of the .NET Framework.

Second, the .NET Framework creates many different types of framework programs that help you quickly add specific features to form a complete program. The .NET Framework has created the skeleton for many different types of applications, including web applications ( ASEP.NET ), desktop applications (such as Windows Forms, Windows Presentation Foundation), and service-oriented applications (Windows Communication Foundation). The .NET Framework provides a huge generic class library system that all frameworks on it can use.

In addition, each framework has its own class library system. This is the “library” role of the .NET Framework. In fact, the .NET Framework library system affects all supported languages. For example, the C # programming language has a syntax system, not its own data type system and library. All of this in C # comes from the .NET Framework. C # data types (such as int, bool, char, etc.) are aliases of data types from the .NET Framework (Int32, Boolean, Char, etc.).

Below is an illustration of the toolchain of the .NET Framework.

The .NET Core is a system independent of the .NET Framework. Once you understand the .NET Framework in this respect, you will need to visualize the same about .NET Core. The .NET Core is also a complete system that includes an intermediate code execution and application execution platform, frameworks for developing application types, and a support library system. The system of .NET Core is built completely new and independent of the .NET Framework.

Below is an illustration of the toolchaine of .NET Core.

The idea is that it has similarities with the .NET Framework. However, it is not related to the .NET Framework.

First, the execution environment of .NET Core is called CoreCLR. CoreCLR can run on many operating systems. CoreCLR can currently work on Windows, Linux and macOS. CoreCLR uses an intermediate compiler similar to the JIT compiler of the .NET Framework. Despite the same name, the .NET Core JIT compilter is not the .NET Framework JIT. .NET Core’s JIT can translate IL code into machine code of the 3 platforms it supports.

Another runtime difference is that CoreCLR and machine code are downloaded and activated by another process, dotnet.exe, while CLR is controlled by the Windows operating system. As a framework, .NET Core provides the framework for web application development ( ASP.NET Core), and desktop application development on windows (Windows Forms and WPF, from .NET Core 3.1). Regarding this feature, .NET Core and .NET Framework are almost the same.

As a library, .NET Core also provides class systems for the languages ​​it supports (currently C #, VB.NET and F #). However, it should be emphasized here that,

Firstly, the library systems of the .NET Core and .NET Framework are completely independent of each other. However, they are all files containing IL intermediate code, so they can theoretically use each other’s libraries. In fact, starting with .NET 2.0 you can reference libraries written in the .NET Framework. This makes the transition to .NET Core easier.

However, this reference is limited. Libraries built on the .NET Framework will not run on .NET Core if it depends on APIs not supported by .NET Core. Second, the .NET Core development team reuses intact the basic libraries of the .NET Framework. This makes it easy for programmers to switch from the .NET Framework to the .NET Core.

For example, both .NET Framework and .NET Core have Console class (System.Console), which have methods such as Write, WriteLine, Read, ReadLine. Therefore, if you are already proficient in C # (on the .NET Framework), you can continue to use it on .NET Core without learning anything more about programming languages. In general, if you have a library in the form of POCO (Plain Olde C # Object) written on the .NET Framework, you can easily refer to and use it in the .NET Core project.

.NET Standard – code sharing between platforms This is a name as well as a “category” that is confusing and confusing. As mentioned above, .NET Core and .NET Framework is quite difficult when sharing libraries. Microsoft offers a solution – .NET Standard.

The .NET Standard is a set of specifications for common APIs that all types of .NET must implement. If you understand and distinguish the concept of interfaces and implementations in C #, then .NET Standard can be considered as an interface type, and .NET Core or .NET Framework are different implementations.

.NET Standard allows you to write libraries but this library is quite special: its IL code doesn’t really contain code like libraries written on .NET Core or .NET Framework! When you use the library in a .NET Core project, the actual .NET Core classes are “merged”. Similarly, when you use it in a .NET Framework project, specific classes of the .NET Framework are included.

This type of technique is called type forwarding. As such, there are currently two specific implementations of .NET running on the desktop, the .NET Core and the .NET Framework. There are also Xamarin / Mono running on Android and iOS. .NET Standard acts as the interface to unify the libraries that specific implementations need to build. Thereby helping the above platforms share code with each other.

Share the news now

Source : Viblo