14 ms·
Personally/Syntactically I've found that coding in D is much pleasant than C++. Consistent '.' operator for the equivalent '.' '->' '::' in C++, template meta p
by arunc 8y ago
Personally/Syntactically I've found that coding in D is much pleasant than C++. Consistent '.' operator for the equivalent '.' '->' '::' in C++, template meta programming for humans, modules, UFCS, etc, etc.
But a killer feature that's available in C++, but not available in D is pure RAII idiom. Sure D does scoped destruction (via struct's destructor), but is in no way equal to the contructor+destructor combination in C++. struct's in D don't have default constructor, so RAII in D is just incomplete.
Automem[1] is a boon for D, but is useful only for heap memory resource. Not for all kinds of resources (like locks, etc).
On the other hand D has scope exit/failure, which is not available in C++.
[1] https://dlang.org/blog/2017/04/28/automem-hands-free-raii-for-d/ https://dlang.org/blog/2017/04/28/automem-hands-free-raii-fo...
- FeepingCreature 8y agoYou can disable the default constructor on structs with @disable this(); Then the only proper way to initialize the struct is with its parameterized constructor.