Article: Alternatives to C++

Ali Çehreli acehreli at yahoo.com
Mon Mar 8 21:00:47 UTC 2021


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. Here is the story why I 
thought C++ programmers may have that objection:

I co-organized and attended a presentation by Sean Parent at the Silicon 
Valley Chapter of the ACCU. Sean Parent lists multiple "ACCU" 
presentations below, so I can't be sure exactly which one that was:

   https://sean-parent.stlab.cc/papers-and-presentations/

I remember Andrei Alexandrescu and other C++ people were in the audience 
as well.

I may not remember this accurately but final slides of Sean Parent's 
presentation included his ambitions on writing a framework where he was 
hoping to be able to define the transitions of the code beforehand like 
state transitions. That made sense considering the first part of his 
presentation where he was advocating removing explicit language 
constructs like loops from the code. (This idea has been popularized by 
his famous "that's rotate" words, which has been referenced by other 
presenters as well.)

Seeing how difficult his ambitions would be achievable in C++ of that 
time, I approached him at the end of the presentation and said "Have you 
considered D? Because what you're trying to do...". I couldn't finish my 
sentence because he said "A language with reference types? No thanks!" 
while using a hand gesture that looked like "brushing away", and walked 
away.

Looking back after all these years, I think his objection might have 
been to garbage collectors. I don't know. But I never forgot that 
interaction and used that point in multiple presentations that C++ 
indeed has reference types of the worst kind: by programmer education 
through guidelines. D wins over C++ here as well by providing both 
reference types and value types. My only regret is the space cost of the 
monitor pointer of all D class objects. So, I hereby help populatize 
something I learned recently: extern(C++) class definitions don't have 
that monitor pointer:

// Smaller object:
extern (C++) class C {
   // ...
}

Anyway... This is the first time I told that story publicly. :)

Ali



More information about the Digitalmars-d mailing list