DEV Community

Admir Mujkic
Admir Mujkic

Posted on • Updated on

A Comprehensive Overview of New Features .NET 8

Image description

I am not a huge fun of writing such a blog but I am impressed with what Microsoft did with .NET 8. So, if you’re a developer, you’re probably curious about the latest features and changes in .NET 8. In this blog post, we’ll break down the new additions and improvements in a simplified manner.

Enhanced Building, Packing, and Serialization

Starting with .NET 8. The default mode for the ‘dotnet publish’ and ‘dotnet pack’ commands has changed from Debug to Release. However, if you prefer Debug mode you can set the parameter -p:PublishRelease to false. In addition, the System.Text.Json has made significant improvements since it replaced Newtonsoft.Json in recent versions.

Image description

Image description
The latest version of the source generator is now more efficient and dependable when used with ASP.NET Core in Native AOT apps. It also provides support for serializing types with required and init properties as well as allowing customization of how members that are not present in the JSON payload are handled.

Boosting Randomness and Performance

The rising popularity of AI programming has generated a call for a range of content. In response to this demand, .NET 8 introduces two fresh approaches, namely Random, GetItems and RandomNumberGenerator. These approaches empower developers to randomly select a specific quantity of items from a designated set.

Image description

Additionally, .NET 8 presents novel types that enhance the performance of applications. The FrozenDictionary and FrozenSet collection varieties are in the System.Collections.Frozen namespace prohibits alterations to both keys and values following their creation. Thereby resulting in faster read operations.

Image description

Creating the FrozenSet

Undoubtedly showcasing lookups and other similar operations is quite valuable. However, it should be noted that this is just one aspect of the entire process. Generating sets often require more resources compared to creating a basic List.

Image description

For example, this observation is consistent with the usual situation for FrozenSets, which are typically built once at the beginning and then accessed frequently. Usually through lookups. To better understand the creation of these objects using a pre existing array let’s take a look at some numerical examples.

Image description
You can check more: https://steven-giesel.com/blogPost/34e0fd95-0b3f-40f2-ba2a-36d1d4eb5601

Data Validation and Function Pointers Introspection Support

The DataAnnotations namespace in .NET 8 has new attributes specifically for validating data in cloud-native services. These new attributes are meant to validate data not entered by users, such as configuration options.

Image description
Function pointers, introduced in .NET 5, now support reflection in .NET 8. This means that using typeof or reflection on a function pointer will return a System.Type object instead of an IntPtr, providing access to function pointer metadata.

Native AOT and Code Generation Improvements

Native Ahead of Time (AOT) compilation, which was introduced in the latest version of .NET (version 7). Enables developers to create self-contained applications that do not rely on a separate runtime. In the forthcoming version of .NET (version 8). Native AOT support has been extended to include x64 and Arm64 architectures on macOS.

Additionally, Linux users can now benefit from native AOT applications that are up to 50% smaller in size compared to previous versions.

Moreover, .NET 8 offers several enhancements in code generation and just-in-time (JIT) compilation, such as improvements in JIT throughput. Performance enhancements for Arm64 architectures. And support for AVX 512 ISA extensions.

DevOps Improvements and Building .NET on Linux

There are several updates in .NET 8 that impact .NET container images. First, the default Linux distribution in the container images is now Debian 12. Additionally, the images now include a non-root user, which enhances security.

Another change is the default port, which has been modified from 80 to 8080. To facilitate port customization a new environment variable called ASPNETCORE_HTTP_PORTS has been introduced. This variable allows users to easily alter ports as needed.

Moreover, with .NET 8. it is now feasible to build .NET applications directly on Linux by utilizing dotnet/source build. This tool enables the creation of runtimes, tools, and SDKs for .NET development on Linux systems. For a streamlined building process within containers users can rely on dotnet buildtools/prereqs container images. These images incorporate all essential dependencies required for building purposes.

These updates provide developers with enhanced flexibility and efficiency when working with .NET container images while bolstering security measures and easing port customization.

Conclusion

In summary, the latest release of .NET 8 brings forth a plethora of new features and enhancements that not only optimize performance but also provide increased flexibility and improved support for developers.

These updates prove advantageous for both seasoned .NET developers and novices alike as they streamline and enhance the overall development process. Making it more efficient. It is my sincere hope that Microsoft will continue its commitment to improving this framework as we have come to expect from them.


P.S. If you believe I can help with something, don’t hesitate to contact me, and I will reach you as soon as possible. admir.m@penzle.com

Cheers! 👋


References:

What's new in .NET 8
Learn about the new .NET features introduced in .NET 8.
learn.microsoft.com

Steven Giesel
NET 7 was freshly released but Microsoft does not sleep. .NET 8 is already in the making and I want to showcase to you…
steven-giesel.com

Top comments (0)