News for hackers. Stuff that matters.
Re:DARPA: Translating All C to Rust (Tractor) by calebpeterson on Tuesday July 30, 2024 @12:06PM (#41110642)
Genuine question:

Would you mind explaining to a dev that doesn’t know much (anything) about Rust, how does this settle any debate?

Re:DARPA: Translating All C to Rust (Tractor) by jerf on Tuesday July 30, 2024 @12:10PM (#41110690)
I believe it goes something like, "I have constructed a strawman that Rust claims that all code written in it is automatically safe by all conceivable definitions of safe, but look, ha ha, here's something that detects unsafe code in Rust!", and I don't mean "code marked in unsafe blocks".

It's a concatenation of several logical fallacies in a row; equivocation, straw manning, binary thinking about safety, several others. It's hard to pick the main one, but I'd go with the dominant problem being a serious case of binary thinking about what "safety" is. Of course, if the commentor is using anything other than Idris for all their programming, they're probably not actually acting on their own accusations.

Re:DARPA: Translating All C to Rust (Tractor) by PreInternet01 on Tuesday July 30, 2024 @12:18PM (#41110829)
Oh, come on. This repository demonstrates that, when using 'safe' Rust, there are still double-digits cases where you may still encounter dread-pirate-UB.

Again, I don't want to argue against you using or enjoying Rust, I would merely like to point out that it does, demonstrably, not solve all programming problems ever...

Re:DARPA: Translating All C to Rust (Tractor) by commodoreboxer on Tuesday July 30, 2024 @12:23PM (#41110909)
> This repository demonstrates that, when using 'safe' Rust, there are still double-digits cases where you may still encounter dread-pirate-UB.

No it doesn't. Miri is for unsafe code. There's no UB in safe Rust by design. Any UB caused without unsafe is considered a bug to be fixed.

Re:DARPA: Translating All C to Rust (Tractor) by PreInternet01 on Tuesday July 30, 2024 @01:18PM (#41111679)
MIRI also detects problems in generally safe Rust. If you want to know how I know, read the sibling comments. Or, like, just downvote me, it's not like I care about my imaginary Internet points.

The sanity of future devs, though? I do care about that, though, and there is a huge problem with that in the Rust 'community'

Re:DARPA: Translating All C to Rust (Tractor) by nequo on Tuesday July 30, 2024 @01:42PM (#41111992)
> ... in generally safe Rust.

Just to find agreement about the terminology, wouldn't we call all code that is not inside an unsafe block "safe?" If so, then adding "generally" is superfluous, right?

If not, then how is "generally safe" different from "not inside an unsafe block?"

Re:DARPA: Translating All C to Rust (Tractor) by jerf on Tuesday July 30, 2024 @01:49PM (#41112079)
I didn't expect you to outright confirm that you are using the "solve all programming problems ever" strawman, but, err, thanks for the proof I guess. I thought maybe I went a bit overboard in the reading between the lines but I guess I nailed it.
Re:DARPA: Translating All C to Rust (Tractor) by marcosdumay on Tuesday July 30, 2024 @04:08PM (#41113590)
> Of course, if the commentor is using anything other than Idris

I'm sure the Idris compiler has bugs somewhere too. If the OP actually programs, they are violating their rationale (I'm quite sure assembly or assembled binary aren't ok either).

Re:DARPA: Translating All C to Rust (Tractor) by PreInternet01 on Tuesday July 30, 2024 @12:12PM (#41110726)
Well, the general 'Rewrite All in Rust' consensus is that it solves all general programming problems, ever.

Yet, the linked repository shows a huge list of cases in which simple, documented use of Rust can cause Undefined Behavior (a.k.a. 'UB')

Pretty much every argument of Rust advocates against C/C++ boils down to either 'but memory safety' or 'but UB'.

Yet there are many convincing counter-arguments that boil down to 'but CompCert' or similar, and, as the linked repository shows, there might be at least some truth in there?

Re:DARPA: Translating All C to Rust (Tractor) by steveklabnik on Tuesday July 30, 2024 @12:23PM (#41110905)
No serious person claims that Rust solves every problem ever.

Also, many people cite things like Cargo as a reason to prefer Rust over C and C++, as well as other things. UB is a big part of it, of course, but it isn’t the only thing.

Re:DARPA: Translating All C to Rust (Tractor) by galangalalgol on Tuesday July 30, 2024 @12:49PM (#41111264)
I selected it for performance reasons myself, the UB protection was a nice benefit that was expected, cargo wasn't expected and is extremely nice coming from the cmake,conan,vcpkg and duct tape world I came from.
Re:DARPA: Translating All C to Rust (Tractor) by PreInternet01 on Tuesday July 30, 2024 @01:09PM (#41111559)
> No serious person claims that Rust solves every problem ever

No, but there are a lot of people claiming that Rust cannot ever have any problems.

Just look at this thread. I merely linked to MIRI, and am currently at, like, -10 just for that.

Lots of people claiming that it just applies to 'unsafe Rust': is that true or not?

Regardless of anything else: can you, as a Rust community leader, please state clearly: is UB in generally safe Rust possible or not?

Re:DARPA: Translating All C to Rust (Tractor) by steveklabnik on Tuesday July 30, 2024 @01:13PM (#41111615)
No, people are not claiming Rust cannot have any problems.

UB is not possible in safe Rust, by design. The root cause of UB is always in unsafe code. Miri is useless if your code is 100% safe Rust.

The only exception to this is bugs in the compiler, of which there are a few. They’ll be fixed.

Re:DARPA: Translating All C to Rust (Tractor) by PreInternet01 on Tuesday July 30, 2024 @01:51PM (#41112112)
> UB is not possible in safe Rust, by design

You're available as an expert witness to that fact?

Because, eh, well, in at least one of the Rust-related situations that I'm involved in right now, someone might soon very well require the services of a person both as wise and reluctant-to-offer-any-kind-of-compromise as yourself...

Re:DARPA: Translating All C to Rust (Tractor) by jcranmer on Tuesday July 30, 2024 @03:53PM (#41113457)
The situation you've alluded to in another thread seems to involve an unsafe block (since it's using a type which is only usable in an unsafe block).

Let me be even more explicit than steveklabnik here. If your code, including any libraries you link to, is 100% Rust and free of any unsafe blocks, then (barring compiler bugs) it is impossible to execute undefined behavior. If your code has an unsafe block, then it is possible execute undefined behavior. Note that it is possible for safe code to execute undefined behavior, IF there was an unsafe block that did an operation that requires the programmer to promise something was true that was not true.

For example, there is an unsafe method that will let you convert a pointer to a reference with an arbitrary lifetime. If you wrap that in a safe function, you can return a reference to an object whose lifetime has ended, and cause undefined behavior in attempting to use that lifetime--the attempt can even be outside the safe block. But were that unsafe block that upgraded the lifetime not present, then you couldn't cause the later undefined behavior to happen.

In short, an unsafe block is where the compiler can no longer guarantee that the conditions that prevent the ability to observe undefined behavior are present, and it is up to the programmer to ensure that these conditions are met, and even and especially ensure that they continue to be met after the unsafe block completes. I do worry that too many programmers are blasé about the last bit, and it sounds like your coworker may fall into that category. But Rust has always maintained this principle.

Re:DARPA: Translating All C to Rust (Tractor) by steveklabnik on Tuesday July 30, 2024 @01:54PM (#41112136)
Yes, it is a core design tenet of the language. It's as benign a statement as "C# has garbage collection." That's not "reluctant to offer compromise."
Re:DARPA: Translating All C to Rust (Tractor) by PreInternet01 on Tuesday July 30, 2024 @02:03PM (#41112244)
OK, you truly seem not to understand how much damage you're dealing to the general population using absolutist statements like this, do you? Nor do you seem to understand "compromise", like at all, because you seem to equate it with "tit for that", which is unsurprising, but still... disappointing.

In any case, I'm truly done here, in all senses of the word, but I still I wish you and your acolytes the absolute best.

Re:DARPA: Translating All C to Rust (Tractor) by keybored on Tuesday July 30, 2024 @03:49PM (#41113413)
Calling Steve Klabnik (of all Core Rust background people, literally all of them) an “absolutist” proves how unreasonable you’re being.
Re:DARPA: Translating All C to Rust (Tractor) by chiggsy on Wednesday July 31, 2024 @10:22AM (#41119424)
Why do you feel it is unreasonable for this person to have human failings? What label would you find suitable?
Re:DARPA: Translating All C to Rust (Tractor) by keybored on Wednesday July 31, 2024 @10:26AM (#41119459)
You’re either reframing the statement to be about human failings overall—the lack thereof—or you’re assuming the conclusion.
Re:DARPA: Translating All C to Rust (Tractor) by superb_dev on Wednesday July 31, 2024 @02:50AM (#41116917)
Man all you had to do was bring proof, like maybe a code snippet with UB?
Re:DARPA: Translating All C to Rust (Tractor) by Slyfox33 on Tuesday July 30, 2024 @03:54PM (#41113461)
What are you talking about? Yes it's impossible to have UB in safe rust unless theres some obscure compiler bug or something. This isn't a controversial statement.
Re:DARPA: Translating All C to Rust (Tractor) by chiggsy on Wednesday July 31, 2024 @02:26PM (#41121849)
I have no faith in this statement. Let's see how it plays out.
Re:DARPA: Translating All C to Rust (Tractor) by steveklabnik on Wednesday July 31, 2024 @09:58PM (#41125532)
If you ever find UB in purely safe Rust, it is a very serious bug. Please report it.
Re:DARPA: Translating All C to Rust (Tractor) by leftyspook on Tuesday July 30, 2024 @12:31PM (#41111006)
> Well, the general 'Rewrite All in Rust' consensus is that it solves all general programming problems, ever.

a) There is no such consensus. The actual consensus is that even if Rust solved all problems, it would not be financially feasible to rewrite pretty much any substantial project.

b) While Rust does solve many problems, it is nowhere close to solving all safety, otherwise there would be no `unsafe` keyword. Alas, fully proving safety in an impure, turing-complete language is mathematically impossible.

c) The only reason you would think that there's some sort of woke Rust lobby, is if you spend way too much time subjecting yourself to opinions of literal sixteen year olds on twitter.

Re:DARPA: Translating All C to Rust (Tractor) by superb_dev on Tuesday July 30, 2024 @12:33PM (#41111042)
> Well, the general 'Rewrite All in Rust' consensus is that it solves all general programming problems, ever.

No, that’s not the consensus. This is a strawman.

Re:DARPA: Translating All C to Rust (Tractor) by timeon on Tuesday July 30, 2024 @12:52PM (#41111312)
> Well, the general 'Rewrite All in Rust' consensus is that it solves all general programming problems, ever.

This is obvious example of strawman. Why are you doing this?

Re:DARPA: Translating All C to Rust (Tractor) by PreInternet01 on Tuesday July 30, 2024 @01:15PM (#41111644)
Towards general mental health. I'm just a C# wage slave, and I'll admit, when being prompted, that my language, its vendor, its runtime environment, and its general approach are, to put it kindly, flawed.

However, as evidenced by the arguments and voting in this thread, Rust proponents will take no criticism, whatsoever.

I linked to a GitHub repository that documents many, many instances in which generally safe Rust causes UB.

The same kind of UB that recently hit one of my coworkers, caused a 3-day outage and now (despite all my counseling to the contrary!) will burn them out permanently.

My only request: can you guys please back off just a little bit? Programming is already hard enough without the purity wars you're stoking all the time...

Re:DARPA: Translating All C to Rust (Tractor) by keybored on Tuesday July 30, 2024 @03:47PM (#41113394)
Stoking language flame wars based on hysterical exaggeration has never promoted mental health.
Re:DARPA: Translating All C to Rust (Tractor) by fargle on Tuesday July 30, 2024 @06:07PM (#41114599)
to be fair, from his perspective, it's often the rusty crowd who is stoking the flame wars - this sounds like a reaction to them.

how often do we hear something like "C and C++ are horribly flawed and completely unsafe. it's basically a crime against humankind and gross negligence to use them"?

i get weary of that kind of thing too. i wouldn't approach it by reacting in the same way as the GP comment, but i get it. and it's not really that much of a strawman. it's more exasperation and sarcasm.

personally, i'm very interested in rust. but everytime someone at best "overhypes" it or at worse, outright dogs on other languages, it's a negative point toward dealing with the whole rust ecosystem.

Re:DARPA: Translating All C to Rust (Tractor) by jamincan on Wednesday July 31, 2024 @09:39AM (#41119068)
In all honesty, I don't see that sort of thing posted except maybe the overly naive excited "omg I love rust" post in /r/rust from someone just learning it which no one should be taking as credible.

I do, however, see people trot out the oft-repeated "rust evangelists want to rewrite everything in rust" or "rust people say programming C++ is a crime against humanity", but it seems to me that's the only place I see this argument. In other words, it's a simple strawman.

Re:DARPA: Translating All C to Rust (Tractor) by keybored on Wednesday July 31, 2024 @10:18AM (#41119392)
I don’t buy it.

People can, in the most neutral way possible, point out facts about how safe or unsafe Rust is compared to C and C++. People will STILL complain about how the Rust zealots are bullying their language. This is how it plays out every time.

You can look at this thread. The “exasperation and sarcasm“ is stupid and one-sided. “But” they always say “that’s just a reaction to a previous debate”–because the Rust zealots are always in the rear-view mirror, never in front of them.

How about complaining about something in Rust… that is bad? Like how un-ergonomic Async is? Or how pointy and awkward the syntax can be? Instead they choose to fight the losing battle over how C and Rust are equally unsafe or how actually Rust’s safety doesn’t matter, depending on the phase of the moon. Then they whine about tone and zealotry when they realize arguing against Rust safety from the C and C++ side is a losing battle and they have run out of arguments.

Re:DARPA: Translating All C to Rust (Tractor) by mrweiden on Tuesday July 30, 2024 @12:10PM (#41110700)
From the original post > It’s not enough to rely on bug-finding tools

From the Miri github: > Miri is an Undefined Behavior detection tool for Rust.

Re:DARPA: Translating All C to Rust (Tractor) by Sharlin on Tuesday July 30, 2024 @12:15PM (#41110788)
There is no contradiction. The fact that UB-finding tools alone are not sufficient doesn't mean they aren't useful even with a safe(r) language.

In other words, from "safer languages are necessary" it does not follow that "safer languages are sufficient".

Re:DARPA: Translating All C to Rust (Tractor) by keybored on Tuesday July 30, 2024 @12:13PM (#41110752)
Darpa is already ahead of you all with the hedging:

> The preferred approach is to use “safe” programming languages

“Safe”. Terms and conditions may apply.

Re:DARPA: Translating All C to Rust (Tractor) by leftyspook on Tuesday July 30, 2024 @12:37PM (#41111094)
It is a tool for checking that your unsafe code doesn't cause UB. It doesn't really settle anything, but the commenter uses it as a gotcha to say "rust is no better than C, because you still can compile code that contains UB".
Re:DARPA: Translating All C to Rust (Tractor) by spease on Tuesday July 30, 2024 @01:11PM (#41111584)
They are claiming that because code in ‘unsafe’ blocks in Rust can have undefined behavior, that the language is no safer than C.

This does not settle the debate because unsafe is rarely needed for a typical Rust program. In addition, the presence of an unsafe block also alerts the reader that the set of possible errors is greatly increased for that part of the code and more careful auditing is needed.

It’s a little like saying traffic lights are useless because emergency responders need to drive through them sometimes, so we should just leave intersections completely unsignaled and expect drivers to do better.

Rust is by default restrictive and requires you to explicitly make it unsafe, C/++ are by default unsafe and require you to explicitly make them restrictive.