Zig-style generics are not well-suited for most languages
Zig is an attempt to merge metaprogramming and type system into a single, coherent unit, however not without drawbacks. Basically, in an ideal language, I see that type system permits three kinds of dependencies:<p>- Values dependent on values (algorithms)<p>- Values dependent on types (parametric polymorphism)<p>- Types dependent on types (type-level functions)<p>This is one dimension weaker than Calculus of Constructions (CoC) [1], which permits types dependent on values (so-called "dependent types"), but we don't need them until we want to prove some properties about our code (dependent types correspond to logical predicates). Some tasks handled by metaprogramming however may not be handled even by a type system that permits type-level functions; for this reason, probably we have to include some sort of simple syntax transformations, such as those found in Idris [2].<p>I expatiated in one of my posts [3] on why static languages duplicate their language concepts. This writing also includes Zig and Idris.<p>[1] <a href="https://gist.github.com/Hirrolot/89c60f821270059a09c14b940b454fd6" rel="nofollow">https://gist.github.com/Hirrolot/89c60f821270059a09c14b940b4...</a><p>[2] <a href="http://docs.idris-lang.org/en/latest/tutorial/syntax.html" rel="nofollow">http://docs.idris-lang.org/en/latest/tutorial/syntax.html</a><p>[3] <a href="https://hirrolot.github.io/posts/why-static-languages-suffer-from-complexity.html" rel="nofollow">https://hirrolot.github.io/posts/why-static-languages-suffer...</a>