Article
12 Dec
2023

Unveiling .NET 8: A Comprehensive Guide

Microsoft .NET 8.0 is packed with advanced software development tools and performance improvements that have set the developer community abuzz, and for good reason. The latest version of .NET offers a host of new features and enhancements set to help develop modern, cross-platform applications that are even more powerful and efficient.
Ivo Rodrigues
|
8
min read
unveiling-net-8-a-comprehensive-guide

Statistics show that 42.3% of developers worldwide use varying versions of .NET, highlighting that it remains the most utilised framework in the global software development community. Small and large-scale companies alike use .NET as their primary technology to power websites and applications, including well-known brands like Samsung, Microsoft, Intel, and JP Morgan Chase

This blog will take a deep dive into the new features and improvements to look forward to with the release of the latest  .NET version  — and everything you should know about .NET 8.0, including the release date and roadmap, key features, and performance improvements. 

.NET 8 Release Date and  Insights

.NET 8 is the most recent iteration of .NET. Microsoft has announced November 2023 as the official release date of .NET 8. 

Additionally, the latest version has also been designated a Long Term Support (LTS) release version, which means it will continue receiving updates, bug fixes and ongoing community support for at least three years after the initial release date. 

As for the preview releases, the support lifecycle is as follows:

New versions of .NET are released yearly every November to enable developers and businesses to plan their roadmaps. Per Microsoft’s Modern Lifecycle Policy, the extended guarantee of patches and free support is also meant to empower developers to adopt the newest versions as they are released. 

Odd-numbered releases, like .NET 7, are Standard Support Release (STS) versions that get free support and patches for a minimum of 18 months.

Image credit: .NET and .NET Core official support policy

.NET 8 Features 

.NET 8 comes with new features that enhance responsiveness and improve website performance to allow you to create a more seamless user experience for site visitors.

Let’s take a look at the key features of .NET 8:

C# 12 Code Improvements

C# 12 introduces notable enhancements to coding efficiency and clarity. Primary constructors can now be applied to any class or struct, offering a streamlined and elegant syntax. .NET 8 does away with boilerplate code for field and property initialization, plus the syntax for creating arrays, spans, and other collection types is now more concise and expressive. Additionally, lambda expressions benefit from new default parameter values, reducing the reliance on method overloading and null checks for optional arguments. The “using” alias directive also extends its utility, allowing aliasing for any type, not restricted to named types.

Artificial Intelligence Integration

.NET 8 simplifies the integration of AI capabilities through its features in the .NET SDK and seamless compatibility with various tools. Notably, improvements in the System.Numerics library cater to Generative AI workloads, including the integration of Tensor Primitives. 

In response to the growing prevalence of AI-enabled applications, Microsoft has collaborated with key partners like Azure Cognitive Search, Azure OpenAI, Qdrant, Milvus, and Microsoft Teams. This collaborative effort ensures that .NET developers can easily access a diverse range of AI models, platforms, and services through their respective SDKs.

Moreover, the open-source Semantic Kernel SDK streamlines the incorporation of these AI components into both new and existing applications, facilitating innovative user experiences. To aid developers in getting started, Microsoft has also released a collection of samples and reference templates showcasing various patterns and practices. Examples include Customer Chatbot, Developing Apps using Azure AI services, and Retrieval Augmented Generation.

Blazor in .NET 8

In .NET 8, Blazor offers a comprehensive solution for web UI by seamlessly integrating server and client capabilities. This full-stack web UI approach allows developers to address all their web UI needs effectively. With a focus on optimising page load time, scalability, and enhancing the user experience, Blazor now enables the concurrent use of Blazor Server and Blazor WebAssembly within the same application. This dynamic runtime behaviour automatically transitions users from server to client as needed.

The performance boost is notable, particularly for .NET code running on WebAssembly, thanks to the introduction of a "Jiterpreter"-based runtime and new built-in components. In terms of authentication, authorization, and identity management, Blazor in .NET 8 also takes it a step further by supporting the generation of a complete Blazor-based Identity UI, contributing to an enhanced overall experience. 

.NET 8 Container Enhancements

Easily and securely package your applications using containers with .NET's improved functionality. Each .NET image now comes with a non-root user by default, offering enhanced container security through a straightforward setup. With the updated .NET SDK tooling, you can publish container images without the need for a Dockerfile, ensuring they're non-root as well. 

You can also speed up the deployment of your containerized apps thanks to smaller .NET base images, including experimental variants for exceptionally compact application sizes using native AOT. Increase security further by opting for the new Chiseled Ubuntu image variants to reduce your application's vulnerability. Whether you’re using Dockerfiles or SDK tooling, building applications and container images for any architecture is now straightforward.

Garbage Collection Improvements

In .NET 8, a newly introduced capability dynamically adjusts memory limits, which is particularly valuable in fluctuating demand scenarios, such as those encountered in cloud services. Scaling up and down in response to demand variations is crucial for cost-effectiveness. 

When a service identifies a reduction in demand, it can optimise resource consumption by lowering its memory limit. In the past, this adjustment could fail as the garbage collector (GC) remained unaware of the change, potentially allocating more memory than the updated limit. Now, with the introduction of the RefreshMemoryLimit() API, you can seamlessly update the GC with the new memory limit.

However, there are certain limitations to consider. On 32-bit platforms (e.g., Windows x86 and Linux ARM), establishing a new heap hard limit in .NET is not possible if one doesn't already exist. Also, the API may return a non-zero status code, indicating a failed refresh. This might occur if the scale-down is overly aggressive, leaving no room for the GC to adapt. In such cases, it is recommended to call GC.Collect(2, GCCollectionMode.Aggressive) to reduce current memory usage before attempting the adjustment again.

Lastly, scaling up the memory limit beyond what the GC believes the process can handle during startup might succeed with the RefreshMemoryLimit call, but the process won't be able to utilise more memory than perceived by the GC as the limit.

JSON Upgrade

.NET 8 has also improved how JSON serialisation and deserialization are managed, with added support for numeric types, including Half Struct. The system uses an IEEE float16 type, making it useful for data delivery to machine learning models. 

Overall, Microsoft has also improved its JSON tooling. It’s now easier to write specific nodes to a JSON document. Plus, .NET now manages JSON content better alongside other features. Overall, the updates ensure JSON document integrity and make .NET a better platform for cloud-native development. 

.NET 8 introduces enhancements to the System.Text.Json source generator, focusing on aligning the Native AOT experience with the reflection-based serializer. Key improvements include:

  • Support for Serialising Types with Required and Init Properties: The source generator now accommodates the serialisation of types featuring required and init properties, aligning with capabilities already present in reflection-based serialisation.
  • Improved Formatting of Source-Generated Code: Enhancements have been made to the formatting of code generated by the source generator, contributing to a more refined and readable output.
  • JsonSourceGenerationOptionsAttribute Feature Parity with JsonSerializerOptions: Achieving feature parity with JsonSerializerOptions, the JsonSourceGenerationOptionsAttribute now offers additional options. For more detailed information, refer to the Microsoft documentation.
  • Additional Diagnostics: The update introduces additional diagnostics, including SYSLIB1034 and SYSLIB1039, enhancing the tooling for better error detection and resolution.
  • Exclusion of Ignored or Inaccessible Property Types: Types associated with ignored or inaccessible properties are now excluded, streamlining the serialisation process.
  • Support for Nesting JsonSerializerContext Declarations: JsonSerializerContext declarations can now be nested within arbitrary type kinds, providing more flexibility in organising and structuring code.
  • Support for Compiler-Generated or Unspeaking Types in Weakly Typed Source Generation: Support has been extended to compiler-generated or unspeakable types in scenarios involving weakly typed source generation. Since these types cannot be explicitly specified by the source generator, System.Text.Json dynamically performs nearest-ancestor resolution at runtime. This resolution determines the most appropriate supertype for serialisation.

Just-in-Time Compiler Enhancements

.NET 8 includes improvements to code generation and just-in-time (JIT) compilation with JIT throughput improvements, SIMD improvements, and Arm64 performance improvements, among others. Also, JIT/NativeAOT in .NET 8 now possesses the capability to automatically unroll and vectorize certain memory operations utilising SIMD, including comparison, copying, and zeroing. This optimisation is applied when the compiler can ascertain their sizes during compile time.

Furthermore, dynamic Profile-Guided Optimization (PGO) has undergone enhancements and is now activated by default. There's no longer a need for a runtime configuration option to enable it. Dynamic PGO collaborates seamlessly with tiered compilation, refining code optimization through additional instrumentation introduced during tier 0.

On average, the implementation of dynamic PGO results in a performance increase of approximately 15%. In an extensive benchmark suite comprising around 4600 tests, 23% exhibited performance improvements of 20% or more.

Methods for Randomness

.NET 8 also supports new tools that provide randomness or tools that allow you to use randomness as a selector within your code. There’s no need to run calculations. You can now randomly select items from an input set to place in an output array.

You can also randomly shuffle items in a dataset, which can be very useful when working with machine learning models, such as in differentiating training and test data each time you build a new model.

Cryptography

.NET 8 also introduces support for SHA-3 hashing primitives, available on Linux with OpenSSL 1.1.1 or later and Windows 11 Build 25324 or later. APIs that originally offered SHA-2 functionalities now include their SHA-3 counterparts. This includes:

  • SHA3_256, SHA3_384, and SHA3_512 for hashing; 
  • HMACSHA3_256, HMACSHA3_384, and HMACSHA3_512 for HMAC;
  • HashAlgorithmName.SHA3_256, HashAlgorithmName.SHA3_384, and HashAlgorithmName.SHA3_512 for configurable hashing algorithms; 
  • RSAEncryptionPadding.OaepSHA3_256, RSAEncryptionPadding.OaepSHA3_384, and RSAEncryptionPadding.OaepSHA3_512 for RSA OAEP encryption

It's important to note that current SHA-3 support primarily targets cryptographic primitives, with expectations that higher-level constructions and protocols, such as X.509 certificates, SignedXml, and COSE, may not fully adopt SHA-3 initially.

Next-Gen Silicon and Time Abstraction

Some .NET 8 features are also specific to silicon advances, like vector acceleration features built on Intel AVX-512. As such, .NET 8 allows developers to write error-handling code via a flag to test for AVX support. 

Specifically, .NET 8 includes support for the following key features of AVX-512:

  • 512-bit vector operations
  • Additional 16 SIMD registers
  • Additional instructions available for 128-bit, 256-bit, and 512-bit vectors

There’s also a new time abstraction feature that allows developers to create a local time provider and then set it up to operate in different time zones outside one’s current local time. This allows for programmatic control of time zones and makes creating mock times for tests and spotting bugs much easier. 

Software engineer enjoying .NET 8

.NET 8 Performance Improvements

In addition to the features we discussed above, there are also several key performance improvements at the core of .NET 8. From the looks of it, this version is substantially  heavy on providing significant improvements to optimise runtime and reduce startup times. 

Runtime Optimisation

.NET 8 applications will benefit from faster execution and greater efficiency with a significantly optimised .NET runtime, reduced resource consumption, and enhanced overall performance.

Reduced Startup Times

Reduced application startup times is another key improvement, allowing for even faster application launches and an overall better, more optimised user experience.

Optimised Resource Management

.NET 8 applications are also set to become even more efficient in using memory and system resources with .NET 8’s optimised resource allocation and management.

Improved Parallelism

Significant improvements in parallelism also enable .NET 8 developers to write scalable, efficient code that utilises modern and multi-core architectures. 

.NET 8 Interoperability

.NET 8 is also capable of interoperating with other languages and technologies. Interoperability provides opportunities to reuse existing code and facilitates better integration with legacy systems — opening a new world of opportunities for seamless connections between new and old technologies. 

Seamless Integration

.NET 8 allows developers to incorporate existing C/C++ libraries and code into .NET projects, allowing teams to leverage existing code heritage, saving time and resources. 

Blazor and Xamarin Integration Updates

Integrations with Blazor and Xamarin have also been updated, with Blazor now deeply integrated into .NET 8. This enables developers to create advanced applications with reusable components. Xamarin now also offers cross-platform mobile app development. 

Improved Legacy Code Handling

.NET 8 has also improved the way the framework handles legacy code, which can be very helpful within organisations looking to leverage existing legacy applications that need to be updated, maintained, or modernised. 

.NET MAUI (formerly Xamarin.Forms)

.NET MAUI offers a unified project system and a single codebase, enabling the development of applications for iOS, Android, WinUI, and Mac Catalyst. The experimental Native AOT also now extends its support to targeting iOS-like platforms. 

Additionally, a newly introduced Visual Studio Code extension tailored for .NET MAUI equips developers with essential tools for creating cross-platform .NET mobile and desktop applications. 

Expanded support for Xcode 15 and Android API 34 also facilitates targeting the latest iOS and Android versions. Noteworthy improvements have also been implemented in performance, UI elements, controls, and platform-specific behaviours. Enhancements include refined desktop interaction incorporating improved click handling, keyboard listeners, and more.

Conclusion 

.NET 8 is a supercharged release that provides incredible value to the development ecosystem, with several performance improvements, development tools, support, and interoperability updates. True to its standing as the most utilised development framework, .NET 8 provides more expansive opportunities for developers to build web applications, desktop software, mobile applications, cloud services, or games.

The efforts to improve both cloud integration and interoperability with legacy systems and code also allow developers to harness the full potential of emerging technologies as well as legacy systems that have provided value in the past.

Overall, these improvements make .NET 8 ideal for developing high-performance applications with accelerated runtimes and reduced operational costs. Most importantly, the updates seek to improve user experience and provide the end user with the best and most streamlined experience with .NET 8-based apps and services, regardless of device or architecture.

Learn More at The Virtual Forge

Check out our blog at The Virtual Forge website for more interesting reads about development, AI, data, and all things tech. We also offer Cloud, Data, DevOps, and Software Development services

At The Virtual Forge, we build data-rich, intelligent platforms to help clients solve unique business problems. We use a collaborative and transparent approach to understand your needs and use our tools and expertise to innovate and create solutions that will help you excel in your field.

Feel free to connect with us if you need help with .NET 8-based design, development, testing, or support—we’d love to hear from you.

FAQS 

When is the .NET 8 release date?

According to Microsoft, the official release date for .NET 8 was November 14th 2023.

Is .NET 8 LTS or STS?

.NET 8 is an LTS release and is set to receive free support and patches for a minimum of three years post-launch.

How can I install the .NET 8 SDK?

To install the SDK, you have to visit the .NET website and download the installer for your specific operating system. 

Does .NET 8 have performance improvements for apps?

Yes, .NET 8 has several performance improvements that can significantly enhance the efficiency, speed, performance, and overall user experience of applications built with .NET 8.

Our Most Recent Blog Posts

Discover our latest thoughts, tendencies, and breakthroughs in the realm of software development and data.

Swipe to View More

Get In Touch

Have a project in mind? No need to be shy, drop us a note and tell us how we can help realise your vision.

Please fill out this field.
Please fill out this field.
Please fill out this field.
Please fill out this field.
Send Message

Thank you.

We've received your message and we'll get back to you as soon as possible.
Sorry, something went wrong while sending the form.
Please try again.