Article: Alternatives to C++

tsbockman thomas.bockman at gmail.com
Mon Mar 8 21:22:24 UTC 2021


On Monday, 8 March 2021 at 21:00:47 UTC, Ali Çehreli wrote:
> On 3/8/21 10:31 AM, Istvan Dobos wrote:
>
> > https://caiorss.github.io/C-Cpp-Notes/cpp-alternatives.html
> >
> > Some good ol' C++ bashing. I found this interesting: if a
> polymorphic
> > type gets passed by value, it loses its polymorphism. I
> haven't seen it
> > spelled out like this before, but makes sense. Why mentioning
> it
> > specifically though?
>
> I may be responsible for that specific poing because the 
> article lists my C++Now 2017 presentation as a reference where 
> I mentioned reference types as a D objection at this moment in 
> the presentation:
>
>   https://youtu.be/vYEKEIpM2zo?t=3084
>
> I remember Atila and others being surprised that I thought 
> reference types were a D objection of C++ programmers.

As someone who is trying to write a reference counting system at 
the moment, reference types are a massive pain.

Class instances exist, and are semantically entirely distinct 
entities from the references to them. Being forbidden to name or 
otherwise represent the type of a class instance, and therefore 
forbidden to introspect it properly, sucks. Having to 
special-case classes and interfaces everywhere, because they are 
accessed at a different level of indirection, sucks.

D's powerful meta-programming capabilities allow me to work 
around most of these issues, but I shouldn't have to. Passing 
class instances by reference is a best practice that applies most 
of the time, not a fundamental truth that should be enforced by 
the language.


More information about the Digitalmars-d mailing list