Re:Better C – A subset of D Programming Language
by maxsam on Wednesday April 29, 2020 @06:10AM
(#23017437)
> its metaprogramming facilities far outstrip the C preprocessor.
...and are severely crippled by applying betterC constraints to CTFE:
// CTFE-only
string genint(string name) {
return "int " ~ name ~ ";";
}
void main() {
mixin(genint("x"));
}
Error: array concatenation of expression "int " ~ name ~ ";" requires the GC which is not available with -betterC
True, but the trouble with simplicity is a number of things become excessively tedious and error-prone to code - such as ensuring no buffer overflows.
C makes up for its lack of expressivity by adding a text preprocessor. The preprocessor is a tacit admission that the core language simply isn't powerful enough. When people find themselves doing metaprogramming with the C preprocessor, it's really time to graduate to a more powerful language. DasBetterC doesn't need a preprocessor, and its metaprogramming facilities far outstrip the C preprocessor.