Last month, Microsoft’s .NET 7 finally officially launched, and like with every previous version of .NET, the new release makes the developer experience more convenient, makes the services you build more robust and resilient, and provides developers with a wide range of new tools and capabilities to play with.
Tanel, .NET architect and senior developer at Uptime, said that 2023 will most likely be a year of many new things for .NET developers, as they try to get familiar with the new features on offer. While there’s a lot that’s new, he said the five most interesting and important new features are the following:
Blazor Custom Elements
Components created with Blazor can now be used more universally, for example with React or Angular projects. Tanel noted that it’s too early to say how good this new option is, but hinted that the move is ushering in an interesting phase in front-end development, removing the limitations of the past and making the development process significantly faster and more convenient.
New Orleans 7
New Orleans is a framework that supports the virtual actor model architecture, allowing to avoid the shortcomings experienced so far with microservices. The framework includes the concepts of silo and grain, where a silo can contain multiple grains and grains contain the business logic. The efficiency of the framework stems from its ability to distribute grains across silos so that the application’s load and interaction with other silos is minimised.
Tanel noted that since the .NET 7 update significantly improved the overall performance of the framework and made it more convenient for developers to use, now is the time to put it to the test.
Dapr is similar in nature to New Orleans, as it also aims to compensate for the shortcomings of microservices. However, unlike the previous framework, Dapr works with Docker containers, thereby offering everything good from that world as well – technological agnosticism, easier migration of legacy applications, and an isolated runtime environment. Dapr microservices interact directly with Dapr’s sidecar module, as such leaving routing and security entirely for Dapr to handle.
Tanel pointed out that while New Orleans only supports C# and F# as languages, Dapr is much more flexible. At the same time, New Orleans has the advantage of efficiency, which is useful in cases where saving resources is critical.
Dynamic PGO and Native AOT optimisation
.NET 7 lays the foundation for better optimization of applications, in part thanks to Dynamic Profile Guided Optimization (PGO). While a static version of PGO was already available, allowing deployed applications to be recompiled and re-released to the public after testing, the dynamic version of PGO makes things much easier.
Tanel explained that now the .NET runtime can adjust its own usage and recompile itself as needed, losing almost nothing in terms of performance. This means that in the future, .NET-powered applications should be noticeably faster.
Native AOT (Ahead Of Time) functionality is also included in .NET 7, which compiles the application to exactly meet the needs of the server operating system. He said that while with this you miss out on the acceleration provided by PGO, it should also reduce the time it takes for an application to start up, as well as reduce memory usage, as the application will run without the help of the .NET runtime. Native AOT also works well with Blazor, removing segments of code that are not actually needed for the application to run.
JIT Intrinsics allows .NET to interact with device hardware in a much more precise way, making certain processes faster and easier. For example, Tanel pointed out, code can ask a processor if it has a certain way of finding the largest number. If the processor says no, the algorithms run as usual, but if the answer is yes, processes can be accelerated. In this way, for example, many LINQ methods were optimised to be orders of magnitude faster.