C++ pattern matching is coming

German Diago germandiago at gmail.com
Wed Oct 26 10:51:03 UTC 2022


On Wednesday, 26 October 2022 at 00:53:26 UTC, zjh wrote:
> On Tuesday, 25 October 2022 at 17:34:10 UTC, Alexandru Ermicioi 
> wrote:

> It also has some functions and convenience that `D` does not 
> provide.

Besides concepts, what are those exactly? D metaprogramming is 
ahead of C++'s and #embed, which goes into C23 and probably C++26 
is import("file") in D for years, modules are not there yet, D 
has had them for years. Overload resolution is easier to 
understand also in D. I do not see (from a language-level, not 
ecosystem, which is clearly behind) what is clearly worse from D 
compared to C++. CTFE is also there for years. C++ is just 
catching up on this.


> The same is true of `D`. `D` also has shortcomings, such as` 
> default` GC.

You have @nogc, not sure how well it works in practice. You lose 
slices to begin with as far as I understand, or most uses of 
them. That said, nothing would prevent you from having your own 
struct similar to `std::span` I think?

> `C++` has a large user base. Many people start learning 
> languages from `C++`.

True. I based most of my career around it.


> Because many of the latest things in `C++` are already in `D`.
> `D`,Being a `partner` language.
> It is best to use `'C++' and 'D'` at the same time.

Nothing prevents you from using it today in a "companion" mode. 
It is just that it is more than powerful enough to be an 
independent language as well IMHO. In my list, after years and 
years taking a look at Nim, Rust, Zig (C replacement more than 
C++) and others, I think the winner, with a little more ecosystem 
love, is D. The reason is because it is powerful, productive and 
has few surprises compared to C++ and there is a serious effort 
in code reuse coming from C/C++, which are, whether we like it or 
not, the kings of native.




More information about the Digitalmars-d mailing list