Zig-style generics are not well-suited for most languages
Zig-style generics, inspired by C++, are critiqued for limited universality. Zig's simplicity contrasts with Rust and Go's constraints. Metaprogramming praised for accessibility, but error messages and compiler support pose challenges. Limited type inference compared to Swift and Rust.
Read original articleZig-style generics, resembling C++, are critiqued for not being universally suitable for all languages. While Zig aligns generics with its philosophy of simplicity, other languages may not share this view. The post highlights that Zig's approach, akin to templates, lacks upfront constraints in function signatures, contrasting with languages like Rust or Go. Zig's metaprogramming capabilities are praised for being more approachable than C++ due to its simplicity. However, the post warns against the complexity of error messages in generic code, a common issue in languages like C++. It also points out limitations in compiler support for both writing and calling generic code, emphasizing the need for extra work to ensure a good developer experience. Additionally, the post discusses the challenges posed by limited type inference in Zig-style generics compared to languages like Swift or Rust. Overall, the post suggests that while Zig's approach may work well for Zig itself, it may not be the best fit for most other languages due to various constraints and complexities involved.
Related
Tracing garbage collection for arenas
Tracing garbage collection in systems programming languages like C++, Rust, and Ada is compared to reference counting. A simplified tracing garbage collection approach inspired by Mark-and-Sweep is proposed for languages like Zig or Odin.
Common Interface Mistakes in Go
The article delves into interface mistakes in Go programming, stressing understanding of behavior-driven, concise interfaces. It warns against excessive, non-specific interfaces and offers guidance from industry experts for improvement.
Weekend projects: getting silly with C
The C programming language's simplicity and expressiveness, despite quirks, influence other languages. Unconventional code structures showcase creativity and flexibility, promoting unique coding practices. Subscription for related content is encouraged.
I Probably Hate Writing Code in Your Favorite Language
The author critiques popular programming languages like Python and Java, favoring Elixir and Haskell for immutability and functional programming benefits. They emphasize personal language preferences for hobby projects, not sparking conflict.
Improving Your Zig Language Server Experience
Enhance Zig Language Server (ZLS) by configuring it to run build scripts on save for immediate error display. Zig project progresses include faster builds, incremental compilation, and code intelligence. Support via Zig Software Foundation donations.
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.
>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)
Related
Tracing garbage collection for arenas
Tracing garbage collection in systems programming languages like C++, Rust, and Ada is compared to reference counting. A simplified tracing garbage collection approach inspired by Mark-and-Sweep is proposed for languages like Zig or Odin.
Common Interface Mistakes in Go
The article delves into interface mistakes in Go programming, stressing understanding of behavior-driven, concise interfaces. It warns against excessive, non-specific interfaces and offers guidance from industry experts for improvement.
Weekend projects: getting silly with C
The C programming language's simplicity and expressiveness, despite quirks, influence other languages. Unconventional code structures showcase creativity and flexibility, promoting unique coding practices. Subscription for related content is encouraged.
I Probably Hate Writing Code in Your Favorite Language
The author critiques popular programming languages like Python and Java, favoring Elixir and Haskell for immutability and functional programming benefits. They emphasize personal language preferences for hobby projects, not sparking conflict.
Improving Your Zig Language Server Experience
Enhance Zig Language Server (ZLS) by configuring it to run build scripts on save for immediate error display. Zig project progresses include faster builds, incremental compilation, and code intelligence. Support via Zig Software Foundation donations.