News for hackers. Stuff that matters.
Re:Unexpected inconsistency in records – Jon Skeet's coding ... by cbsmith on Tuesday July 22, 2025 @12:59PM (#44649983)
> Really? Perhaps read the 'Principle of Least Astonishment' [1] to see why this is a problem. If I create a new object I would expect the 'init time' properties to be initialised.

The Principle of Least Astonishment definitely applies. It's a deliberate design choice that unfortunately violates the principle.

> Great insight. Let's not run the 'init time' properties for a newly initialised object, just in case it works as expected. This 'feature' can't even be manually resolved by doing post-`with` updates (because often the properties are init/read-only). It makes the whole init-property feature brittle as fuck.

? I'm not sure I follow what you are going with here, but yeah, in general you'd have to carefully limit all uses of "with" for objects with precomputed values to inside the encapsulation of said objects. Alternatively, as you mentioned, you could just not have precomputed properties.

Re:Unexpected inconsistency in records – Jon Skeet's coding ... by louthy on Tuesday July 22, 2025 @03:28PM (#44651925)
> in general you'd have to carefully limit all uses of "with" for objects with precomputed values

What you’re describing is incidental complexity. It is not a good thing. You can’t limit it with the language, you have to rely on the programmer following this and never ever making a mistake.

Ultimately the incidental complexity for the average C# developer has increased, whereas a better direction of travel is toward correctness and declarative features. I would prefer it if the csharplang team worked toward that.

Re:Unexpected inconsistency in records – Jon Skeet's coding ... by cbsmith on Tuesday July 22, 2025 @05:43PM (#44653346)
> What you’re describing is incidental complexity. It is not a good thing.

Yes.