C++ has semi-official Core Guidelines issued by prominent members of the ISO-WG21 standard committee, that describe how to express these things idiomatically. Of course Rust can actually check these things automatically and achieve something close to actual memory safety, but there are ways to at least make a meaningful effort in C++.
Yes you can make a meaningful effort in C++, but one of the great benefits of Rust is that effort is handled by the compiler instead.
One of the things that struck me as a major advantage about Java and garbage collected languages is that you can simply combine code from different libraries without worrying about what's freeing the objects, because that's the GC's job. With Rust, the memory management model takes over this responsibility without runtime cost (or minimal cost -- perhaps freeing something from the heap, if you allocated it there, but definitely not GC).
With C++, unless the library that you're using is using the same smart point library as you, from the same language version, then aren't you stuck writing wrappers around the libs you want to use?
Types like std::async seem to have changed in every recent revision of C++ version (11, 17, 20). Can you reliably find multiple open source libraries that you could integrate into a codebase that uses futures and async/await?
(It's been a long time since I've done much C++ professionally. I'm asking skeptically but genuinely.)
I can spend all my development budget on the problem instead sacrificing part of it to building an ecosystem.
I'd imagine that we're at most 3 years away from it having mature libraries for 99% of tasks you'd want to do as a professional developer.
Some of those companies, like Google, Microsoft and NVidia, are heavily invested into C++, ISO C++ and selling C++ based products.
To use a common example that one puts against any technology that Microsoft touches, when will Office use Rust on its foundation and extension APIs?
Are you aware that Apple has rather created their own safe C dialect for iBoot firmware instead of using Rust?
If we can have Singularity/Midori back, with a microkernel in Rust, it would be quite nice, but yeah, I guess that is more of wishful thinking.
With Rust, the burden of checking all of that is shifted to the compiler, and that reduces cognitive load for the developer.
Anyone that cares about memory safety for userspace applications has already moved on into other languages, the problem is the foundation and those that resist no matter what.
Also the data races prevented by Rust type system only apply to multihreaded code accessing in-memory data structures, there plenty of other data races in multiprocessing scenarios.
Safe rust prevents data races at compile time. It doesn’t prevent other race conditions.
And “only” preventing data races, is still a non-trivial achievement!
Yes it is a non-trivial achievement, just I get the feeling that the advocacy for it tends to forget about the other ones.
By the way, John Regehr's example won't work if the transferXXX functions are using SQL statements without transactions across threads each with its own connection, instead of in-memory variables.
I would watch the upcoming VC++ static analysis talk regarding its progress.
https://visualstudio.microsoft.com/de/pure-virtual-cpp-event...
Note I mean the work being done by Microsoft and Google on top of Core Guidelines on their syntac analysers, which on Microsoft's case are active by default as background process that validate your code as you type.
It will never be as good as Rust is able to, but in some domains a "worse is better" solution will already be better than nothing, because they aren't going to port their code to something else.
I will consider Microsoft is fully into Rust when Azure Sphere supports Rust instead of being a C only SDK, despite its security marketing.
https://techcommunity.microsoft.com/t5/internet-of-things/de...
The first step in reducing those 70% is to actually use the tools that exist, but unfortunelly the macho attitute is still quite prevalent.
https://isocpp.org/files/papers/CppDevSurvey-2021-04-summary...
Those that are open to embrace Rust, are most likely already using static analyzers.