Hacker News new | ask | show | jobs
by mumblemumble 963 days ago
Just taking a stab at it; this might not be exactly right --

It's kind of down to C# being compiled into bytecode and then JIT compiled at run-time. During the initial compilation phase, the compiler doesn't necessarily have enough information to know whether `ElementAt()` or `Name` has side effects. (I assume here that Name is a property getter and not a field, in keeping with .NET conventions.) And then at run time the JIT compiler isn't as aggressive as an AOT compiler would typically be about optimization, so it may be less likely to do any dead store elimination.

1 comments

Pretty much correct from a historical sense.

On top of this recent advancements in .net have lead to native AOT.

Something to look into.