Bjarne Stroustrup: Constructors, Destructors, and Resource Acquisition Is Initialization (RAII)
LlZWqkCMdfk • 2019-11-08
Transcript preview
Open
Kind: captions Language: en there's a lot of features that came in in C++ 11 there's a lot of features at the birth of C++ they were amazing and ideas with concepts in 2020 what to you is the most justjust to you personally beautiful or just you sit back and think wow that's just nice and clean feature of C++ I have written two papers for the history of programming languages conference which basically asked me such questions and I'm writing a third one which I will deliver at the history of programming languages conference in London next year so I've been thinking about that and there is one play answer constructors and destructors the way a constructor can establish the environment for the use of the Java type for an object and the destructor that cleans up any messes at the end of it that is the key to C++ that's why we don't have to use garbage collection that's how we can get predictable performance that's how you can get the minimal overhead in many many cases and have really clean types it's the idea of constructor destructor pairs sometimes it comes out under the name our high a III resource acquisition is initialization which is the idea that you grab resources and the constructor and release them and destructor it's also the best example of why I shouldn't be in advertising I get the best idea and I call it resource acquisition is initialization not the greatest naming I've ever heard so it's types abstraction of types you said I want to create my own types so types is an essential part of C++ in making them is the if it is the key part and GU the this is almost getting philosophical but the construction and the destruction the creation of an instance of a type and the freeing of resources from that instance of a type is what defines the object is uh that's a little is like birth and death is what defines human life yeah that's right by the way philosophy is important you can't do good language design without philosophy because what you are determining is what people can express and how this is very important by the way constructors destructors came into C++ in 79 in about the second week of my work with what was then Corsi the classes it is a fundamental idea next comes the fact that you need to control copying because once you control as you says birth and death you have to control taking coffees which is another way of creating an object and finally you have to be able to move things around so you get the move operations and that's the set of key operations you can define on a C++ type inserts you those things are just a beautiful part of C++ that is at the core of it all yes you
Resume
Categories