The main goal of.NET 7 is performance, and every feature was created with performance in mind.
The following .NET 7 feature, Native AOT Deployment is solely focused on performance
Table of Contents
What is .NET AOT?
.NET-based desktop applications or mobile apps can now run with AOT or Without AOT.
Without AOT(JIT compilation), it will compile the C# to an intermediate language (certain .dlls)
When the application is launched, the Just-In-Time compilation of .NET Framework runtime or .NET Core runtime will convert IL into binary executable code.
But With AOT in .NET, Visual Studio can compile the C# code to binary executable code.
The application execution performance of AOT-compiled apps is almost the same as compared to JIT-compiled since JIT will compile to binary code when the application starts.
So there will be a performance improvement during application start-up only.
Native AOT Deployment
Native AOT deployments are one of the significant features of .NET 7. Native AOT deployment will be one great feature for game development.
Native AOT deployment allows us to compile .NET applications to native machine code, directly. As earlier, there won’t be anything in the middle of compilation, No intermediate language (IL), and also no runtimes.
Deploying to iOS platforms actually requires AOT compilation. The long-term objective of Native AOT deployment is to be able to construct AOT in a variety of ways and in a variety of capacities.
Microsoft is developing a new system with this. There are certain restrictions with this release; for example, only a small portion of libraries in.NET 7 support native AOT compilation, and this release is geared toward console-type applications. As a result, this is something to look forward to in the future.
AOT allows you to focus on a very precise runtime. You might claim that you want to create a native version of your application for the Windows ARM64 platform. At the moment only Windows and Linux operating systems support AOT deployment.
Regardless of where AOT stands, it is still new to .NET 7 and I am assuming by the way Microsoft is presenting it that eventually, you are going to have the full library support for all the different platforms later on.
AOT deployment is still new to.NET 7. But, based on the way Microsoft is presenting it, it may eventually improve with full library support and will support all of the different platforms.
Native AOT has an advantage when there are many deployed instances, such as in hyper-scale cloud infrastructure services.
Although it is a highly specialized use case, in general, natively compiled applications can start up more quickly and consume less memory.
FAQ – Native AOT in .NET
What is AOT in .NET core?
AOT compilation refers to a group of technologies that produce code at application construction time rather than at the run time.
Why would you use AOT compilation in .NET framework?
Some Platforms don’t support the execution of dynamically produced code. With AOT compilation feature that issue is addressed. Also, application startup time will be less as compared to JIT based.
What is .NET native runtime?
.NET Native runtime is designed for static precompilation for better performance. The fundamental reflection characteristics that developers normally use are still present.
What are the Benefits of AOT in .NET?
Ahead Of Time Compilation improves application startup time.
AOT can create libraries that non-CLR programming languages can use in their applications.
AOT can be used on platforms when JIT compilation isn’t permitted for some reason. Platforms such as Xamarin and iOS prohibit the execution of dynamically produced code. Hence AOT-compiling of applications will be the best to pass such security issues.
How to Enable AOT compilation?
Ensure .NET 6.0 or higher version is installed.
During Publish, we can choose Precompile during publishing in the File publish option(as shown below the check box).
Summary
This post covered in brief the new feature in .NET 7, the Native AOT Deployment. Hope you find this post useful.
Leave a Reply