>>27706metaprogramming is like programming about programming, youre basically writing a code that can read generate analyze or create other code(including itself) while the program runs so when normal code manipulates data,metaprogramming treats code as data and is able to manipulate it, D is good and even the best for that as you can run it at compile time because of CTFE which is far beyond C++ `constexpr`
it also has string mixins so you can generate arbitrary D code at compile time
for example a code like this
string generateGetters(string[] fields) {
string result;
foreach (f; fields) {
result ~= " @property auto " ~ f ~ "() const { return _" ~ f ~ "; }\n";
}
return result;
}
mixin(generateGetters(["x", "y", "z"]));
will turn into this after compile
@property auto x() const { return _x; }
@property auto y() const { return _y; }
@property auto z() const { return _z; }