Zig-style generics are not well-suited for most languages (2022)
typesanitizer.com
typesanitizer.com
This is the first time I've seen something said so similarly to how I feel about what the article describes as "template"-style generics; it has a similar user experience to duck typing where you have to just use something that fits the expected shape where it's being used or else everything falls apart. The happy path where everything is done correctly is certainly less verbose, but at least personally I don't end up feeling like it's less work in the long run to have the errors that inevitably happen when I slip up take so much more effort to debug.
I have mixed-feelings about them. On one hand they have all the problems mentioned in the blog post and most of the ones from duck typing in general.
On another hand not needing to define protocols for every little thing is pretty nice.
I think a nice middle ground would be to structuraly type them. Have the compiler record in some interface file of some sort exactly which fields/functions must be available for the template to work.
But I don't think such a thing is feasible with the insane metaprogramming you can do in zig or even C++ (which is also turing complete, just incomprehensible)
>However, most languages don’t share that philosophy, at least, not as strongly as Zig does.
Bryan Cantrill talked about values of different programming languages [1] and I think it's a particularly useful way to compare different languages and the choices they make when developing them.
It often seems that criticism that is directed at a language is simply a reflection of a difference in values.
1. https://corecursive.com/024-software-as-a-reflection-of-valu...
Zig-style generics are not well-suited for most languages - https://news.ycombinator.com/item?id=33142751 - Oct 2022 (128 comments)