The main difference between .NET Core 3.1 and newer versions of .NET Core (such as .NET 5 and .NET 6) is that .NET Core 3.1 was the last version of .NET Core, while the newer versions have been rebranded as .NET, without the “Core” designation.
we named this new release .NET 5 instead of .NET Core 4 for two reason:
- To prevent confusion with the .NET Framework 4.x, we intentionally omitted version numbers 4.x. Furthermore, we have removed the term “Core” from the name to highlight that this implementation of .NET is now the primary one
- With .NET 5, we have expanded our support to encompass more application types and platforms than what was available in either .NET Core or .NET Framework.
However, in terms of features and functionality, there are several differences between .NET Core 3.1 and the newer versions of .NET:
- C# updates
- F# updates
- Visual Basic updates
- System.Text.Json new features
- Single file apps
- App trimming
- Windows Arm64 and Arm64 intrinsic
- Tooling support for dump debugging
- The runtime libraries are 80% annotated for nullable reference types
- Performance improvements:
1. Garbage Collection (GC)
2. System.Text.Json
3. System.Text.RegularExpressions
4. Async ValueTask pooling
5. Container size optimizations
Now we trying to understand what is new in each step that is given above
- C# updates :
a. Top-level statements: You can now write code without needing to wrap it in a class or a method. This feature can simplify small programs and make them more concise.
b. Improved pattern matching: Pattern matching has been improved with the introduction of the “and” and “or” operators, as well as the ability to use patterns in switch expressions.
c. Records: Records are a new reference type that allow you to create immutable objects with value semantics. Records can simplify code and improve performance in certain scenarios.
d. Target-typed new expressions: You can now omit the type name in a new expression if the type can be inferred from the context.
e. Covariant returns: You can now override a method with a return type that is more derived than the return type of the overridden method. This can make it easier to work with interfaces and base classes.
f. Init-only properties: You can now declare properties that can only be set during object initialization. This can help enforce immutability and make code more readable.
g. Performance improvements: C# 9 includes several performance improvements, such as better JIT performance, faster string handling, and more efficient collection initialization. - F# update : because I am using c# in .net application but you still want to what is change in F# you can refer this link https://learn.microsoft.com/en-us/dotnet/core/whats-new/dotnet-5#f-updates
- Visual Basic updates : https://learn.microsoft.com/en-us/dotnet/core/whats-new/dotnet-5#visual-basic-updates
- System.Text.Json new features : System.Text.Json is a JSON serialization and deserialization library that was introduced in .NET Core 3.0 and has been further improved in .NET 5. Here are some of the new features and improvements in System.Text.Json in .NET 5:
1. Support for a wider range of types: System.Text.Json now supports serialization and deserialization of more types, including enums, nullable value types, and types with read-only properties.
2. Improved performance: The library has been optimized for better performance, with faster serialization and deserialization speeds than in previous versions.
3. More customization options: You can now customize how objects are serialized and deserialized, such as by renaming properties, ignoring properties, or applying custom converters.
4. Support for reference handling: System.Text.Json now supports reference handling, which can help reduce the size of JSON payloads and improve performance in certain scenarios.
5. Improved error handling: The library now provides more detailed error messages when serialization or deserialization fails, making it easier to debug issues.
6. Support for UTF-8 and UTF-16 encoding: You can now choose to serialize JSON data in either UTF-8 or UTF-16 encoding, depending on your needs. - Single file apps : Single file apps were introduced in .NET Core 3.0 and have been further improved in .NET 5. Here are some of the new features and improvements in single file apps in .NET 5:
* Cross-platform support: Single file apps can now be created and run on Windows, Linux, and macOS, making them even more versatile.
* Improved performance: The startup time for single file apps has been improved, with faster app launch times than in previous versions.
* Support for native libraries: You can now package native libraries alongside your .NET assemblies in a single file app, allowing you to create self-contained apps that can be run without installing any dependencies on the target machine.
* More deployment options: You can deploy single file apps using a variety of methods, including HTTP download, network share, or USB drive.
* Reduced file size: The size of single file apps has been reduced, making it easier to distribute and deploy them.
* Improved debugging experience: Single file apps can now be debugged in Visual Studio and other debugging tools, making it easier to diagnose issues during development. - App trimming: Application trimming is a feature in .NET that reduces the size of an application by removing unused code during the build process. This feature was introduced in .NET Core 3.0 and has been further improved in .NET 5. Here are some of the new features and improvements in application trimming in .NET 5:
1. Improved analysis: The analysis process has been improved to better understand how your application is being used, and to identify code that can be safely removed.
2. Faster build times: The analysis and trimming process has been optimized for faster build times, which can help improve developer productivity.
3. More precise trimming: The trimming process now takes into account the specific runtime environment in which the application will run, allowing for more precise trimming that does not remove code that is actually used.
4. Better support for reflection: Reflection is now better supported in trimmed applications, allowing for more accurate analysis of the code that is actually used at runtime.
5. Improved compatibility: The trimming process has been improved to ensure compatibility with third-party libraries and frameworks, reducing the risk of breaking changes when applications are trimmed.
6. Support for conditional trimming: You can now specify which parts of your application should be trimmed based on conditions such as the target platform or runtime environment.
Rest of the point is general and you can try to read this with following url
https://learn.microsoft.com/en-us/dotnet/core/whats-new/dotnet-5
hope you like this