June 22, 2022

Differences Between .NET Core 3.1 and .NET Core 6

Differences Between .NET Core 3.1 and .NET Core 6

IT Tips & Insights: A Softensity Software Engineer details the changes introduced with .NET Core 6, and how to choose the best version for your project.

By Mario Leiton, Software Engineer

Whenever most of us see a new version of a tool we use in our daily work, we get curious about its new features and other changes. It’s crucial to stay up to date with the languages we work with. As developers, we need to continuously master skills in the top technologies so that we keep up with the advancements and are not left behind. That said, having knowledge in the not-so-recent languages and frameworks is equally important so we can support company projects and applications that are already built.

In this post, we’ll look at the recent framework released for the .NET Family, .NET 6.0 — and compare it with .NET Core 3.1. Hopefully, this will help you decide which technology is best for your projects going forward. To begin with, let’s revisit some background on .NET before the arrival of the supercharged .NET 6.

Legacy .NET Technology

In the past, the .NET framework only worked on Windows devices and offered no flexibility for .NET developers to work on other operating systems. When .NET Core arrived, it provided a standard base library that was usable across multiple platforms, like Windows, Linux, macOS, and mobile devices through Xamarin.

There are four major components of the .NET architecture:

  • Common language specification (CLS) defines how objects are implemented, in a way that they can work everywhere .NET works. CLS is a subset of the Common Type System (CTS), which sets common ways to describe all types.
  • Framework class library (FCL) is a standard library that collects reusable classes, interfaces, and value types.
  • Common language runtime (CLR) is the virtual machine that runs the framework and manages the execution of .NET programs.
  • Visual Studio is the IDE, provided also by Microsoft, to create entire projects and standalone applications, interactive websites, and web services.

Before we talk about the two versions from the different sides of .NET (Core and Framework), we will talk about the differences between .NET Core and .NET Framework.

Differences Between .NET Core and .NET Framework

Microsoft maintains both runtimes for building applications with .NET while sharing many of the same APIs. This shared API is called the .NET Standard.

Developers tend to use the .NET Framework to create Windows desktop and server-based applications. This includes ASP.NET web applications. Then we have the .NET Core scenario where developers use this tool to create server applications that run not only on Windows but also on Linux and Mac.

When To Consider Using .NET Core

If you need your project to be cross-platform:
You will likely be running your application on platforms like Windows but also in Linux and macOS. With the new code editor Visual Studio Code, you can work and create entire projects in the Apple environment and be flexible. The same applies if you are a Linux user.

Using Microservices:
With a shape of service-oriented architecture, this model works with software composed of small, modular business services. Each service can run a unique process, and be deployed independently, which increases scalability and can be created in different applications.

When Docker is a must:
Containers and microservices architecture are used together most of the time. Because of its lightweight and modular nature, .NET Core works very well with containers.

You need to have high-performance and scalable systems:  
This becomes important when running lots of microservices. In this case, a lower number of servers and virtual machines is the best scenario. The efficiency and scalability gained should be equal to a better user experience in addition to cost savings.

You are running multiple .NET versions side-by-side:
This allows multiple services to be executed on the same server with different versions of .NET, thanks to the flexibility of .NET Core.

You need an offering for command-line interface (CLI) control:
Not all developers want to work only on Interface-driven environments. Some like to work from the command line for performance purposes or pure automation when deploying changes and whatnot.

When Not To Use .NET Core

  • Windows Forms and WPF applications are not supported in .NET Core — in case you have legacy applications that still run in this type of technology.
  •  If you need to create a WCF service, .NET Core does not currently support WCF. However, you can work around this by creating a REST API with ASP.NET Core MVC.
  • Missing third-party library support.

Now that we’ve reviewed some of the pros and cons of .NET Core, let’s do the same for .NET Framework.

When To Consider Using .NET Framework

-Since it is distributed with the Windows OS, it is used to build Windows desktop and large-scale enterprise applications.

-It is already being used, and instead of migrating, extend the application. For instance, developers can write a new web service in ASP.NET Core.

-You are using libraries that are not available on .NET Core.

When Not To Use .NET Framework (Before the 6th Version)

  • Multiple OS Platforms are required
  • High performance and scalability are needed
  •  .NET Core works just fine
  • Open-source compatibility is required

Now that we’ve looked at .NET Framework and .NET Core, let’s see what .NET 6 looks like and how this new version integrates the best of both worlds as it is the fastest framework for developers.

What’s New in .NET 6?

Since .NET Framework 5 came out, there were plans to unify .NET Core and .NET Framework 5 features. With .NET 6, this has finally been accomplished. .NET 6 unifies the SDK, base libraries, and runtime across mobile, desktop, and other newer technology fields like IoT and cloud applications. The .NET 6 ecosystem offers the following:

Simplified development:
A new ‘starting up’ for new applications that are agile and flexible. The technology also offers more segregation on the type of structures you have on various working templates out of the box. This includes the new features of the language C# 10, and with that, the reduction of code you need to write to get your apps up and running. It comes with minimal APIs to make it easy to quickly write smaller and faster microservices.

Better performance:
.NET 6 is the fastest full-stack web framework, which lowers computing costs if you are running in the cloud.

Great productivity with the new Microsoft IDE version:
.NET 6 and Visual Studio 2022 provide the features of hot reload, new git tooling, intelligent code editing, robust diagnostics and testing tools, and better team collaboration.

Other changes in .NET 6 include:

  • The System.IO.FileStream type has been rewritten for .NET 6 to provide better performance and reliability on Windows. Now, FileStream never blocks when created for asynchronous I/O on Windows.
  • Profile-guided optimization (PGO) is where the JIT compiler generates optimized code in terms of the types and code paths that are most frequently used. .NET 6 introduces dynamic PGO.
  • .NET 6 introduces Crossgen2, the successor to Crossgen, which has been removed. Crossgen and Crossgen2 are tools that provide ahead-of-time (AOT) compilation to improve the startup time of an app. Crossgen2 is written in C# instead of C++ and can perform analysis and optimization that weren’t possible with the previous version.
  • The .NET 6 release includes support for macOS Arm64 and Windows Arm64 operating systems, for both native Arm64 execution and x64 emulation.

These are a few features and improvements that .NET 6.0 offers developers. Read more on this blog from the Microsoft Developer community

Choosing the Best Version of .NET

When it comes to choosing the right .NET version, consider the business requirements and, of course, what’s already written and what can be refactored. It’s also important to consider the lifecycle that Microsoft will give to the versions of .NET Core or .NET Framework.

Upgrading from .NET Core 3.1 to .NET 6+ requires much less effort than porting from .NET Framework to .NET Core. For this reason, many developers may choose to upgrade to .NET Core 3.1 first as an incremental step, and then further upgrade to .NET 6 once the upgrade to .NET Core 3.1 has succeeded.

For new projects, it’s recommended to go with the newest and fastest version, .NET 6, since it is the most flexible and performance-oriented version released so far and will work on every scenario and requirement.

Don’t worry about the learning curve, as it’s more about understanding the new architecture and the impact of the changes described above. Of course, developers should be familiar with the rest of the .NET environment.

About

Hi, my name is Mario and I’m a software engineer that works with Microsoft Azure. I also have experience with AWS and GCP. C# and .NET are where I develop my skills, along with DevOps technologies. I have also worked as a Web Developer with NodeJs and I want to further sharpen my Cloud skills and master new technologies, pointing to productivity for developers and end-users.

Join Softensity’s Team

BACK TO MAIN PAGE

Let’s Talk