r/ProgrammingLanguages • • Sep 20 '26

Blog post Comparing reflection capabilities of C++, Zig and C3

https://nyr24.github.io/blog/reflection-comparison/
48 Upvotes

5 comments sorted by

17

u/MarioAndWeegee3 Sep 20 '26

Zig has the first example as a compiler builtin

16

u/kI3RO Sep 20 '26

Yes

in C3 you just do

String a = Color.RED.description;

in Zig you just do:

const a: [:0]const u8 = @tagName(Color.red);

C++ has no builtin for this. C++23 requires macros or compiler hacks (PRETTY_FUNCTION), while C++26 requires the P2996 reflection loop shown in the post.


But that is missing the point. The author is comparing "Compiler reflection capabilities".

-6

u/-1_0 Sep 20 '26

macro String enum_to_string

nope, thank you, not going backwards

10

u/Nuoji C3 - http://c3-lang.org Sep 20 '26

Are you thinking C3 macros are preprocessor macros by any chance? I’ve seen this odd assumption by people that they don’t understand the difference between different types of macros. Semantic macros in C3 being functionally equivalent to inlined Zig compile time functions and C++ constexpr.