News for hackers. Stuff that matters.
Re:“Rewrite It in Rust” Considered Harmful? [pdf] by ericseppanen on Wednesday May 24, 2023 @12:43PM (#36060691)
"we model a scenario where the original code is memory-safe; the ported code is memory-safe; and we consider memory safety and undefined behavior that may arise across the FFI layer between the two pieces of code."

I may be stating the obvious, but that's a bit of a strawman. Yes, writing good FFI code is hard; yes it could result in security/soundness issues; yes, we could use better tools in this space.

But nobody rewrites C code in Rust if they believe existing codebase is free of memory safety hazards; they rewrite it because they think the result will contain fewer hazards, even accounting for the potential problems at the FFI boundary.

If I could remove tens of thousands of lines of hard-to-analyze C code, and replace it with tens of thousands of lines of safe Rust, paired with a few hundred lines of hard-to-analyze FFI adapters, that sounds like a pretty good tradeoff to me. I now know exactly where to focus my attention, and I can have confidence that the situation will only improve with time: better tooling may allow me to improve the dangerous FFI layer, and in the meantime I can recklessly improve the safe Rust module without fear of introducing new memory unsafety bugs, unsound behavior, or data races.

Re:“Rewrite It in Rust” Considered Harmful? [pdf] by morning-coffee on Wednesday May 24, 2023 @01:21PM (#36061312)
Exactly. No one is saying "rewrite it in Rust because it already works". They typically say it because the thing in question is a bug farm, or it's really difficult to maintain.

I looked for the author's (whoever they are) proposed solution and it's this:

"This is because many of the FFI bugs surveyed are fundamentally cross-language issues. Instead, we propose that both C and Rust must conform to a shared, formally-based domain-specific language, which provides a safe-by-construction abstraction over the FFI boundary."

Such a thing is a "new thing", and isn't going to retroactively apply to the legacy C code written before this new thing... so how does that help?

(Full disclosure: I'm a professional programmer who has written in C, C++, C# for many years, and now I choose to write new things in Rust.)

Re:“Rewrite It in Rust” Considered Harmful? [pdf] by aidenn0 on Wednesday May 24, 2023 @04:43PM (#36063630)
> Exactly. No one is saying "rewrite it in Rust because it already works". They typically say it because the thing in question is a bug farm, or it's really difficult to maintain.

Well some people are. Is there a word for attacking the weakest real version of an opposing argument? Strawman usually implies you are attacking a fake version of the argument, but on the internet you can usually find someone who actually holds an easily refuted point of view, just because of the law of large numbers...

Re:“Rewrite It in Rust” Considered Harmful? [pdf] by telotortium on Wednesday May 24, 2023 @06:39PM (#36064746)
* * *
Re:“Rewrite It in Rust” Considered Harmful? [pdf] by thisarticle on Wednesday May 24, 2023 @04:56PM (#36063746)
How’s the job market for Rust? Would someone with a good amount of Scala and Python experience and some Rust have a decent shot?
Re:“Rewrite It in Rust” Considered Harmful? [pdf] by sshine on Thursday May 25, 2023 @02:03AM (#36067502)
Scala, yes.

It’s still growing.

The companies that do commit to Rust usually have a fair amount of work ahead.

And the typical developers are C/C++ developers who sometimes bring a bunch of unsafe habits that make the whole transition kind of pointless.

Re:“Rewrite It in Rust” Considered Harmful? [pdf] by tinus_hn on Wednesday May 24, 2023 @05:13PM (#36063931)
> it's really difficult to maintain

Typically the Rust Evangelization Task Force does not include people who are actually going to maintain the software (or do the rewrite themselves).

Re:“Rewrite It in Rust” Considered Harmful? [pdf] by phamilton on Wednesday May 24, 2023 @01:05PM (#36061051)
> nobody rewrites C code in Rust if they believe existing codebase is free of memory safety hazards

I'd offer that even if the existing codebase is free of memory safety hazards, low confidence in future changes being able to keep it free of memory safety hazards in a cost efficient manner is a motivation to migrate.

Re:“Rewrite It in Rust” Considered Harmful? [pdf] by ericseppanen on Wednesday May 24, 2023 @02:12PM (#36061968)
This is so true.

The idea that a program can approach some optimal bug-free state, never to be modified or refactored again, doesn't resemble any project I've ever encountered.

Re:“Rewrite It in Rust” Considered Harmful? [pdf] by Szpadel on Wednesday May 24, 2023 @01:01PM (#36060975)
agree, i wanted to just add that this paper might be right for projects that are not actively developed anymore something like bash or coreutils etc, as there this is fairly well tested code and there aren't that many added features that could introduce issues.

for anything that is actively developed it's a whole other story, even if you are confident that the current codebase is safe, each added feature has a risk that it breaks some unwritten contract somewhere and introduces security issues.

eg. look at recent vulnerability in sudo, at and second sight it was safe and secure, triggering it required unobvious corner case.

how many of similar issues you could have in your codebase that could be dormant for years?

Re:“Rewrite It in Rust” Considered Harmful? [pdf] by knome on Wednesday May 24, 2023 @01:06PM (#36061068)
Re:“Rewrite It in Rust” Considered Harmful? [pdf] by Szpadel on Wednesday May 24, 2023 @03:49PM (#36063073)
I didn't mean that those projects are not maintained, rater that there aren't intensive changes anymore.

Coreutils:

> There have been 26 commits by 3 people in the 29 days since 9.2

Bash looks like didn't has any commit this year yet

Re:“Rewrite It in Rust” Considered Harmful? [pdf] by spoiler on Wednesday May 24, 2023 @04:25PM (#36063430)
> Bash looks like didn't has any commit this year yet

Does anyone know why this is? Is it because doing anything would cause POSIX divergence? Nobody wants to (because it's an "ugh experience")? It's considered effectively complete?

Genuinely curious.

I don't actually use Bash for my personal shell, thought. I do write bash scripts semi-regularly though.

Re:“Rewrite It in Rust” Considered Harmful? [pdf] by knome on Wednesday May 24, 2023 @04:41PM (#36063611)
All of the commits are from Chet Ramey, who the wiki says took over maintenance on bash just shy of 30 years ago.

It looks like its busy in the devel branch.

https://git.savannah.gnu.org/cgit/bash.git/log/?h=devel

The last commit from anyone else was Jari Aalto in 2009? Wow.

If he's committing on behalf of anyone else, it isn't mentioned in git.

The AUTHORS file is mostly Chet Ramey with occasional input from other FSF members.

Re:“Rewrite It in Rust” Considered Harmful? [pdf] by JodieBenitez on Wednesday May 24, 2023 @12:58PM (#36060921)
> But nobody rewrites C code in Rust if they believe existing codebase is free of memory safety hazards; they rewrite it because they think the result will contain fewer hazards

What if someone makes a strawman out of memory problems so they can rewrite it in Rust ?

Re:“Rewrite It in Rust” Considered Harmful? [pdf] by awestroke on Wednesday May 24, 2023 @01:10PM (#36061135)
Great, let them do whatever they want
Re:“Rewrite It in Rust” Considered Harmful? [pdf] by patrick451 on Wednesday May 24, 2023 @06:17PM (#36064546)
> But nobody rewrites C code in Rust if they believe existing codebase is free of memory safety hazards; they rewrite it because they think the result will contain fewer hazards, even accounting for the potential problems at the FFI boundary.

That's pretty generous. They re-write it in rust because a "Show HN: Thing-X, in Rust gets upvotes."

Re:“Rewrite It in Rust” Considered Harmful? [pdf] by notmypenguin on Thursday May 25, 2023 @12:54AM (#36067162)
Citation needed… lol

But seriously, that’s kinda silly to propose as a motive for a software project requiring significant effort.