3 ms·
I'm not sure I fully understand the question. RAII is powerful, but it is just a tool to organize what is still manual resource management. it can help with mem
by leetcrew 5y ago
I'm not sure I fully understand the question. RAII is powerful, but it is just a tool to organize what is still manual resource management. it can help with memory/thread safety, but it doesn't guarantee those things by itself. ex: it's nice that std::vector's memory buffer will be freed when the object goes out of scope, but I can still do something stupid like hold onto to its .data() pointer and try to dereference later.
to answer the more general question, I think most engineers would prefer to refactor a c++ project over rewriting the whole thing in rust, and rightly so. you usually don't want to fuck around with delicate things that currently work in these sorts of projects. perhaps over time you end up with an FFI layer over a thoroughly tested c++ core. then new features can be written in rust or whatever friendly language is popular at the time.
- rileymat2 5y agoOne quibble one of the best uses for RAII is not memory management but any external resource like db connections or file handles or mutexes. The built in smart pointers take care of much of memory management. (Although they use RAII internally)
- ducharmdev 5y agoI appreciate the clarification, my understanding of this stuff is pretty superficial. Putting it that way, I can see why someone would appreciate that Rust guarantees safety by default, instead requiring you to opt-out explicitly when needed (with `unsafe`), versus the opt-in nature of RAII - for greenfield projects, anyway.