Do .NET 8 & C# 12 Signal Microsoft Coming Back To Form In The Game?

Jerry Wallis
11 min read
Microsoft's release of .NET 8, the latest long-term support version, showcases improvements in performance, introducing features like .NET Aspire for cloud-native applications, containerization enhancements, seamless artificial intelligence integration, and language improvements in C# 12.
.net 8 launch for microsoft

Last week, Microsoft announced the release of .NET 8, the latest Long-Term Support (LTS) version of one of the world’s premier development platforms. 

.NET 8 introduces a multitude of enhancements in performance, stability, and security, along with improvements to platforms and tools that boost developer productivity and accelerate innovation. Discover the latest features and developments in .NET 8 and C#12 in this article.

We’ll also review the significance of this latest update and discuss what it means for Microsoft’s position in the landscape of development frameworks.

What Does This New Release Include?

So, first of all, let’s go over the details; what exactly is happening? Well, .NET, C# and Visual Studio were all updated with new versions in the latest release on November 14th 2023, from Microsoft. All of this happened in .NET Conf 2023, an online conference spanning a few days. 

In this latest release, .NET transforms the way intelligent, cloud-native applications and high-traffic services are constructed to scale on demand. Whether deploying on Linux or Windows, using containers, or opting for a cloud app model, .NET 8 will simplify the development of such applications. 

It includes proven libraries utilised by high-scale services at Microsoft, addressing fundamental challenges related to observability, resiliency, scalability, manageability, and more. With this new update, here’s a brief rundown of what you can expect:

  • Incorporate Large Language Models (LLMs) like OpenAI’s GPT directly into your .NET application.
  • Manage all your web UI requirements with Blazor, utilising a single powerful component model. 
  • Deploy your mobile applications to the latest versions of iOS and Android with .NET MAUI. 
  • Explore new language enhancements in C# 12 that make your code more concise and expressive. Let’s delve into the notable features of .NET 8:

Unparalleled Performance

So, let’s start with the big one, and this is a really important improvement to note. In essence, with this new update to .NET, every time you update to a new version of .NET 8, your existing code can get faster. This is not to say that every line of your existing codebase will perform better, but there are underlying methodologies that the .NET 8 framework runs the application that will make your overall codebase faster as a result. All in all, this is to say that just by upgrading to .NET 8, you should expect a noticeable performance improvement.

But how does this exactly happen? Microsoft has dubbed this latest instalment of .NET as its “fastest version to date”. And there are multiple reasons for that. So, let’s go over them in detail.

First up, the introduction of Dynamic Profile-Guided Optimisation (PGO) as the default code generator enhances app performance by up to 20%. Support for the AVX-512 instruction set enables parallel operations on 512-bit vectors, significantly boosting data processing speed. 

Next up, Primitive types now implement a new formattable and parsable interface, allowing direct formatting and parsing as UTF-8 without transcoding overhead.

To back this claim up, performance gains in the latest TechEmpower benchmarks reveal an 18% improvement in the JSON API scenario, reaching nearly one million requests per second with ASP.NET Core Minimal APIs. The Fortunes scenario, representing a real-world workload, shows a 24% improvement, surpassing 300K requests per second with ASP.NET Core.

.NET Aspire

Within Microsoft’s .NET 8 release, another standout announcement during the launch was the introduction of .NET Aspire. This is a fresh, cloud-native development stack designed to construct robust, observable, and configurable cloud-native applications within the dotnet framework.

.NET Aspire offers an opinionated stack for building observable, production-ready cloud-native applications. It includes curated components enhanced for the cloud-native environment, incorporating telemetry, resilience, configuration, and health checks by default. The stack simplifies the discovery, acquisition, and configuration of essential dependencies for cloud-native applications from day 1 to day 100.

.NET 8 Container Enhancements

Containers are another component of the .NET system that has gone through a major upgrade. Containers in .NET are lightweight, portable units that package applications and their dependencies, ensuring consistent and reliable execution across diverse environments. Leveraging technologies like Docker, containers offer advantages such as portability, isolation, efficiency, and scalability. 

Containers enable streamlined DevOps practices, supporting continuous integration and deployment, and have become essential for building resilient and easily scalable applications in the .NET ecosystem. So, as you can see, they are quite important in the overall .NET environment.

With this latest release, you can now more easily and securely package your applications with containers using .NET 8 because each .NET image now includes a non-root user for enhanced container security with a one-line configuration. The .NET SDK tooling publishes non-root container images without a Dockerfile by default. 

All this means you can now enjoy faster deployment of containerised apps with smaller .NET base images, including experimental variants for truly minimal application sizes. Plus, you have the option to opt for additional security hardening with new Chiselled Ubuntu image variants.

Native AoT

Compile your .NET apps into native code, reducing memory usage and enabling instant startup without waiting for the JIT compiler. AOT apps deploy only the code needed for your application, allowing them to run in restricted environments where a JIT compiler isn’t allowed.

Incorporate Artificial Intelligence Effortlessly

Another major enhancement comes in the fact that AI integration with .NET is now more seamless than ever before. Integrate AI easily into your .NET applications with features in the .NET 8 SDK. The Numerics library improves compatibility with Generative AI workloads, including the integration of Tensor Primitives. 

Collaborations with other AI application partners such as Azure OpenAI, Azure Cognitive Search, Milvus, Qdrant, and Microsoft Teams ensure easy access to various AI models, services, and platforms through their respective SDKs. Lastly, the open-source Semantic Kernel SDK simplifies the integration of AI components into new and existing applications.

Blazor

Here’s another big addition to the .NET system. Build full-stack web applications with Blazor in .NET 8. Blazor is a novel client-side UI framework developed by the ASP.NET team and stands out for its distinctive approach to creating rich web UI experiences. Unlike many frameworks that rely on JavaScript, Blazor empowers developers to craft dynamic web UIs using a combination of HTML, CSS, and C#. 

Its uniqueness lies in the separation of the UI change calculation (app/component model) from the application of these changes (renderer). This sets Blazor apart from counterparts like Angular or ReactJS/React Native, which are limited to web-based UIs. 

Thanks to different renderers, Blazor not only creates web UIs but also extends its capabilities to native mobile UIs. Although this requires components to be authored differently for web and mobile renderers, the underlying programming model remains consistent. This means that once developers grasp the model, they can seamlessly create UIs using any renderer.

The new .NET 8 release brings optimisations for page load time, scalability, and user experience, all of which benefit key components of Blazor. For instance, Blazor Server and Blazor WebAssembly can be used in the same app, dynamically shifting users between server and client at runtime. Blazor now supports generating a full Blazor-based Identity UI, enhancing authentication, authorisation, and identity management.

Improvements To .NET MAUI

Finally, the latest update also makes improvements to .NET MAUI. But again, before we review those, let’s briefly overview .NET MAUI. 

What Is .NET MAUI & How Does It Work?

.NET MAUI is an open-source evolution of Xamarin.Forms has expanded its capabilities from mobile to desktop environments, boasting rebuilt UI controls for enhanced performance and extensibility. If you’re familiar with Xamarin. Forms for cross-platform UI development transitioning to .NET MAUI will reveal similarities and notable differences. 

With .NET MAUI, the convenience of creating multi-platform apps through a single project is retained, allowing platform-specific code and resources to be included when needed. The primary goal of .NET MAUI is to streamline the implementation of app logic and UI layout within a unified code base.

The mechanics of .NET MAUI involve unifying Android, iOS, macOS, and Windows APIs into a singular API, enabling a “write-once run-anywhere” experience while maintaining deep access to each native platform. Supported by .NET 8 or newer, platform-specific frameworks (.NET Android, .NET iOS, .NET macOS, and WinUI 3) are provided for app development, all sharing the .NET Base Class Library (BCL) that abstracts platform intricacies. While the BCL facilitates sharing common business logic, the diverse platforms dictate varying UI definitions and interaction models. Unlike the conventional approach of crafting separate UIs for each platform, .NET MAUI offers a unified framework for constructing UIs for mobile and desktop applications.

In the architecture of a .NET MAUI app, developers primarily engage with the .NET MAUI API, which then interfaces directly with native platform APIs. App code can also now utilise platform APIs if needed. .NET MAUI apps can be written on PC or Mac and compiled into native app packages tailored for specific platforms, such as Android, iOS, macOS, and Windows. 

Android apps leverage just-in-time (JIT) compilation; iOS apps undergo ahead-of-time (AOT) compilation; macos apps utilise Mac Catalyst, and Windows apps employ the WinUI 3 library for native desktop targeting. This unified framework simplifies the development process, offering a consistent and efficient approach for creating versatile apps across diverse platforms.

The latest .NET update brings a few significant enhancements to .NET MAUI, as it now provides a unified project system and codebase for building WinUI, Mac Catalyst, iOS, and Android applications. Native AOT support for iOS-like platforms (experimental), a Visual Studio Code extension for .NET MAUI, and support for Xcode 15 and Android API 34 enhance performance, reliability, and the developer experience.

What’s New In C# 12?

Microsoft has also launched a new version of C# in C#12 as part of this latest release. But before we go further into that, let’s do a quick debrief on C# as a whole.

What Is C#?

C# is a modern, object-oriented programming language developed by Microsoft as part of the .NET initiative. Introduced in the early 2000s, it is designed for building a wide range of applications, including Windows software, web applications, and services. C# follows object-oriented principles like encapsulation, inheritance, and polymorphism, providing a structured and efficient approach to programming.

One notable feature is its platform independence, allowing C# applications to run on various operating systems through technologies like .NET Core, .NET 5, and .NET 6. The language is statically typed, ensuring early error detection during compilation. Automatic garbage collection simplifies memory management, reducing the risk of memory leaks.

C# development is facilitated by the Visual Studio integrated development environment (IDE), which offers robust coding, debugging, and testing tools. The language supports LINQ for querying and manipulating data within the code. C# is often used for event-driven programming, making it suitable for developing graphical user interface (GUI) applications. It prioritises security with features like the Common Language Runtime (CLR) for enforcing code access security.

Widely adopted, C# has a thriving developer community and continues to evolve with updates and new features, making it a versatile and powerful language for diverse application development needs.

What New Features Does C#12 Include?

First things first, C#12 introduces simplified syntax for improved developer productivity. Primary constructors can now be created in any class or structure with an elegant syntax, eliminating boilerplate code for field and property initialisation. This means you can now enjoy a concise and expressive syntax for creating arrays, spans, and other collection types. 

Default values for parameters in lambda expressions are another game changer that eliminates the need for overloading or null checks to handle optional arguments. And lastly, the alias directive can now be used for any type, not just named types.

Major Takeaways 

In summary, Microsoft’s release of .NET 8 marks a significant milestone with a plethora of enhancements across performance, cloud-native development, containerisation, artificial intelligence integration, and language improvements. 

Noteworthy features include the introduction of .NET Aspire for cloud-native applications, container enhancements for security and efficiency, seamless integration of artificial intelligence into .NET applications, advancements in Blazor for full-stack web development, and simplified syntax in C# 12.

Considering these innovations, it’s evident that Microsoft is not just back in the game but is actively pushing the envelope in the landscape of development platforms. The strides made in performance, versatility, and integration of cutting-edge technologies position .NET 8 as a robust and forward-looking framework. 

With a comprehensive set of tools across the Visual Studio family, Microsoft demonstrates a commitment to empowering developers and fostering productivity. The releases showcase Microsoft’s dedication to staying at the forefront of technology, making it clear that it will continue to be a formidable player in the ever-evolving realm of software development.

If you’d like to learn more about such emerging technologies and possibly even integrate them into software applications for your business’ growth, then reach out to us. We’d love to speak with you and go over your project in greater detail and discuss what we can do to help you supercharge your growth.

Topics
Published On

November 26, 2023