Why You Should be Enthusiastic About .Net 7?

The .NET Framework is an open-source developer platform you can use to create a broad range of applications. This free cross-platform framework accepts multiple coding languages and features large code libraries that make it easy to build applications for mobile devices, desktops, the web and the Internet of Things.

Proficiency in all things “dot net” could increase your earning power because of its usefulness and adoption among companies throughout diverse industries, ease of use and versatility. In this article, we explain what .NET is, its components, why companies use it and the different things you can create on this platform.

What is .NET?

.NET (pronounced dot net) is a free, open-source software development framework developed by Microsoft. It provides programming tools and guidelines you can use to build a wide range of applications for the web, gaming, mobile devices, desktops and the Internet of Things (IoT). Since Microsoft released the first version in 2002, developers and companies have used the .NET Framework to create form-based and web-based applications.

The .NET Framework comprises a large class library called the Framework Class Library (FCL) and the Common Language Runtime (CLR), which allows software applications developed on the platform interoperability across multiple programming languages. With the .NET Framework, developers can build and run software applications for Windows, Windows Mobile, Windows Server, Microsoft Azure and XML Web services on a single integrated development environment.

The primary focus of .NET was to eliminate the major challenges of application development, such as high ownership costs, ease of deployment, difficulty in changing applications and extended development periods. The CLR and FCL addressed many of these issues.

How About .NET 7?

Last year, the .NET team introduced the .NET Upgrade Assistant tool to make migrating from .NET Framework to modern .NET targets easier. Since then, the team has been hard at work iterating on the upgrade tooling story to improve functionality and fill gaps.

With .NET 7’s release, there are now more tooling options for easing the transition from .NET Framework to .NET 7. This article walks through those improvements – both the new capabilities in Upgrade Assistant and some new tooling focused specifically on web scenarios with the ASP.NET Incremental Migration Tooling and System.Web Adapters.

.NET 7 Will be Very Fast?

Microsoft’s Stephen Toub, a partner software engineer for .NET at Microsoft, has written a massive post detailing performance improvements in the forthcoming .NET 7, for which release is expected around November this year.

Toub’s book-length article (over 75,000 words) is based on “almost 1000 performance-impacting PRs [pull requests]”, of which he describes around 500, concluding that “it’s the fastest .NET ever.” The .NET Runtime supports Windows, Linux and macOS; Toub states that his results are recorded on Windows 11 64-bit but “aren’t Windows-specific.”

The question of how much faster is slippery. A big speed-up in some corner of the .NET just-in-time (JIT) compiler, for example, might make little difference to most applications but a big difference for code that happens to stress that part of its functionality. One of the things Toub discusses is bounds-check elimination, meaning cases where the compiler can maintain memory safety but improve performance by skipping checks for accessing memory out of the bounds of a data structure, by proving that a check is unnecessary. A performance test showed a four-times speed-up in some array operations.

What Can We Already Expect From .NET 7?

Even though there is no official release date for .NET 7 yet, the development team has already announced .NET Preview 4 (with Preview 3 being released in April 2022). And by looking at the newly introduced features in all Preview versions, we can already get a good understanding of what .NET 7 will have under its hood. Without further ado, let’s quickly go through the history of .NET 7 Preview versions and focus on the most anticipated functionality.

Native AOT

Native ahead-of-time compilation was first mentioned in Preview 2 but at that time, it had just been moved to the mainline development out of the experimental status. With the release of Preview 3, developers now have the option to test Native AOT for .NET and enjoy what it has to offer.

Ahead-of-time compilation implies code generation at the app’s build time rather than at run-time. This approach usually provides faster startup time, lighter apps, faster rendering, and more efficient memory usage. Even though AOT is not new for .NET, native AOT is something freshly introduced. The main idea behind native AOT is that it produces native artifacts only. In this way, the underlying OS is fully responsible for handling the executable file format parsing. And while the use of native AOT is not obligatory, this approach is recommended for projects where startup time matters the most.

The .NET team states that console apps and native libraries are the main targets for native AOT use. The main condition for apps to be compatible with the native AOT approach is that they should be trimmable. For that, Microsoft provides detailed documentation on how to prepare apps and libraries for trimming and therefore, make them suitable for native AOT.

Observability

.NET supports observability via OpenTelemetry so several enhancements were made to continue and improve this support. But first, a quick note on OpenTelemetry. It is a set of SDKs, APIs, tools, and integrations that help you create and manage telemetric data such as logs or metrics (in other words, observe them). .NET 7 is intended to bring more efficiency and transparency to the existing observability with the following improvements:

  • New Activity.Current change event for receiving notifications on span context changes;
  • Exposed methods for enumerating Activity properties;
  • Trace state is now mutable for samplers.

Startup time improvements

One of the main areas of focus of the new .NET 7 version is performance so it’s no surprise that the development team is working hard on that. In Preview 3, the .NET team announced that they managed to significantly improve the startup time by reimplementing the precode and call counting stubs. This was done with Write-Xor-Execute enabled which is also a newly introduced thing.

It’s interesting that this approach also resulted in state performance improvements in a few ASPNet Benchmarks and microbenchmarks and their performance saw improvement even with the disabled Write-Xor-Execute. However, it’s important to mention that this change resulted in several regressions that are currently being worked on. These regressions happened on Intel processors only and impacted only Orchard and Fortunes benchmarks.

On Stack Replacement for better performance

Another great contribution to the startup time and overall performance is the implementation of On Stack Replacement (OSR) which was introduced in Preview 4. With enabled OSR, the code that’s executed by currently running methods can be changed mid-execution by the runtime. In this way, the runtime can quickly jit all methods at first and then shift to more optimized ones if needed (i.e. when the methods are called frequently). As a result, developers can enjoy a great performance boost from using OSR.

Microseconds and nanoseconds in date and time structures

A really interesting innovation added to the .NET Preview 4 is the introduction of milliseconds and microseconds to the date and time implementations. Before, developers had to perform computations on the “tick” value (100ns) to determine the values of microseconds and nanoseconds. Now, a new API surface area addresses the issue and makes date and time structures more manageable.

Final…

the .NET team is really dedicated to bringing a superior development experience with the new .NET 7 version. By now, all newly introduced features look really exciting, and seems like the development team takes all feedback into consideration and delivers corresponding changes.

Posted in Hosting Article.