
Why hasn't D started to replace C++ - systems
https://www.quora.com/Why-hasnt-D-started-to-replace-C++?share=1
======
jstewartmobile
From what I'm seeing on GitHub, Rust has beaten it to the punch, mightily.

Levien's _Xi_ video today being yet another example.

edit: As for why, languages are more of a battleground than a substrate. If
you have a choice between Swift (Apple), Rust (Mozilla), Go (Google), or D
(Walter Bright), most people are going to flock to one of the bigger forces.

Golang is a kind-of underwhelming riff on Pascal, but I use it anyway for
network stuff. Why? Google has given it an instant ecosystem with plenty of
well tested libraries, docs, and howtos. Never underestimate the ecosystem.

~~~
flukus
In lieu of a mega corporation behind you, having a killer app to get people
interested seems valuable. Ruby would still be niche without rails for
instance, .net would have been an uninspiring java clone without MS RAD tools.
You can't just have a good language, you need to show the world that it can be
used to build good software.

~~~
jstewartmobile
I'm really impressed with the Clojure community. They have done a great job
sans-megacorp.

~~~
dropit_sphere
It helps to have a good language to attract those people.

------
Someone1234
I believe a related question to ask is: How many new projects are started in
that niche?

C still seems to spawn new software because people are working directly with
hardware and don't wish to code using straight assembly. I'm thinking computer
engineering related fields. Robotics for example.

C++ falls into an uncanny valley, it is neither high level language with all
of the benefits (e.g. programmer efficiency, certain security guarantees,
lower barrier to entry) or a completely low level language (or at least it
isn't if you want to benefit from most of C++'s advantages over straight C;
you'll avoid a garbage collector but not a lot of "magic" behind the scenes).

C++ carved out a space with 3D gaming for a while but with many development
houses moving to licensed game engines or targeting mobile platforms C++'s
benefit may be waning.

The data does support this supposition[0].

[0] [https://www.tiobe.com/tiobe-
index/cplusplus/](https://www.tiobe.com/tiobe-index/cplusplus/)

~~~
bitL
Advanced robotics is utterly dominated by C++.

~~~
fooker
Advanced everything is utterly dominated by C++.

~~~
AstralStorm
Not lower bit microcontroller programming which is still dominated by C.
(Because C++ compilers do not exist or produce worse code.)

~~~
fooker
>Because C++ compilers do not exist or produce worse code.

I am surprised this is still true in 2018. GCC and Clang on x86 with -fno-rtti
and -fno-exceptions produce almost identical code for similar programs in C
and C++.

If what you say is true, I suppose there aren't enough compiler devs paid to
optimize C++ for those platforms.

~~~
pjmlp
GCC and Clang are not even a thing in most microcontrollers.

You buy the compiler from the same vendor that is selling you the hardware.

Even if it is based on gcc, it happens to be a fork with changes they don't
easily release. Some of them are now transitioning to clang, because the
license makes it easier to keep doing so.

Many of them are still mostly C89 (not 100% ANSI C compliant due to hardware
limitations) with a few C99 features.

------
systems
i think the best hope for D is not to replace any language, or dominate any
domain

but to be a player

there will always be systems written in different languages for different
reasons, or for small advantages of one language over the other

there is a place for C# and Java , a place for rust and go, a place for F# and
Clojure, a place for Pythong and Tcl/Tk, etc ..

D from the little i know of it, is a nice language, I dont think it will ever
dominate anything or replace anything .. but it definitely has a place .. or
deserves to have a place

------
aey
It was closed source when it was gaining mindshare. So they missed the boat

------
person77
Cpp was my first language. It seems like I choose languages based upon the
project, and it along with Java or JS or python tend to be what's needed for
my interests. I guess to me it is simply a tool. So if some killer tech
preferred D, then I would pick it up probably. I do avoid many Cpp features, I
am just working with a subset usually, for better or worse.

------
megaman22
D looked cool when I was struggling to learn C++, and got a little bit of buzz
on some sites I was active on, like gamedev.net. That was 12-15 years ago.

I'm just not sure that middle ground between C++ and Java/C# is terribly
compelling, and has also been swamped by later entries like Rust, Swift, and
Go, which additionally have major backers.

------
dpc_pw
GC, no bigger-player backing, backend was propriety for a long while, and till
fairly recently it wasn't a community project, but a one-man work.

D is generally a much better Go (especially if you add fibres to it), but it
doesn't have Google-brand behind it, so Go ate it's lunch in distributed
systems space, while Rust is much better suited to be a serious competition to
C++.

~~~
soulbadguy
> Rust is much better suited to be a serious competition

why ?

~~~
kbart
Performance and memory control -- these are the main reasons why people choose
C/C++ nowadays and Rust tries to fit in as well. D, as stated in article, is
more of Java competitor than C++, because it's slow and use GC.

~~~
WalterBright
If you use LDC or GDC, the code generation for D is the same as for C and C++,
if the code is written the same way.

The code generation for DMD has fallen a bit behind, mostly because I spend my
time on other issues these days :-(

------
icholy
It's not a big enough improvement over C++ to warrant switching.

------
harry8
legal D:

    
    
        if(foo)
            bar();
            baz();
    

A language design bug copied from C. A feature that is good only to add a
class of bugs to programs in your language with zero benfit. Perl wasn't
tasteless enough to copy that. D designers were, does that convince you they
have the right taste to design your _systems_ language?

Alexandrescou is exactly the kind of C++ person D is designed for (and now
by). Is the code more important or the data transformation being performed by
that code? Garbage collection, same as golang with the same perception that
it's a replacement for java/python/ruby/perl not C nor C++ - this will be the
perception and they will say "yeah but ..." sure, but that perception is not
devoid of merit. "You don't need ..." nup, as an engineer I decide that, I
don't want it imposed.

Low level access to raw hardware, zero cost convenient abstractions, no
runtime cost imposed by the language, consistent, easy to get right (or at
least harder to get wrong, less gotchas). Whatever replaces C & C++ will tick
those boxes unless hardware changes dramatically. People believe that D
doesn't.

Then there's just practical stuff like using facebook's linter - well you
can't, it just doesn't work.
[https://github.com/facebookarchive/flint](https://github.com/facebookarchive/flint)
Is the D version even there? Too hard, too alpha, the overhead of a new
language needs more to sell it. I haven't yet programmed a line of Rust or Go
but both look more compelling.

------
nitwit005
Because everyone who could make that change already switched to Java, Python,
and other options instead.

------
potbelly83
Serious question, if you were going to replace C++, why choose D over
something like Ada?

~~~
p0nce
Without going into the language details: it seems there is only one open-
source free compiler for Ada, while there are three for D.

------
bitL
Facebook uses D internally.

------
dingo_bat
Most times the reason people switch from thing A to thing B is because they
have a problem with A. Nobody has a problem with C++. Talk to any C++ dev,
they love their job.

~~~
jstewartmobile
A long time ago, I did C++ dev for about 5 years. _Absolutely hated it._ Part
of that could have been that it was C++ for Windows, but even so...

Slow compile times, a sea of compiler options, pragmas, swamps of macros and
templates, and the complete lack of understanding among coworkers of OO
concepts like virtual functions or inheritance.

Can totally sympathize with Linus' contempt for C++.

edit: Notice _dingo_bat_ is getting downvoted on this. How about responding
with why _you_ dislike C++ instead of the downvote?

~~~
abcd_f
If you use C++ as "C with Classes", it is a _fantastic_ C replacement.

Just stick to 'struct's instead of 'class'es, use ctor/dtor for RAII, pure
virtual functions to declare interfaces and single-level inheritance to
implement them and, perhaps, an occasional template to replace a macro - and
you still basically have C, but it's now far less verbose and more pleasant to
use.

~~~
jstewartmobile
Fair enough, but how many train wrecks did you have to witness to come to that
conclusion?

~~~
abcd_f
Hehe... in my case there was some oscillation between C and C++ before
eventually converging to C-style C++. To each his own. I even heard of people
who thought Boost was a good thing, but I suspect someone was making a joke.

~~~
AstralStorm
Boost is being surpassed by new standards though. Most of the truly and widely
useful stuff from boost is being reimplemented in a much cleaner way for
standard library. It can be considered proving ground.

------
grawprog
I like D. I learned all the things in D I could never really understand when I
tried to learn about them in C and C++. Things like pointers, structs, unions
the different sizes of types and other things. It's the first language that
really made me appreciate why static typing and memory management are useful
and why you can do things in a lower level language you can't do in a higher
level one. But i also found the syntax fairly easy to pick up, I could never
really wrap my head around C++'s weirdness, and my little bit of C knowledge
made it fairly easy to begin learning more complicated aspects of the
language. I have to admit some parts of it confuse me a bit. I still don't
fully understand Templates and ranges but i've used them a little bit and can
see why they're useful. I like the dub build system and code repository and
definitely prefer imports to #include.

As far as a lack of ide's goes. There isn't many. I like dlang ide. It has
everything I need, though it can be kind of buggy. I also don't mind Vim with
dlang plugins. But I don't think they can compare to large established ides
for other languages.

I can also understand why it doesn't really pick up for large projects the way
c++ is.

There isn't much in the way of libraries, there is no tutorials or help aimed
towards beginner programmers, which is too bad because I think D is way better
for beginners than Java or C, it teaches the same important concepts as both
languages while providing a fairly strict compile time checking and a far less
ridiculous syntax than java. With the option to not have to learn OOP stuff
until you understand basic programming. It also makes it a lot harder to shoot
yourself in the face the way C does.

The standard library docs and most other documentation I've seen for D is
fairly technical and not very inviting even for non beginners. Most libraries
have little to no documentation and many haven't been maintained.

The only real, understandable learning resource I could find is:

[http://ddili.org/ders/d.en/](http://ddili.org/ders/d.en/)

Which is a great book, but also nearly the only readily available one to learn
from.

It is too bad because there are definitely lots of benefits to C++ it's just
they're not quite worth the tradeoffs.

~~~
earenndil
> I think D is way better for beginners than Java or C

I love D but tbh I disagree. I think an optimal-ish progression for learning
programming languages is:

Python (basic programming&computer knowledge, algorithms) -> C (low-level
knowledge) -> ASM (optional, only if you want to learn extra low level
knowledge) -> C++ or Java (to learn modern OOP concepts. D's are a bit too
complex and the error messages aren't as good and thus off-putting to a
beginner) -> D (amazeballs metaprogramming) -> LISP (amazeballs
metaprogramming and FP)

Neither C, D, nor Java should be beginner languages. They're too big and
fancy. (To be fair, python does this too, but it does a bit better job of
hiding it, and exposes an api that can be leveraged to teach people
programming even if they don't understand how it works.)

~~~
pjmlp
C should never be learned on the path of being a good, programming safe
conscious C++ programmer.

CppCon 2015: Kate Gregory “Stop Teaching C"

[https://www.youtube.com/watch?v=YnWhqhNdYyk](https://www.youtube.com/watch?v=YnWhqhNdYyk)

~~~
earenndil
C should _ALWAYS_ be learned on the path of being a good, programming safe
conscious programmer of _ANY_ language. Otherwise you will not understand the
underlying machine.

~~~
pjmlp
C is not the only way to understand the underlying machine, plenty of
languages offer similar features.

Plus being a subset of C++, there is hardly any value in learning C as such,
instead of good C++ idioms.

In fact, my university already in the mid-90's never teached C, only C++ with
a professor that was insightfull to have its own set of type safe
abstractions, the usual array/string/containers set, while teaching us about
RAII, years before C++98 and STL were a standard.

There were system programming assignments in C, it was expected that any
student would be able to think and know how to apply C++'s C subset for the
assignment.

~~~
earenndil
> Plus being a subset of C++, there is hardly any value in learning C as such,
> instead of good C++ idioms

To say this is to miss the point entirely. A machine runs not C++, but C. To
learn how to use, e.g., std::vector (to cite a random example) is to learn a
high-level programming concept which could be learned in _any_ language but
not to learn how the machine works. To learn how to use a char* in c++ is a
complete waste and not different from learning how to use a char* in c.

~~~
pjmlp
No, you are the one missing the point.

CPUs don't run C, and unless we are speaking about a PDP-11, the ANSI C
abstract machine surely doesn't expose how this mobile phone CPU/GPGPU works.

When I want people to actually know how computers work, I teach them Assembly.

C isn't a special snowflake in the realm of systems programming languages,
there are plenty of languages, some even older than C with the same low level
capabilities.

Had AT&T been allowed to sell UNIX at the same price the as other OS vendors
were selling their products instead of giving it almost for free to US
universities, we wouldn't be talking about C nowadays, and probably also not
about C++.

~~~
earenndil
> C isn't a special snowflake in the realm of systems programming languages,
> there are plenty of languages

That's just not true. You see something like assembly, which seems so low-
level and implementation-focused, and then you see java with all its high-
level complexity and it seems like it's _fundamentally something different_. C
bridges that gap, because you can see all the ways in which it's exactly the
same as assembly, yet all the ways in which it's exactly the same as java. If
you truely want to understand a computer on every level from silicon to state-
machines (idk, it was the first thing that came to mind), C belongs on that
stack.

What makes c special is not its capabilities, but rather its lack of
abstraction.

