Mar 23rd, 2024

Highlighting the Key Features Introduced in .NET 8

Author - GuruPrasad Murthy
Mar 23rd, 2024

Highlighting the Key Features Introduced in .NET 8

.NET is a cross-platform, open-source developer platform providing languages, editors, and libraries to build applications for the web, mobile, desktop, games, and the internet of things. The most recent iteration of .NET is .NET 8, which proceeds .NET 7 and will be supported for three years.

.NET 8 has some exciting new developments that make intelligent app design easier and more efficient. Let’s dive in and explore some of those features now.

What is an intelligent app?

First, let’s define what we mean by an “intelligent app”. Intelligent apps use user data from interactions and other sources to make predictions and suggestions based on previous behavior. In this way, they can deliver tailored and adaptive experiences to their users.

Examples of intelligent apps include Tik Tok and YouTube, whose algorithms serve users content based on previous actions taken within the app, ensuring users only see content that is relevant to them or that they will find engaging.

video technology software
What’s New? Key Features in .Net 8

Here’s a brief overview of several fresh features now accessible on .NET 8.

  • .NET Aspire: Pre-configured toolkit for cloud native applications that can be tracked. It encompasses a carefully selected array of elements optimized for cloud-native environments, integrating telemetry, resilience, configuration, and health checks as standard features. Paired with an intuitive yet powerful local development setup, .NET Aspire simplifies the process of identifying, obtaining, and setting up crucial dependencies for cloud-native applications from day one through day 100.
  • AI pattern and practices templates: .NET 8 makes adding AI to your applications a breeze. It provides built-in AI tools directly in the .NET software development kit (SDK) and allows you to easily use other AI services. Microsoft have partnered with a range of internal and external collaborators, including Azure OpenAI, Azure Cognitive Search, Milvus, Qdrant, and Microsoft Teams, to ensure that .NET developers can seamlessly access a diverse array of AI models, services, and platforms via their respective SDKs.
  • Improved garbage collection: This improved version allows you to adjust memory limits dynamically for cloud-native applications, especially those running on Kubernetes.

    To utilize this functionality, simply invoke the RefreshMemoryLimit() API.

    GC
    .
    RefreshMemoryLimit
    ();

    Refresh GC settings pertaining to the memory limit.

    AppContext
    .
    SetData
    (
    "GCHeapHardLimit"
    ,
    (
    ulong
    )
    100
    *
    1_024
    *
    1_024
    );
    GC
    .
    RefreshMemoryLimit
    ();
  • JSON serialization and deserialization: .NET 8 offers some enhancements to JSON serialization and deserialization compared to previous versions. The System.Text.Json source generator has been improved to bring its capabilities closer to the traditional reflection-based serializer when building apps for Native AOT (Ahead-of-Time) compilation.
  • Time Abstraction Functionalities: .NET 8 introduces a new way to control time in your tests, making them more reliable and easier to write. This feature is called time abstraction.
    • Create custom timers: Define how timers behave in your tests.
    • Get local or UTC time: Access the current time (local or Coordinated Universal Time) during your tests.
    • Measure performance: Obtain timestamps to measure how long parts of your code take to execute.
  • Cryptography features: Now, you can compress files from a directory using a stream without the need for caching, enabling direct memory management of the compression result. These APIs are particularly valuable in scenarios where disk space is constrained, as they bypass intermediate disk operations.
  • Code generation enhancements:
    • Refinements in Profile-guided optimization (PGO)
    • Improved containerized application performance in cloud-native settings
    • Performance enhancements tailored for Arm64 architecture
    • Enhanced SIMD for better parallelization
    • JIT optimizations for accelerated code generation
  • Blazor enhancements: Blazor in .NET 8 is even more flexible! You can now mix and match client-side and server-side rendering within the same application. Some of the benefits are faster page loads and more interactive elements, control over performance and data updates and smooth user experience.
  • .NET MAUI: This simplifies development by offering a unified project system and codebase for creating WinUI, Mac Catalyst, iOS, and Android applications. Additionally, the experimental Native AOT now extends support to target platforms resembling iOS. It also gives you tools to develop cross-platform, .net mobile and desktop applications.
  • #C 12 feature: With C# 12, coding becomes more efficient and easier. You can easily craft primary constructors in any class or struct using a clean and concise syntax. There is no need of repetitive boilerplate code for initializing fields and properties.