News for hackers. Stuff that matters.
Re:C++ the Good Parts (2014) by cjfd on Thursday October 01, 2020 @04:25AM (#24648698)
People are noticing below that some other languages may have RAII as well. I am quite willing to concede that some languages may have it. After all, it is rather hard to know all languages out there. But it also seems that people are a bit too eager to add languages to the list. If you either have to use 'using' or something like it it really does not count. My question would be whether you can do the HtmlElement example that I mentioned in my post. If you cannot, for instance, because the closing tag would be written whenever the garbage collector feels like it, it really does not count.
Re:C++ the Good Parts (2014) by ncmncm on Thursday October 01, 2020 @12:51PM (#24653219)
Yes, really only D and Rust, nothing else.

If you think other language X supports RAII, you don't really understand it. It's not really compatible with obligate-GC. Finalizers, in particular, are not it.

The thing about destructors is that reclaiming memory is only their most trivial use. In C++, as in D and Rust, and Haskell, too, catching errors is the type system's most trivial use. It does the heavy lifting.

If your program isn't putting the type system to work, you're toiling away with a screwdriver while people around you are using impact drivers and forklifts.

Re:C++ the Good Parts (2014) by int_19h on Thursday October 01, 2020 @06:05PM (#24656643)
It's perfectly compatible with GC. GC manages memory. RAII manages object lifetime. C++/CLI, for example, has full-fledged C++ RAII implemented on top of GC memory management.
Re:C++ the Good Parts (2014) by ncmncm on Friday October 02, 2020 @05:05PM (#24667022)
Fine, but having managed lifetime, it also manages memory, leaving nothing worthwhile for GC to do.