It is the year 2020: why should I use / learn D?
Atila Neves
atila.neves at gmail.com
Fri Nov 16 13:10:19 UTC 2018
On Wednesday, 14 November 2018 at 15:07:46 UTC, lagfra wrote:
> https://www.reddit.com/r/cpp/comments/9vwvbz/2018_san_diego_iso_c_committee_trip_report_ranges/
>
> By 2020 C++ is planning to introduce:
>
> * Ranges
> * Contracts
> * Concepts (`__traits`)
> * Proper constexpr
> * Modules
> * Reflections
> * Green threads
>
> Right now it already has:
>
> * `auto` variables
> * Ranged for (`foreach`)
> * Lambda expressions and closures
> * `nothrow` attributes
> * Proper containers
> * Proper RAII
>
> In no way this is the usual trollpost (I am a participant of
> SAoC). What bugs me is the shortening distance regarding what D
> has to offer with respect to C++. While D for sure has a way
> better syntax (thinking of template declarations, `immutable`,
> UDAs) and a GC, what are the advantages of using D vs C++ if my
> goal is to build a complex system / product?
>
> TL;DR: what will D offer with respect to C++ when almost all
> key features of D are present in C++20(+)?
Even if they're present in C++20 or later, they might not work
the same or be as good. C++17 has `if constexpr`, but it's not as
good as `static if`.
Having used most of the modern C++ features and writing D daily,
here's my personal opinions of why D is still / will still be
better:
* The GC. It's just easier to write safe code by default.
* DIP1000
* auto is easier to use in D (no need for `const auto` or `static
auto`, or...
* Compile-time reflection. Whatever C++ gets is likely to be
worse, because of:
* string mixins
* Lambdas are harder to use in C++ and have lifetime issues with
captures by reference
* Headers / modules.
* UFCS and chains, even though the new C++ ranges will mitigate
this
* Sane template metaprogramming, but void_t is nice
* Syntax for slices
Is writing C++17 much better than C++03? Indubitably. Is it as
nice as writing D? In my opinion, no - I'm 2x to 3x more
productive to begin with in D and end up writing fewer bugs.
D is still rough around the edges when it comes to implementation
quality. I've never had C++ projects break due to a compiler
update, nor have I ever filed a clang or gcc bug. CMake is
horrible but I can get the job done, whereas I have to work
around dub all the time. Right now my main source of cortisol is
the ridiculously long edit-test cycle, but I'm working on
something to make that part of my work life a lot happier.
More information about the Digitalmars-d
mailing list