.NET core vs ASP.NET core: Differentiate .NET Framework, .NET Core and Mono

One of the strengths of .NET ecosystem is the very good support of tools such as Visual Studio. However, this is also a weakness because it prevents many programmers from interacting with the basic theories of the Framework. In this article we will find out how .NET is different, and how the .NET Framework, .NET core, and Mono platforms are different.

WHY SHOULD NEED THE BASIC THEORY?

I have met many people who have worked with .NET for a long time but are still confused about the concepts and definitions of the Framework. This is very dangerous because it causes a misunderstanding of the platform, leading to the production of low quality software. So knowing your framework is the responsibility of any developer?

WHEN SPEAKING ABOUT .NET, NORMAL PEOPLE ATTENTION 3 COMPONENTS:

Runtime (operating environment)

Libraries (library)

Toolings (development tools).

We will slowly learn the function of each component later in the article.

First of all, we need to understand how .NET can run the C # (or VB, F #) code you write. To understand this, we need to understand the code compilation process in .NET

dot_net_application_compilation-707676

In the image above, the 'Compile time' section is the 'Build', and 'Runtime' process is the running process (ie from the time you start your application).

Basically, when you execute the build command (in Visual Studio, or 'dotnet build' with the command line), your source code is transformed into an intermediate language called MSIL (Microsoft Intermediate Language). When the application is launched, the Runtime component or the unique name in .NET is CLR (common language runtime) that will translate MSIL code into machine code (Native code) so that the computer can execute. This process is called JIT (just-in-time) compilation. The way of compiling and operating .NET is quite similar to Java.

To better understand JIT, let's try an experiment. Copy the following code into the Program.cs file in your project:

We will proceed to call the same function twice and measure how much time the two calls run. (10000 ticks = 1 ms). Proceed to 'dotnet run' and see the result.

jit_exp1

You can see that the first run is much longer than the second. Why so? That's because when DoSomeCalculation () is first called, CLR compiles (JIT) this function into machine language. At the next run, DoSomeCalculation () does not need 'JIT' again (because 'JIT' has been completed), so execution time is much faster. (This also explains why in some software, the time to perform a certain function for the first time is often slower than the next time).

Why is an intermediate language needed? The intermediate language in .NET is quite close to the machine code but does not contain specific CPU information. Helping your intermediate code can work on a variety of CPUs (64bit, 32bit), as well as many different types of architectures (ARM, Intel …)

In fact, some languages ​​(Javascript, Python …) do not use intermediate language: Source will be translated directly into the machine code at 'Runtime'. The advantage of this is that the build process is simplified, but the performance will be limited.

In addition to compiling, the operating environment (Runtime) has uses such as:

– Automatic memory management. When working with high-level languages ​​like C # or Java, you don't need to free memory by calling free () as when working with C / C ++. CLR includes a garbage removal tool (Garbage collector -GC) that will automatically release unused memory parts.

– Strong typings: CLR manages information about the types of data you use. This helps you to distinguish the information formats of each different variable (class, structure …).

What about Libraries and Toolings?

When you work with .NET, your code will interact with many different classes. For example: The most used class in .NET is System.String. All of these classes are defined in the basic library system of .NET that is commonly referred to as BCL (Base class libraries).

The source code of the BS, contrary to everyone's thinking, is open source. You can access this source at sourceof.net .

The toolsings of .NET including compiler and Visual Studio .NET use Microsoft's build system called MSBuild. For the new .NET core platform, we also have the command line tool (dotnet cli).

Differentiate .NET Framework, .NET Core, and Mono

Why need to distinguish them ? Because you need to understand what you are doing. For example, if you intend to run a Web server on Linux, you should absolutely not use Mono.

For those who are new to .NET or even some who have worked with .NET for years, names like the .NET Framework, Mono or most recently .NET core are still causing misunderstandings. However, the above basic concepts of .NET help us distinguish quite easily. Basically, the .NET Framework, .NET core and Mono are three different .NET versions (meaning that each version has Runtime, Libraries and Toolings separately).

So why are there 3 different versions?

– .NET Framework has been officially launched by Microsoft since 2002. .NET Framework only works on Windows. Application platforms such as WPF, Winforms, ASP.NET (1-4 ) operate on the .NET Framework.

– Mono is the community version to bring .NET to platforms other than Windows. Mono was developed primarily to build applications with a user interface and is widely used: Unity Game, Xamarin …

– Until 2013, Microsoft oriented multi-platform and developed .NET core. .NET core is currently used in Universal Windows platform applications and ASP.NET Core.

aspnetcoretoday

SO I SHOULD USE .NET FRAMEWORK, .NET CORE, OR MONO?

That depends on the application you intend to develop. For Windows desktop applications, the .NET Framework will be your choice. If you develop games based on Unity, or mobile apps with Xamarin, you'll use Mono. For Web servers, you can use both .NET Framework and .NET Core.

Absolutely not use Mono to operate the web server. Mono's garbage cleaner is not designed to work with the webserver and will cause rapid overloading.

So choose .NET Framework or .NET Core for web servers? .NET Core runs multi-platform and has higher performance. The only downside is that the number of support libraries is still limited. The .NET Framework has a larger ecosystem with more support libraries.

This series will use .NET Core. Should we look to the future?

ITZone via goatysite

Share the news now