5 ms·
Yes, it's very similar to unique_ptr. The point here is that you can implement many kinds of complex and useful heap-allocated data structures in safe Rust cod
by roca 7y ago
Yes, it's very similar to unique_ptr.
The point here is that you can implement many kinds of complex and useful heap-allocated data structures in safe Rust code, without any reference counting, and the compiler will verify that you have no use-after-free bugs, or any other kind of memory-safety bug. The same is not true of (pre-SPARK) Ada, or C, or C++, or BetterC.
- pjmlp 7y agoYou can play around with C++ lifetime analysis in Visual C++ 2019 and clang tidy. It is still WIP, yet to be deployed at large, naturally doesn't cover binary libraries, but it already a very good improvement.
- dthul 7y agoIt's exciting to see C++ pick up some of those ideas! Anything that improves the current situation is appreciated.
- pjmlp 7y agoThat is what I see as most valuable contribution from Rust. Even if Rust would fail at large scale mainstream adoption, the fact that the community has pickup up Cyclon and ATS ideas to the point that Swift, OCaml, Haskell, Ada, C++, D, Chapel, ParaSail and eventually other communities started to adopt similar ideas, that alone is a major victory to everyone involved in Rust.
- vardump 7y agoThat's interesting, still on VS2017 for Windows stuff. I can't wait to try that on kernel drivers, etc.
- pjmlp 7y agoYou can read more about here, https://herbsutter.com/2019/05/03/eurollvm-lifetime-talk-by-gabor-horvath-and-matthias-gehre/ https://herbsutter.com/2019/05/03/eurollvm-lifetime-talk-by-... https://devblogs.microsoft.com/cppblog/lifetime-profile-update-in-visual-studio-2019-preview-2/ https://devblogs.microsoft.com/cppblog/lifetime-profile-upda...
- roca 7y agoI'm excited about the C++ lifetimes work, but it's important to recognize that its goals are much more modest than the goals of memory-safe languages. They aim to catch many common memory-safety bugs, which is very valuable, but that's not nearly the same thing as guaranteeing the absence of memory-safety bugs. https://robert.ocallahan.org/2018/09/more-realistic-goals-for-c-lifetimes-10.html https://robert.ocallahan.org/2018/09/more-realistic-goals-fo...
- pjmlp 7y agoTrue, but that way I can still do my .NET / C++/WinRT interop without having to reboot the world, keeping the nice Visual Studio mixed mode debugging integration and the whole Windows infrastructure that is build around C++. Maybe now with Microsoft having some care for Rust, the tooling situation will improve, but right now, even if handicapped, C++ lifetimes are easier to sell in some shops than rebooting the whole stack in Rust. And in the end they all share the same goal, improved safety in our daily stacks, even the bits we only touch as user.