Comment

Comment by iainmerrick

That's clearly correct, as e.g. Go uses this style and there are lots of happy Go users.

I want to push back on the idea that it's a "trade-off", though -- what are the actual advantages of the ZII approach?

If it's just more convenient because you don't have to initialize everything manually, you can get that with the strict approach too, as it's easy to opt-in to the ZII style by giving your types default initializers. But importantly, the strict approach will catch cases where there isn't a sensible default and force you to fix them.

Is it runtime efficiency? It seems to me (but maybe not to everyone) that initialization time is unlikely to be significant, and if you make the ZII style opt-in, you can still get efficiency savings when you really need them.

The explicit initialization approach seems strictly better to me.

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton