Show Navigation
Conversation
Notices
-
In a way the elegance of C++ is that by making explicit the handling of the most common resource type - memory - it forces resource lifetime to be a primary concern of programmers which through the developed idioms (RAII) helps a lot with resources that are less visible but also important (e.g. file descriptors, mutexes). Compare this to the approach taken by C# and Python where you have to actively declare a block scope for the lifetime of a resource (using in C# / with in Python) and if you forget to do that the resource does not get deallocated. So instead of having memory be the special case as with a garbage collector C++ applies the same logic (lifetime of a resource is tied to the lifetime of an object) to all resources.