3 ms·
> Now, C++ does have one code generation facility today: C macros. It’s just a very poor and primitive one. Poor because of their complete lack of hygiene to th
by sixthDot 2y ago
> Now, C++ does have one code generation facility today: C macros. It’s just a very poor and primitive one. Poor because of their complete lack of hygiene to the point where you could be accidentally invoking macros without knowing it (and standard library implementations guard against that), and primitive because even remarkably simple things conceptually (like iteration or conditions) require true wizardry to implement. That said, there are still plenty of problems today for which C macros are the best solution — which really says something about the need for proper code generation facilities.
The D language has both: introspection (__traits, is, etc.) plus hygienic code generation (mixin, static if, static foreach, etc.).
- germandiago 2y agoPlus few people use it and the ecosystem is not stellar I would say. And that is the only reason why I do not use it, probably. It scores very high in code style and convenience, I can see there expertise in day-to-day coding actually, in the patterns it enables. A pitty, actually :(
- sixthDot 2y agoI agree, isn't it a pitty. D should have worked more. Why the heck people ignore it ? They prefear speaking about zig, odin, c3, v, nim, crystal, etc ? I eventually look at their bug trackers and see bugs that have been fixed since years in D ;)
- germandiago 2y agoD is incredibly balanced as in "people who know how to write code". It has a very pragmatic view of things, actually and does things that do work. I think the main problem why D did not catch up is because its leadership (mainly Walter Bright I guess) is very focused on the core technology: compiler writing and the like and how to write software. This ignored things such as ecosystem, tooling or the availability of the compiler in a polished way for multiple systems. I think the part that has been ruining D is the fact that they had a very good language (good) but they did not take care of the rest of the aspects. Also, they have been quite poor at marketing it. I also saw complaints quite often for broken code or underspecified behavior. All these things together add up and can make people who just "want to get things done" run away. It is a pitty because the core of the language is beautiful and useful: you can do very advanced generic programming, good OOP, avoid the GC when necessary, slices are well-thought, introspection and code generation is stellar... What I said... a pitty. Walter Bright is a genius in my humble opinion. But a genius in his area. I think he should pay a bit more attention to other aspects, because the core is really robust, it would be about improving it, marketing it, making it more stable, making it more widely available and improving the ecosystem. For example, last time I heard, D language for Android was not ready... you cannot afford that nowadays if you want to get through, I think priorities after desktop should be mobile... Idk. All in all, the perception, unless they change something, is against them compared to newer languages such as Rust (which I really do not like that much, even if I know its merits). So, the only way I see to make this perception change would be with a more targeted roadmap and an announcement that has impact in the marketing sense and a commitment that it is going to happen. The problem with this it is that it needs resources and direction, and projects like this are in a big part community-driven, so it is not easy to deal with something like this.
- steveklabnik 2y agoAndrei Alexandrescu is involved in this work, they are aware of D for sure.
- oneshtein 2y agoIt's possible to use another macro languages with C/C++. For example, cvstrac uses «translate» tool to replace `@` with `cgi_printf`.
- MiguelX413 2y agoIt's significantly less portable to do so.
- int_19h 2y agoSo long as it's a separate facility that is not aware of C++ syntax and semantics, you get the same problems wrt hygiene and lack of ability to resolve symbols.