News for hackers. Stuff that matters.
Re:DARPA: Translating All C to Rust (Tractor) by PreInternet01 on Tuesday July 30, 2024 @12:04PM (#41110600)
The one link for those who think that 'Rewrite it All in Rust' will, well, settle any debates: https://github.com/rust-lang/miri/
Re:DARPA: Translating All C to Rust (Tractor) by keybored on Tuesday July 30, 2024 @12:07PM (#41110652)
You linked an interpreter for some kind of internal compiler representation that the Rust compiler uses.

What on Earth do you mean?

Re:DARPA: Translating All C to Rust (Tractor) by nequo on Tuesday July 30, 2024 @12:08PM (#41110673)
It's the old trope that some Rust code uses unsafe blocks so all Rust code is as unsafe as C.
Re:DARPA: Translating All C to Rust (Tractor) by melling on Tuesday July 30, 2024 @12:13PM (#41110747)
I don’t know Rust but even if the Rust is just as unsafe in certain blocks, simply being translated to Rust removes a lot of corporate resistance to adopt the language.

Getting people to adopt a new language can be a lot of work. I remember people claiming they missed headers files in Swift so they wanted to stick with Objective C.

Re:DARPA: Translating All C to Rust (Tractor) by keybored on Tuesday July 30, 2024 @12:11PM (#41110705)
Of course. I should have expected the Nirvana Fallacy. :)
Re:DARPA: Translating All C to Rust (Tractor) by PreInternet01 on Tuesday July 30, 2024 @12:15PM (#41110786)
> What on Earth do you mean?

That documented use of safe Rust can easily lead to UB, which this infernal 'internal compiler representation' demonstrates.

I'm not even sure what is even remotely confusing about that?

Re:DARPA: Translating All C to Rust (Tractor) by woodruffw on Tuesday July 30, 2024 @12:18PM (#41110825)
Miri is a MIR interpreter aimed at unsafe Rust, not safe Rust. Using the fact that it operats on an internal representation is a very weird swipe; almost all static and dynamic analysis tools work on some kind of IR or decomposed program representation.
Re:DARPA: Translating All C to Rust (Tractor) by commodoreboxer on Tuesday July 30, 2024 @12:19PM (#41110844)
> Miri is an Undefined Behavior detection tool for Rust. It can run binaries and test suites of cargo projects and detect unsafe code that fails to uphold its safety requirements.

> ... detect unsafe code that fails ...

Show me the documented safe Rust code that causes UB without using any unsafe blocks outside of the standard library.

Re:DARPA: Translating All C to Rust (Tractor) by steveklabnik on Tuesday July 30, 2024 @12:20PM (#41110864)
There are some soundness holes in the implementation that can cause this. Just like any project, the compiler can have bugs. They’ll be fixed just like any bug.
Re:DARPA: Translating All C to Rust (Tractor) by PreInternet01 on Tuesday July 30, 2024 @01:05PM (#41111497)
Ah, a voice of sort-of sanity, at long last.

So, the reason I posted my original reply, is that at one of my $DAYJOBs, we recently had a 3-day outage on some service, related to Rust. Something like using AVX to read, like, up to 7 bytes too many from an array.

Nothing really major -- we have a 10-day backup window, and the damage was limited to 4 days, so we were able to identify and fix all identified cases. But the person-to-Git-blame for this issue happened to be one of my mentees, and... they were blown away by it.

As in: literally heartbroken. Unable to talk about it. "But the compiler said it was okay!", crying. One of my coworkers pointed at MIRI, which correctly warned about the issue-at-hand, at which point I recommended incorporating that tool into the build pipeline, as well as (the usual advice in cases such as this) improving unit tests and focusing on X-1 and X+1 cases that might be problematic.

To this day, I'm truly worried about my mentee. I'm just a C# wagie, and I fully accept that my code, my language, my compiler, and my runtime environment are all shit.

But, as evidenced by my experience and supported by the voting in this thread, it seems that Rust users seem to self-identify with the absolute infallibility of anything relate to the language, and react quite violently and self-destructively to any evidence to the contrary.

As a community leader, do you see any room for improvement there? And if not, what would it take to convince you?

Re:DARPA: Translating All C to Rust (Tractor) by steveklabnik on Tuesday July 30, 2024 @01:28PM (#41111822)
> using AVX

This would require using unsafe code.

> As in: literally heartbroken. Unable to talk about it.

I would hope that this person improves as an engineer, because this isn't particularly professional behavior, from the way you describe it.

> "But the compiler said it was okay!"

Given that you'd have to use unsafe to do this, the compiler can't say it was okay. It sounds like this person may not fully understand Rust either.

> it seems that Rust users seem to self-identify with the absolute infallibility of anything relate to the language, and react quite violently and self-destructively to any evidence to the contrary.

I don't see how this generalizes. You had one (apparently junior, given "mentee"?) person make a mistake and respond poorly to feedback. You also barged into this thread and made incorrect statements about Rust, and were downvoted for it. That doesn't mean that Rust users think everything is perfect.

> As a community leader, do you see any room for improvement there?

I do think sometimes enthusiastic people who don't understand things misrepresent the thing they're enthusiastic about, but that's a human problem, not a Rust problem. I do not think there's a way to fix that, no.

Re:DARPA: Translating All C to Rust (Tractor) by mike_hearn on Wednesday July 31, 2024 @04:11AM (#41117265)
It'd require using unsafe code somewhere in the stack. Not necessarily by the mentee. It's possible that the AVX code wasn't properly hidden behind a safe abstraction in a library.
Re:DARPA: Translating All C to Rust (Tractor) by steveklabnik on Wednesday July 31, 2024 @10:12AM (#41119331)
That still means the unsafe code is at fault.
Re:DARPA: Translating All C to Rust (Tractor) by mike_hearn on Wednesday July 31, 2024 @11:23AM (#41120012)
Yes, but if a developer can't trust the abstractions then isolating unsafe code behind them is of no value.
Re:DARPA: Translating All C to Rust (Tractor) by commodoreboxer on Friday August 02, 2024 @11:37AM (#41139752)
Given the story at hand, it sounds like the center incorrectly assumed the compiler would prevent UB even in unsafe blocks. They wouldn't be saying "But the compiler said it was okay" if it wasn't unsafe code they had written.

I think the story is just somebody who didn't actually learn unsafe Rust properly (and I'm struggling to give it the benefit of the doubt, as it sounds quite exaggerated; I couldn't imagine a novice Rust dev literally crying because they thought unsafe blocks couldn't cause UB. If you were that emotionally attached to the language, I'd expect you to have learned what unsafe means).

Re:DARPA: Translating All C to Rust (Tractor) by PreInternet01 on Thursday August 01, 2024 @11:29AM (#41130226)
OK, so here's my heartfelt plea: remove the 'unsafe' keyword from Rust?

Sure, not being able to do basic things like IO might be a bit of a limitation at first, but, that's all worth it, I guess?

Again: I'm pointing out to you that your absolutist stance on 'unsafe' and 'UB' is doing more harm than good.

You continue to choose to ignore this, which is your right. But as a "community leader" you could and should to better. As could I, I guess, by simply ignoring you, but, the mental health issues I see you cause in real-life make that sort-of hard...

Re:DARPA: Translating All C to Rust (Tractor) by commodoreboxer on Friday August 02, 2024 @11:30AM (#41139673)
I don't know if he's choosing to ignore it, or if it's simply hard to figure out exactly what you're saying. Your comments are unfocused in a way that makes it hard to engage with any specific point.

The points are:

* Unsafe Rust is required to uphold specific guarantees to not cause undefined behavior. This can be tricky, but it's not impossible, it just involves a lot of care and some tooling like Miri for those specific situations. The situation is the same as pretty much the entirety of the C and C++ languages, plus Rust reference safety.

* Safe Rust is designed to not cause any UB on its own. It can only "bleed" UB from incorrect unsafe code. Without any incorrect unsafe code, this is easy to work with and involves much less work and care.

* Therefore, keeping your unsafe blocks small and in dedicated crates where they can be individually tested increases the quality and reliability of the codebase.

Surely you can see that it's an improvement over the previous status quo. I don't know what absolutist stance you're talking about. Most Rust fans I know, including myself, accept that Rust is an imperfect language, representing an improvement over C and C++. It's not just hypothetical either. Rust has brought demonstrated improvement in reliability for us, and for some of the biggest companies in the world who now lean on it to reduce their rate of defects.

Re:DARPA: Translating All C to Rust (Tractor) by n_plus_1_acc on Tuesday July 30, 2024 @01:20PM (#41111717)
The Rust community as a whole very much promotes the idea of trusting the Compiler. Which is a very useful thing, especially for folks coming from other languages like C. It's not perfect of course as the compiler has bugs, but I think it still a good thing to teach.
Re:DARPA: Translating All C to Rust (Tractor) by astrange on Tuesday July 30, 2024 @09:48PM (#41115793)
You should never do this if you work at a company large enough to have a compiler team, btw, because they're going to fork the compiler and put bugs in it.

Conversely, if you never encounter bugs in a component, it means it's not being improved fast enough.

Re:DARPA: Translating All C to Rust (Tractor) by keybored on Tuesday July 30, 2024 @03:44PM (#41113368)
> I'm just a C# wagie, and I fully accept that my code, my language, my compiler, and my runtime environment are all shit.

What is shit about those things for C#? That’s the application programming language that seems to get the least flak out of all of them.

If I’m using an alpha or beta compiler, I might suspect a compiler bug from time to time… not really when I’m working in a decades-old, very established language.

Re:DARPA: Translating All C to Rust (Tractor) by astrange on Tuesday July 30, 2024 @09:58PM (#41115831)
Java is an underpowered clone of ObjC and C# is a slightly less underpowered clone of Java.

So they fixed the biggest issues (at least it has value types), but it has nullable classes, collection types are mutable, integer overflow doesn't trap, it doesn't have nearly enough program verification features (aka dependent types), etc.

Worst of all it was written by enterprise programmers, who think programs get better designed when you put all their types four namespaces deep. I assume whoever named System.Collections.ArrayList keeps everything in their house in one of those filing cabinets with the tiny drawers.

Re:DARPA: Translating All C to Rust (Tractor) by neonsunset on Tuesday July 30, 2024 @01:31PM (#41111863)
Don't worry, your language and especially the runtime and compiler are great. Particularly so in the last few years. I wouldn't worry about the noise, maybe it concerns C++, but C# is a strict productivity upgrade for general-purpose applications despite some* of the dated bits in the language (but not the runtime).

* like un-unified representation of nullable reference types and structs under generics for example, or just the weight of features over the years, still makes most other alternatives look abysmal in comparison

Re:DARPA: Translating All C to Rust (Tractor) by commodoreboxer on Tuesday July 30, 2024 @12:28PM (#41110975)
Yes, in particular some interactions with LLVM have caused some frustrating UB. But those are considered implementation bugs, rather than user bugs, and all the conditions Miri states at the top are relevant primarily in unsafe code, which contradicts the OP's point, which is that there are tons of documented cases of UB in safe Rust. This is not true. There are a few documented cases, and most have been fixed. It's nowhere close to the world of C or C++'s UB minefield.
Re:DARPA: Translating All C to Rust (Tractor) by steveklabnik on Tuesday July 30, 2024 @12:34PM (#41111056)
For sure, just making sure to acknowledge this is the case, before someone responded to your post with cve-rs. :)
Re:DARPA: Translating All C to Rust (Tractor) by keybored on Tuesday July 30, 2024 @12:23PM (#41110910)
Indeed. There have been UB bugs in the standard library caused by unsafe blocks.

Those are bugs. They are faults in the code. They need to be fixed. They are not UB-as-a-feature like in C/C++. “Well watch out for those traps every time you use this.”

This is like getting mad that a programming language boasts that it produces great binaries and yet the compiler has a test suite to catch bugs in the emitted assembly. That’s literally what you are doing.

Re:DARPA: Translating All C to Rust (Tractor) by Calavar on Tuesday July 30, 2024 @01:25PM (#41111785)
> Those are bugs. They are faults in the code. They need to be fixed. They are not UB-as-a-feature like in C/C++.

Rust has UB-as-a-feature too. They could have eliminated UB from the language entirely, but they chose not to (for very valid reasons in my opinion).

UB is a set of contracts that you as the author agree to never violate. In return, you get faster code under the assumption that you never actually encounter a UB condition. If you violate those contracts in Rust and actually encounter UB, that's a a bug, that's a fault in the code. If you violate those contracts in C++, that's a bug, that's a fault in the code. This is the same in both languages.

It's true that Rust UB can only arise from unsafe blocks, but it is not limited to unsafe blocks. Rust UB has "spooky action at a distance" the same way C++ UB does. In other words, you can write UB free code in Rust, but if any third party code encounters UB (including the standard library), your safe code is now potentially infected by UB as well. This is also the same in both languages.

There are good reasons to favor Rust's flavor of UB over C++'s, but I keep seeing these same incorrect arguments getting repeated everywhere, which is frustrating.

Re:DARPA: Translating All C to Rust (Tractor) by oconnor663 on Tuesday July 30, 2024 @02:34PM (#41112604)
> It's true that Rust UB can only arise from unsafe blocks, but it is not limited to unsafe blocks.

This is correct, and it's hard to teach, and I agree that a lot of folks get it wrong. (Here's my attempt: https://jacko.io/safety_and_soundness.html.) But I think this comment is understating how big of a difference this makes:

1. Rust has a large, powerful safe subset, which includes lots of real-world programs. Unsafe code is an advanced topic, and beginners don't need to learn about it to start getting their work done. Beginners can contribute to big projects without touching the unsafe parts (as you clarified, that means the module privacy boundaries that include unsafe code, not just the unsafe blocks), and reviewers don't need to be paranoid about every line.

2. A lot of real-world unsafe Rust is easy to audit, because you can grep for `unsafe` in a big codebase and zoom right to the parts you need to look at. Again, as you pointed out, those blocks might not be the whole story, and you do need to read what they're doing to see how much code they "infect". But an experienced Rust programmer can audit a well-written codebase in minutes. It's not always that smooth of course, but it's a totally different world that that's even possible.

Re:DARPA: Translating All C to Rust (Tractor) by keybored on Tuesday July 30, 2024 @02:26PM (#41112493)
> There are good reasons to favor Rust's flavor of UB over C++'s, but I keep seeing these same incorrect arguments getting repeated everywhere, which is frustrating.

Tell me what I wrote that was incorrect. I called them UB bugs in the standard library. If they were trivial bugs that caused some defined-behavior logic bug while used outside of the standard library then it wouldn’t rise to the level of being called an UB bug.

Re:DARPA: Translating All C to Rust (Tractor) by Calavar on Tuesday July 30, 2024 @02:42PM (#41112721)
> They are not UB-as-a-feature like in C/C++.

That's the part that's incorrect. That, plus the implication that UB is a bug in Rust, but not in C++. As I said, the existence of UB is a feature in both languages and actually encountering UB is a bug in both languages. You can play with the semantics of the word "feature" but I don't think it's possible to find a definition that captures C++ UB and excludes Rust UB without falling into a double standard. Unfortunately double standards on UB are pretty common in conversations about C++ and Rust.

Re:DARPA: Translating All C to Rust (Tractor) by keybored on Tuesday July 30, 2024 @03:36PM (#41113295)
You’re done editing the comment now?

Do you think UB-as-feature is something that someone would honestly describe C or C++ as? It’s a pretty demeaning way of framing things. Indeed it’s a tongue-in-cheek remark, a vhimsical exaggeration/description of the by-default UB of those languages which was added to the end of the completely factual description of the role that finding UB in the Safe Rust subset of the standard library of Rust serves.

Of course one cannot, from the Rust Side so to speak, use tongue in cheek, off-hand remarks in these discussions; one must painstakingly add footnotes and caveats, list and mention every trivial fact like “you can get UB in unsafe blocks”[1] or else you have a “double standard”.

[1] Obligatory footnote: even though all participants in the discussion clearly knows this already.

Re:DARPA: Translating All C to Rust (Tractor) by Calavar on Tuesday July 30, 2024 @07:11PM (#41115024)
> Do you think UB-as-feature is something that someone would honestly describe C or C++ as?

Yes. That's how I describe it. That's also how Ralf Jung (long time Rust contributor and one of the main people behind Miri) describes UB in both Rust and C++ (although he says C++ overdoes it) [1]

The thing I edited out of my comment was "motte and bailey fallacy" because after reflecting a bit I thought it was unfair. But now you're actually trying to retroactively reframe as a joke.

[1] https://blog.sigplan.org/2021/11/18/undefined-behavior-deser...

Re:DARPA: Translating All C to Rust (Tractor) by keybored on Wednesday July 31, 2024 @10:23AM (#41119440)
> Yes. That's how I describe it. That's also how Ralf Jung (long time Rust contributor and one of the main people behind Miri) describes UB in both Rust and C++ (although he says C++ overdoes it) [1]

Okay. Then I was wrong about that.

> The thing I edited out of my comment was "motte and bailey fallacy" because after reflecting a bit I thought it was unfair. But now you're actually trying to retroactively reframe as a joke.

What a coincidence. I had written on a post-it note that you were going to pull out an Internet Fallacy. (I guess it’s more about rhetoric.)

I guess you’ve never seen someone explain after the fact that they were being tongue in cheek (it’s not a joke, it’s an exaggeration)? Because jokes, sarcastic remarks are always clearly labelled and unambiguous? Okay then. I guess it was a Motte and Bailey.

Re:DARPA: Translating All C to Rust (Tractor) by estebank on Tuesday July 30, 2024 @05:22PM (#41114262)
> That documented use of safe Rust can easily lead to UB

The only thing that comes to mind that this could be referring to are the open bugs at https://github.com/rust-lang/rust/issues?q=is%3Aopen+is%3Ais.... Are these what you're referring to?

> this infernal 'internal compiler representation'

What makes MIR "infernal"?

> I'm not even sure what is even remotely confusing about that?

You posted a link to a tool that executes pure rust libraries and evaluates memory accesses (both from safe and unsafe rust code) to assert whether they conform to the rust memory model. It sits in the same space as valgrind. You left it open to interpretation with really no other context. We can be excused for not knowing what you were trying to say. I personally still don't.

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.

Re:DARPA: Translating All C to Rust (Tractor) by the8472 on Tuesday July 30, 2024 @03:09PM (#41113012)
The trophy cases in miri are about bugs in unsafe code. Yes, you can write UB with unsafe code. This should not be news.

And miri is a blessing. There even is a known case where someone found a bug in C by translating it to rust and then running it through miri.