4 ms·
Ok, try this one: string cat(string s) { return "int " ~ s ~ ";"; } int test() { mixin(cat("i")); return i + 3; }
by WalterBright 4y ago
Ok, try this one:
string cat(string s) {
return "int " ~ s ~ ";";
}
int test() {
mixin(cat("i"));
return i + 3;
}
- pjmlp 4y agoFor that one D gets one point, even though Circle C++ might be able to do it, it isn't ISO C++. So what if D wins at code golf against C++? What matters is being good enough for most compile time use cases, while enjoying the large ecosystem and IDE tooling, perfect is the enemy of good.
- WalterBright 4y agoThe ability to use CTFE to generate strings that can then be fed back into the compiler is a heavily used feature, not just a golf point. It enables the creation of mini-DSLs.
- pjmlp 4y agoYou tend to praise D features, while ignoring that a language on its own doesn't make an ecosystem. Indeed C# and C++ don't give me all nice features from D, when doing language comparison tables, D wins on that table listing. Yet they give me their library ecosystem, graphical IDEs, and first day avail on any major company SDK. I will take that productivity win over the few features that the D language happens to have. Why is Andrei Alexandrescu helping to improve C++ at NVidia instead of using D, when the language is so great? Ecosystem, that is why.