On Tuesday, 10 November 2020 at 01:00:50 UTC, Mark wrote:
Hi all,

Anyone have any thoughts how C++ and D compare?


C++ has a bit more mathematical feeling, everything has been sorted out in the spec, even if the rules are crazy difficult. D feels like it's up to _you_ to write the spec as you discover things in the compiler.

C++ code feels a bit more cast in stone than any other language, you can't move around things as quickly, and you won't be willing to. But as you wrote the lines slower, likely you were a bit more careful too as a side-effect.

If you write a small command-line tool, using D vs C++ will be appreciably more productive. Just std.process will speed up things by a lot, for this kind of work Phobos really shines. I don't think it makes the same difference for large projects.

Learning D is something that can be almost finished, whereas with C++ you have to aggressively conquer new features from the standard one by one, and unfortunately C++ evolves faster than you can assimilate C++. Generally when you meet a C++ programmer, you are meeting someone who has given up the hope to have a full understanding of the language and instead stay strategically on a useful, codebase-specific subset (eg: if you learn about std:unique_ptr, you can avoid to learn about most of move semantics so that's a good learning investment).

D lets you think more about your problem domain, and less about language things. Don't know precisely why. If you are deeply immersed in C++ everyday, you won't see that problem, but it's there. It's as if the culture of C++ was "complexity is free", there is little attempt to contain it.

And it shows in the small things, for example:
- D atomics (core.atomic) has 11 public functions and defined 5 memory models.
- C++ atomics <atomic> has 29 functions and 6 memory models.
It doesn't seem like much, but there is a bit _more of everything_ you can count.

All in all as a D replacement C++ seems a bit lacking, unless you want a particular domain-specific library that only exists in C++. I'm sure with a bit more effort, it could be a bit more attractive to the vast masses of D programmers.

Reply via email to