3 ms·
C++ has improved a lot, but many of those solutions have been half-assed versions of things D does to completion. CTFE in D works as you would expect, constexp
by mhh__ 6y ago
C++ has improved a lot, but many of those solutions have been half-assed versions of things D does to completion.
CTFE in D works as you would expect, constexpr is a weird hack.
Concepts in C++ are ridiculously overcomplicated and are done with a much simpler solution in D.
Ranges are also much better thought out in D.
C++ will also never replicate D's ease of use when it comes to metaprogramming - static foreach and if for example have no alternative in C++ (if constexpr is incredibly stupid)
- einpoklum 6y agoSo, you're saying: CTFEs, concepts and ranges done right. Hmm. Sounds good, actually...
- mhh__ 6y agohttps://run.dlang.io/is/dkFWTu https://run.dlang.io/is/dkFWTu Sink your teeth into that. Code generation at compile time, functional programming etc. The compiler can actually check that this is pure for you but in this case it isn't performed so it can read from stdin
- 1980phipsi 6y agoD doesn't have concepts. It just takes a different approach.
- lionkor 6y ago> if constexpr is incredibly stupid Would you care to elaborate what's wrong with it? When I used it I always felt it was quite straightforward.
- mhh__ 6y agoD CTFE restricts what you can't do. If I write my own vector type, even with my own malloc (it would have to get it's memory from the GC when running under CTFE for obvious reasons, but still), I can do useful work on it at compile time and then save that result in the data segment of my executable. Constexpr tells you what you can do. It adds huge amounts of bulk to the standard, there is syntax soup everywhere now etc.