News for hackers. Stuff that matters.
Re:Classes vs. Structs in .NET. How not to teach about perfo... by mumblemumble on Saturday November 04, 2023 @09:49PM (#38147204)
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.

Re:Classes vs. Structs in .NET. How not to teach about perfo... by idonttalkenough on Saturday November 04, 2023 @11:16PM (#38147731)
Pretty much correct from a historical sense.

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

Something to look into.