Live data from Hacker News

.NET 8 Standalone 50% Smaller On Linux

learn.microsoft.com

1–10 of 179 posts

Re: .NET 8 Standalone 50% Smaller On Linux

#6
post #3

They also added a TimeProvider to help with testing time objects. Maybe one day we will also get an FileSystemProvider.. TimeProviderFake: https://learn.microsoft.com/en-us/dotnet/api/microsoft.exten... ReleaseNotes: https://learn.microsoft.com/en-us/dotnet/core/whats-new/dotn...

> Maybe one day we will also get an FileSystemProvider.

Until then you can use System.IO.Abstraction[1] if you aren't already :)

[1] https://github.com/TestableIO/System.IO.Abstractions

Re: .NET 8 Standalone 50% Smaller On Linux

#8
post #5

This is for native AOT binaries, not for the typical case. Though this release and the previous ones did contain improvements for trimming binaries, which is what you need to use to make non-AOT binaries smaller.

Curious - why isn't it the typical case? .NET runtimes on Linux itself are rare enough, I figured AOT on Linux would be about the only use case, especially in containerized environments.

Re: .NET 8 Standalone 50% Smaller On Linux

#9
post #8
post #5

This is for native AOT binaries, not for the typical case. Though this release and the previous ones did contain improvements for trimming binaries, which is what you need to use to make non-AOT binaries smaller.

Curious - why isn't it the typical case? .NET runtimes on Linux itself are rare enough, I figured AOT on Linux would be about the only use case, especially in containerized environments.

.NET uses a lot of reflection, and you need to replace that with other mechanisms for AOT.

And for modern .NET (previously named .NET Core, the version that also runs on Linux) you can package the runtime with the binary. You can even create single-file executables there, though those are still not AOT.

The main advantage of AOT is startup time, and that didn't use to matter much for the kind of applications .NET was used for. It matters more now with serverless stuff like AWS Lambda.

Post reply on HN