Hacker News new | ask | show | jobs
by pjmlp 2540 days ago
If someone can do systems programming with FreePascal/Delphi, Modula-3, .NET Native, D, Swift, Ada,...

They will be almost at home with Rust.

The biggest hurdle is dealing with the borrow checker when writing GUI code (hello Rc<RefCell<T>>), but for other kind of applications it is quite ok.

Also it speaks a lot that Ada, C++, Swift are adopting the same ideas regarding the borrow checker, even if implementation has some constraints given backwards compatibility.

1 comments

In what way do you think C++ is borrowing the idea of a borrow-checker? Smart pointers pre-date Rust.
Visual 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.

One 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.
Using 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.

Even 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.
Actually 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.

That 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.

Smart pointers are a different feature than the borrow checker.

I believe your parent is referring to the Core Guidelines and the Guideline Support Library.

Lifetime analyser from VS and clang.
Do you have a link? I thought they were related, but maybe I’m behind the times!
EuroLLVM 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.

When is the Xcode integration coming?