C3's compile-time reflection rivals C++ and Zig with far less ceremony

Comparing reflection capabilities of C++, Zig and C3

C3's compile-time reflection rivals C++ and Zig with far less ceremony

C3, a new systems language, uses $-prefixed syntax and macros to make compile-time reflection explicit and readable. The author compares enum-to-string conversion, struct introspection, and attribute validation across C++ (with its upcoming reflection), Zig, and C3. C3 matches C++'s power while being easier to follow, and unlike Zig, it's already on 0.8.x with 1.0 approaching.

It's a lot more stable than Zig (honestly, it's pretty embarrassing that Zig is still stuck on 0.1x versions after over 10 years of development), and since C3 is already on 0.8.x versions, 1.0 is very close.
  1. peesem

    "not an expert in zig" but you can't even look at the documentation to find the `@tagName` builtin to do exactly the problem posed?: https://ziglang.org/documentation/0.16.0/#tagName

    i can literally google "zig enum to string" and the first result is a reddit post where the given solution is `@tagName`. i'm ready to write this post off as a low-effort ad for C3

  2. RyanVail

    Zig doesn't have attributes, but you could just create a thin wrapper struct over an inner type and use setter functions that throw errors on invalid values. Personally I prefer this over attributes because it forces you to handle possible error states from the callers of the setters, instead of relying on you remembering to call `validate` on your types.

  3. WalterBright

    There's a large black zig-zag blocking reading the text.

More from this day

2026-09-20