News for hackers. Stuff that matters.
Re:JavaScript Structs by wvenable on Friday October 11, 2024 @01:35PM (#41811496)
> Primary constructors are a very poorly designed feature that for some reason was added in the last version.

I upgraded to .NET 8 recently and I love primary constructors. I don't use them everywhere but they are great for dependency injection or for small classes.

Re:JavaScript Structs by terandle on Friday October 11, 2024 @04:41PM (#41813501)
Beware the footguns!

https://mareks-082.medium.com/dark-side-of-the-primary-const...

Let's just say they could have done a much better job on it. It feels rushed and haphazard for such a mature language.

Re:JavaScript Structs by wvenable on Friday October 11, 2024 @05:32PM (#41813963)
It doesn't seem that bad -- the lack of readonly would be my only concern out of that article and one I didn't actually consider.

I think, as a feature, this is sort of the MVP. They could have done a better job of it by adding more to it (e.g. maybe allow the readonly modifier on the constructor properties). It's hard to imagine them being able to take anything away from primary constructors that would make it better.