rbowman wrote this post while blinking in Morse code:
On Tue, 31 Dec 2024 19:34:41 -0500, DFS wrote:
This is a Feeb classic:
"C requires brains and intelligence. C++ doesn't."
Who says stupid shit like that?
Obviously not anyone who has tried to use C++. Caveat: my C++ fu is
severely out of date. It may have gotten better when I wasn't looking.
Both languages require care and diligence, and an intuitive understanding of their memory models (which overlap a bit).
All languages do.
I've spend decades working with C and C++, and am very comfortable with them.
I still google or read up on various solutions, just to be sure I've got the best or newest solution in mind.
This is one of the most important benefits of C++:
https://en.cppreference.com/w/cpp/language/raii
Resource Acquisition Is Initialization or RAII, is a C++ programming
technique which binds the life cycle of a resource that must be acquired
before use (allocated heap memory, thread of execution, open socket, open
file, locked mutex, disk space, database connection—anything that exists in
limited supply) to the lifetime of an object.
RAII guarantees that the resource is available to any function that may
access the object (resource availability is a class invariant, eliminating
redundant runtime tests). It also guarantees that all resources are
released when the lifetime of their controlling object ends, in reverse
order of acquisition. Likewise, if resource acquisition fails (the
constructor exits with an exception), all resources acquired by every
fully-constructed member and base subobject are released in reverse order
of initialization. This leverages the core language features (object
lifetime, scope exit, order of initialization and stack unwinding) to
eliminate resource leaks and guarantee exception safety. Another name for
this technique is Scope-Bound Resource Management (SBRM), after the basic
use case where the lifetime of an RAII object ends due to scope exit.
--
As long as there are entrenched social and political distinctions
between sexes, races or classes, there will be forms of science whose
main function is to rationalize and legitimize these distinctions.
-- Elizabeth Fee
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)