‹ BackHN Continuity

Thread

Comparing reflection capabilities of C++, Zig and C3

11 points · 7 comments · ManuLinares

  1. peesem · · focus · HN ↗
    &quot;not an expert in zig&quot; but you can&#x27;t even look at the documentation to find the `@tagName` builtin to do exactly the problem posed?: <a href="https:&#x2F;&#x2F;ziglang.org&#x2F;documentation&#x2F;0.16.0&#x2F;#tagName" rel="nofollow">https:&#x2F;&#x2F;ziglang.org&#x2F;documentation&#x2F;0.16.0&#x2F;#tagName

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

    1. jb1991 · · focus · HN ↗
      Agree, the post was extremely low effort.
    2. ManuLinares · · focus · HN ↗

      [dead]

    3. hiccuphippo · · focus · HN ↗
      If it&#x27;s for debugging purposes, you can use `{any}` as the format and it will print `.BLUE`

        std.debug.print(&quot;{any}\n&quot;, .{color});
    4. lerno · · focus · HN ↗
      C3 has an even simpler way than Zig: `Color.RED.description`.

      From what I can see the example started from C++, and then comparing how each language would look building it in userland instead.

Open on Hacker News to reply ↗

Unofficial Hacker News client; not affiliated with Y Combinator.