It is the year 2020: why should I use / learn D?

H. S. Teoh hsteoh at quickfur.ath.cx
Wed Nov 14 23:58:15 UTC 2018


On Wed, Nov 14, 2018 at 03:25:07PM -0800, Walter Bright via Digitalmars-d wrote:
[...]
> C++ is adding lots of new features. But the trouble is, the old
> features remain, and people will still use them, and suffer.

To be fair, the same could be said of D too.  E.g., will autodecoding
ever be deprecated?  I seriously doubt it, even though it's a
significant performance problem. And it's default behaviour, so
newcomers will suffer.  Just like in C++ it's *possible* to write in a
way that avoids the problems of old features, but newcomers still use
old features because they're still there, and usually are what you get
when you write code in the most straightforward way (i.e., it's "default
behaviour").

Will C integer promotion rules ever be replaced?  Probably never.
Treating 'bool' as a non-integral type has already been rejected, in
spite of multiple cases of counterintuitive behaviour when resolving
overloads.  Similarly for char/int interconversions, even though the
whole point of having separate char/wchar/dchar types is to *not* treat
UTF encoding units as mere numerical values.

Similarly with many other features and language changes that would have
benefitted D, but will probably never happen because of the almost
paranoid fear of breaking existing code, which isn't all that different
from C++'s backward-compatibility mantra.


> Examples:
> 
> 1. The preprocessor remains. There has never been a concerted effort
> to find replacements for it, then deprecate it. It's like allowing
> horse-drawn carts on the road.

Has there been a concerted effort to find a way to migrate existing D
codebases away from autodecoding so that it can be eventually removed?


> 2. Strings are still 0-terminated. This is a performance problem,
> memory consumption problem, and is fundamentally memory unsafe.
> 
> 3. Arrays still decay to pointers, losing all bounds information.
> 
> 4. `char` is still optionally signed. What a lurking disaster that is.
> 
> 5. What size is an `int`?

All good points, except for one fly in the ointment: 'real'. :-D  The
only D type with variable size, it's also a hidden performance degrader
(significantly slower on new hardware because x87 hardware hasn't been
updated for decades whereas IEEE standard floats like float/double have
seen continuous improvement in hardware support over the last decade).
Especially when where code carefully crafted to use only float/double
still get implicit conversion to/from real when calling certain
functions in std.math, causing significant performance degradation.


Not saying that D isn't superior to C++ in many ways (if it wasn't, I
wouldn't be here), but one ought to be careful not to end up being the
proverbial pot calling kettle black.


T

-- 
It is of the new things that men tire --- of fashions and proposals and improvements and change. It is the old things that startle and intoxicate. It is the old things that are young. -- G.K. Chesterton


More information about the Digitalmars-d mailing list