4 ms·
In what way do you think C++ is borrowing the idea of a borrow-checker? Smart pointers pre-date Rust.
by stochastic_monk 7y ago
In what way do you think C++ is borrowing the idea of a borrow-checker? Smart pointers pre-date Rust.
- pjmlp 7y agoVisual Studio and clang are introducing a borrow checker in their static analysis tools. If you leave it on as part of the build you get an similar experience (note on similar, they aren't bullet proof due to language semantics). There are a couple of conference talks about them. Naturally smart pointers predate Rust, I used them back when Windows 3.1 was considered recent, alongside OWL. However they aren't the same thing, introduce runtime overhead and don't prevent use-after-free, or use-after-move.
- stochastic_monk 7y agoThat makes more sense, though not actually part of the language. Smart pointers were the only thing close that came to mind for that reason. I’ve used the Clang experimental lifetime analyzer on Godbolt, and I welcome improved tooling.
- yakubin 7y agoOne thing about static analysis tools that seems to be easily forgotten about in discussions about rust vs other languages is that those tools are trivially ignorable. If your CI pipeline doesn't let you get a binary for a given milestone, because the code doesn't pass static analysis, unit/integration tests etc. people will just disable it for myriads of reasons not the least of which will be "management wanted it to be done by yesterday and it compiles, so it's probably ok", "it's probably false positives again [yeah, right...]", "this is the test that fails from time to time, it's probably nothing". A compilation error is a much better protection from the social pitfalls of programming in a corporate environment. So yup, you have all those wonderful tools at your disposal in the C/C++ which I guarantee you will ignore or be forced to ignore at your peril.
- pjmlp 7y agoActually I tend to refer to it quite often. However one needs to see the full picture, not only language grammar and semantics. If I want to create a GUI application today, I will definitely use a mix of .NET ,Java, with C++ for the low level performance bits, because Rust is lacking in that area, in spite of being a safer language. So, if C++ takes a lesson or two from Rust, and helps developers like myself to keep productive, while improved the security of the whole stack, then so much the better. And if Rust continues to improve, maybe one day Android Studio, XCode, VS, will provide an end-to-end mixed language experience, and OS frameworks, for Rust just like they do for C++ nowadays.
- blub 7y agoUsing the same logic, you could argue that people will just use unsafe and shared pointers everywhere if they have a deadline and they can't get their code to compile. This is an organizational problem, not a language / tool problem.
- zbentley 7y agoEven when abusing unsafe, it's hard to get away with as much laziness (especially sneaky, dangerous, indirected laziness) as you can get away with by default/accidentally in other languages when you disable their linting/analysis tools.
- Rusky 7y agoToo bad that borrow checker is incomplete and unsound, with no intentions or ambitions of improving.
- steveklabnik 7y agoSmart pointers are a different feature than the borrow checker. I believe your parent is referring to the Core Guidelines and the Guideline Support Library.
- pjmlp 7y agoLifetime analyser from VS and clang.
- steveklabnik 7y agoDo you have a link? I thought they were related, but maybe I’m behind the times!
- pjmlp 7y agoEuroLLVM 2019 on YouTube has a talk on clang current implementation state. Apple also demoed their XCode integration at WWDC 2019, on the talk about Objective-C, C and C++ support.
- blub 7y agoWhen is the Xcode integration coming?
- pjmlp 7y agoI remembered it incorrectly, sorry about that, there are several improvements regarding type safety, but not for lifetimes, C++ use-after-move, std::string vs char*, and a couple of others. https://developer.apple.com/videos/play/wwdc2019/409/ https://developer.apple.com/videos/play/wwdc2019/409/ However here is the clang talk I was referring to. https://www.youtube.com/watch?v=VynWyOIb6Bk https://www.youtube.com/watch?v=VynWyOIb6Bk