Reddit: why aren't people using D?
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Thu Jul 23 09:14:25 PDT 2009
Rainer Deyke wrote:
> Walter Bright wrote:
>> Rainer Deyke wrote:
>>> The reason I have stuck with C++ despite its (massive, obvious) flaws is
>>> that it has a couple of really nice and useful features that very few
>>> other languages have even attempted to match. D is the only language I
>>> know that even tries, although it still falls short in many areas.
>> Fair enough. What are those two features?
>
> 1. C++'s object model, complete with polymorphic value types,
What designs make good use of polymorphic value types?
> deterministic destructors, arbitrary copy constructors, and optional
> lack of default constructor.
Struct have that except for default constructor. In D, currently default
constructors cannot execute code. This is a limitation that we might
need to address, although it has some advantages.
> D's structs come close, but I think the
> class/struct split hurts D more than it helps. And, yes, C++ has a lot
> of room for improvement here.
How does the class/struct split? I think it's an enormous source of
confusion for C++. C++ lore clarifies that you must decide in day one
whether a class is meant to be polymorphic or monomorphic. Unfortunately
that can't be expressed in the language, hence the weird cases with
deriving from std::vector or getting polymorphic values unceremoniously
sliced. Avoiding such mistakes are important things that C++ users must
learn because there's nothing in the language stopping them from doing
such nonsensical things; D very elegantly breaks that pattern by
defining the language to only allow meaningful constructs.
Who says the class/struct situation is worse off in D than in C++ either
doesn't know C++ or knows C++ too well.
Andrei
More information about the Digitalmars-d
mailing list