Hacker News new | ask | show | jobs
by zigzag312 591 days ago
I love that NativeAOT is making slow but steady progress through C# ecosystem.
2 comments

Better later than never, I was disappointed with NGEN capabilities, given the Delphi influences on .NET.

Microsoft research had Sing#, System C#, which never came to us, Mono AOT had its issues, and finally Windows 8.x MDIL/Bartok, UWP .NET Native, which were still special cases.

I always vouched the opinion that had .NET supported AOT properly since the beggining, there would have been much less people reaching out to C and C++, as one of the reasons was getting real executables (same applies to Java, and the issue AOT until recently being a commercial JDK feature for deep pockets).

Is no generics with AOT the only catch?
Generics do work with AOT.

You can't generate new code at runtime (Reflection.Emit) with AOT.

My wording was incorrect. My apologies. I meant open generics (List<T>)
Why would generics not work with AOT?
I meant open generics. My wording was incomplete.
Why would open generics not work? If generics had any issues on NativeAOT it would have been an unusable target.
Last time I tried I had troubles. My understanding is open generics (like List<T>, without specifying T) don’t fully compile because Native AOT lacks a JIT to handle unspecified types at runtime. Closed generics work fine, though, as they’re fully known at compile time. Am I wrong in my thinking?
This does not line up with the implementation. You may want to ask in DotNetEvolution or dotnet/runtime discussions as there you can get a definitive answer why something didn't work - most of the time it is best to avoid such assumptions.

Open generics simply propagate type parameters down - T: class produce shared method bodies, as they do with the JIT with the type being passed implicitly. For T: struct the corresponding code is fully monomorphized. This is not related to JIT at all where the main distinction with NativeAOT is when compilation happens.

All generic scenarios are supported. Unbound un-analyzable reflection as well as anything that requires JIT like assembly loading or reflection emit - this doesn't work for obvious reasons.