Reflection lets a program inspect and manipulate its own structure at runtime or compile time. All C++ (with its upcoming reflection support), Zig and C3 rely on compile-time reflection, so you can reason about types, enumerators, and struct members without any runtime cost. In this post I will compare how these languages approach compile-time reflection.

What is C3?

C3 is a relatively new programming language which mainly focuses on readability, performance, minimalism, and familiarity for C/C++ programmers.

It doesn't have heavy runtime, garbage collection, exceptions or RAII.

It also fully supports C ABI compatibility out of the box.

C3 uses special syntax for compile-time execution: all variables, control-flow constructs are prefixed with $**. This was done on purpose to explicitly show the reader which code runs at compile time. It uses **macros for compile-time evaluation and reflection.