3 ms·
It comes from C++ where memory being "initialized" to a particular type has a very specific meaning in the language: when a constructor is called on a memory lo
by Diggsey 4y ago
It comes from C++ where memory being "initialized" to a particular type has a very specific meaning in the language: when a constructor is called on a memory location, it becomes intialized to the type of that constructor, and the reverse when the destructor is called.
"Resource Acquisition Is Initialization". ie. You cannot separate the acquisition of the resource from the initialization of the type (and by implication, you cannot separate the release of the resource from the destruction of the type).
The language already required that initialization/deinitialization is correctly paired for all programs, so RAII was a way to take that guarantee and use it to manage resources as well. And since for local variables it is the compiler itself that upholds the guarantee, the compiler can also ensure resources are acquired/freed correctly.
Without that specific context, the name is poor, but C++ popularized the concept and its name, and once a specific technical name for something exists it's a good idea to continue to use it so as to avoid ambiguity when communicating, even after the originating context is lost.