News for hackers. Stuff that matters.
Re:Idioms for the D Programming Language by mhh__ on Thursday February 11, 2021 @04:12PM (#26107267)
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)

Re:Idioms for the D Programming Language by einpoklum on Thursday February 11, 2021 @05:52PM (#26108529)
So, you're saying: CTFEs, concepts and ranges done right. Hmm. Sounds good, actually...
Re:Idioms for the D Programming Language by mhh__ on Thursday February 11, 2021 @06:29PM (#26108938)
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

Re:Idioms for the D Programming Language by 1980phipsi on Thursday February 11, 2021 @08:07PM (#26109706)
D doesn't have concepts. It just takes a different approach.
Re:Idioms for the D Programming Language by lionkor on Friday February 12, 2021 @07:52AM (#26113092)
> 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.

Re:Idioms for the D Programming Language by mhh__ on Friday February 12, 2021 @01:05PM (#26116566)
D 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.