by jcelerier · 5y ago · 0 comments
but at a pretty large cost : now everything has to be boxed, will be dynamically allocated by default (yes, object pools and small-size optimization, but that does not produce very readable code and needs constant care), you risk slicing, every access has an indirection, etc.
Migrating some C++ code from OOP inheritance to variant-like stack-allocated value types has always resulted in n-fold improvements to runtime performance in my case.
The article makes clear that it is speaking of compiler intermediate representations. Those are pretty much by definition boxed, linked data structures that live on the heap.
> Migrating some C++ code from OOP inheritance to variant-like stack-allocated value types has always resulted in n-fold improvements to runtime performance in my case.
Was this in the context of processing some form of programming language IR?
The OO features were added because at the time it was the raging fad and people thought that every language simply must have "OOP".
But "OOP" was never a foundational principle for C++, more like a tacked-on sidecar.
a) 'Simula style' isn't at all like the Smalltalk-derived programming patterns we call 'OOP'. (Simula was about actor-oriented programming anyways, hence the name.)
b) The unique differentiator for C++ was the STL, and not the OOP features that were done better and cleaner in other languages.
c) The killer feature for early C++ adoption was operator overloading, not inheritance. (Pretty much nobody liked using inheritance in C++ even back in the day.)
> add classes to C
C is the foundation. Classes is the sidecar.