top | item 31752423

(no title)

yesseri | 3 years ago

What makes it a better language than C and Rust? What is unique about it?

discuss

order

mhh__|3 years ago

Lack of bullshit in the source file.

Unlike some D programmers I don't mind rust but compared to C and C++ the primary difference I'd say is that D has a lot of features that you'd have to emulate with either macros or recursive templates that means that the source files end up much cleaner.

If you want to declare a struct with N members where N is declared at compile time, in C++ it's usually a question of doing a bunch of compile time magic that leaves a roadside picnic of SFINAE everywhere whereas in D it's just a "static foreach" loop inside a template.

cyber_kinetist|3 years ago

Out of all the new shiny low-level languages, people seem to praise its strong compile-time metaprogramming facilities. Though the compile-time execution engine in D is still a tree-walk interpreter (very bad performance/memory usage), unlike in Nim and Jai where they use a much faster bytecode interpreter for the evaluation.

destructionator|3 years ago

The compile time execution itself is just one piece of the puzzle, the other two being compile time reflection (which I think is actually the key piece) and the built in code generation.

Running functions alone is not that interesting, and neither really is generating code. You can do those (arguably better for some cases) with helper programs as a separate build step. But reflection is non-trivial to do externally, so that's the biggest value add, and using it with all three pieces let you close the loop.