2 ms·
We all know the acronym stands for "Resource Allocation Is Initialization" - and that in the real world the two often have no reason to be semantically coupled.
by fulafel 7y ago
We all know the acronym stands for "Resource Allocation Is Initialization" - and that in the real world the two often have no reason to be semantically coupled. IOW lots of optimization patterns involve decoupling initialization from allocation and the RAII meme encourages programmers to codify the coupling because C++'s shortcomings make it attractive.
- verall 7y agoThat is what RAII stands for, but in practice good use of C++ RAII is all about explicitly separating interface, allocation, and ownership, such that you only pay for as much initialization as you need when you need it. This takes great care which takes time and leads to slow development. I think of C++ as worth it when this level of care is necessary to create a well-performing system. I would agree that most toy examples don't do a good job of explaining how to use RAII in a careful high performing way