General statistics
List of Youtube channels
Youtube commenter search
Distinguished comments
About
Lawrence D’Oliveiro
Lex Fridman
comments
Comments by "Lawrence D’Oliveiro" (@lawrencedoliveiro9104) on "Bjarne Stroustrup: C++ Zero-Overhead Principle and Object-Oriented Programming" video.
Unfortunately, the “zero-overhead” principle has to be abandoned every time you try to do something actually useful with the language. Like anything involving dynamic memory allocation. Or the first time you discover that a “delete” method has to be explicitly declared virtual to avoid certain unpleasant surprises. Which means your class now has to have a vtable. And you wonder, don’t proper OO languages have tables for all their classes?
5
Given the myriad applications of dynamic memory, that must severely limit the kinds of applications you write. Consider that even text strings require dynamic memory, unless you impose arbitrary limits on the lengths of your buffers. Here is a discussion of how to manage dynamic memory: https://github.com/ldo/a_structured_discipline_of_programming
1
@IamusTheFox What else is “delete” for, if not dynamic memory?
1
But do they have zero overhead?
1
Because once you give up on the “zero-overhead” principle, most of C++ just becomes ... pointless.
1
I see C++, Java and C# as being on a spectrum of “semi-dynamic” languages. C++ tries to be static, but secretly it wants to be dynamic (virtual methods, RTTI). Java and C# are only grudgingly dynamic--look at how convoluted Java’s Reflection API is, for example. In all of them, the more dynamic the things you try to do, the more complicated it becomes.
1