mathrick: but
it's just not very true, if you
look past the rhetoric and expectations that everything
works like Java. I wouldn't mind if it was funny, but the
humour's uninspired too. Complaining that RAII forces you
to use
"smart pointers" (the derogatory quotes are his) but that
built-in pointers
aren't smart is
fatuous, and the focus on smart pointers that manage memory
(rather than, say,
scoped mutex locks, or commit/rollback-style transactions)
betrays his
poor understanding of the idiom. C++ allows management of
any resource
using RAII-style library types. Java allows management of
memory resources using builtin GC but has no automatic
management of other resources. Personally I prefer general
library solutions for any type of resource to builtin ones
that only work with memory, but that's just a preference and
I wouldn't expend so much energy comparing apples and
oranges. The author
implies
that
non-memory resources are rare anyway, giving files as an
example. I wonder what the author writes if he doesn't need
to use mutexes, database handles, sockets etc. let alone
"non-system" resources. I'm currently using RAII to manage
login sessions with a futures
exchange, so that I know it will logout correctly
when the session object goes out of scope, rather than just
dropping the connection. Conflating RAII
solely with memory management and then comparing it to
garbage collected memory is a strawman.