On Thursday, 28 January 2016 at 22:30:51 UTC, nbro wrote:
I have loved C++ when I first started learning it a pair of
years ago (then I stopped for some time for some work reasons),
and quite recently I have discovered D, which seems apparently
a better language from the design point of view, especially in
supporting OO design and modularisation, maybe I am just wrong
since I know just a little of D so far, but I really had some
problems just in setting up a simple OO project, i.e. importing
classes, there are .h and .cpp files, etc, which only make
everything confusing and make you learn stupid things instead
of being productive. D also seems to have a cleaner syntax in
general. C++ is becoming more and more a mess because they keep
introducing new functionalities to make C++ compete with new
languages, and I'm starting hating it. Languages should not
just be powerful but simple enough to be productive.
Apart from this, what are the real advantages of D over Rust?
In my uninformed opinion (I've not used Rust more than "hello
world").
For D:
- no strong feelings against D syntax, it's rare that people
complain about it. Rust syntax is more controversial. This
shouldn't matter, but it does.
- D "duck-typed" meta-programming could well be more applicable
than traits-based meta-programming. Need less names and
complexity.
- using "unsafe", Rust isn't particularly more memory-safe than
the @safe D subset. Which by and large native programmers don't
even care that much. Top concerns with C++ would be compilation
times or build complexity. D kills most memory safety concerns
throught bounds check, slices or default initialization.
- Rust error handling doesn't strike me as working at scale. We
are already seeing "You should not do .unwrap() in a library"
advices from Rust experts. Yet .unwrap() seems to creep
everywhere which conflates input errors and logical bugs.
- D has defaults that let you write ugly code. I think it's a
positive. Why should you care about memory safety or immutability
for a 50 line program? Cost vs benefit. You can always enforce
later, but you don't get your time back.
For Rust:
- Rust has a simpler resource story. Using it is similar to using
modern C++ correctly, hence the appeal for many C++ers who feel
at home conceptually.
- cargo is a bit friendlier than DUB, and less controversial in
its community (which is imho generational, seeing like C++
package managers are even more controversial). Maybe the package
manager / build tool is the primary interest of Rust and D over
C++.
- You can do composed RAII in D but using (GC + linear types) is
more complex than using linear types.
- D is a large language, not sure how much relatively to Rust.
I've heard Rust is complicated too.