C++ Move Semantics Considered Harmful (Rust Is Better)
The author&#x27;s examples are contrived.<p>First, they do gratuitous allocation (e.g. `char* foo = strdup (&quot;Hi&quot;);` followed by explaining that they have to allocate again because of their use of *foo.  No need for the first copy and nobody would write the code that way.<p>Second they seem not to realize you can allocate straight into your destination memory (i.e. &#x27;emplace&#x27;).  So again, they are complaining about something nobody would ever do.<p>Then they make assertions about runtime behavior of C++ code that could easily be disproven by simply looking at what the compiler does!  The C++ compiler can perform optimizations Rust cannot (perhaps can in the future) such as allocating directly into the caller&#x27;s stack frame so that the &quot;move&quot; never happens at runtime at all!<p>I stopped reading at this point.  It&#x27;s a shame, as the author also refers to legitimate issues with C++&#x27;s memory model (e.g. a reference can point to invalid memory in certain multithreaded code) which are partially mitigated by Rust&#x27;s memory model.<p>Rust has its strengths and weaknesses vs C++, but this article doesn&#x27;t appear to really get to them.