News for hackers. Stuff that matters.
Re:Show HN: RustyBox – a Busybox fork written in Rust by comex on Thursday November 14, 2019 @05:18PM (#21540101)
Seems to consist mostly of a copy of Busybox’s C code auto-translated to Rust using c2rust – resulting in ubiquitous use of raw pointers and `unsafe` for mundane operations. That’s technically “written entirely in Rust”, but not in the way you’d expect… On the other hand, it could serve as a good starting point for a gradual rewrite into idiomatic Rust.
Re:Show HN: RustyBox – a Busybox fork written in Rust by dman on Thursday November 14, 2019 @05:30PM (#21540209)
Rust is going to take credibility hits if more people do this. Once it becomes socially acceptable to use unsafe all over the place in the community, it might be hard to win the user trust back.
Re:Show HN: RustyBox – a Busybox fork written in Rust by estebank on Thursday November 14, 2019 @05:43PM (#21540307)
I don't think 1) unsafe will ever become prevalent in the ecosystem nor 2) that unsafe should be seen as anything other than an escape hatch that is sometimes necessary.

Autotranslations from C will be seen as what they are, a transliteration from a less safe language with exactly the same bugs as the preexisting codebase. You could think of the case of calling a COM library that has a leak or a OOB error, I wouldn't blame the language doing the calling for the bug.

Having said that, these translations are still useful as a starting point, not a destination. Think of a case where the external C API is retained, but all the innards are gradually converted to a more idiomatic codebase.

Re:Show HN: RustyBox – a Busybox fork written in Rust by weberc2 on Thursday November 14, 2019 @06:06PM (#21540504)
> these translations are still useful as a starting point, not a destination.

This was the case for the Go compiler (automatic translation from C to Go), and it has worked out well in practice. There are still some vestiges, but it's moving more and more toward idiomatic Go all the time.

Re:Show HN: RustyBox – a Busybox fork written in Rust by skainswoo on Thursday November 14, 2019 @06:14PM (#21540568)
Yeah, this is the broad goal of the project. As much as I love fresh rewrites, I don't think they have nearly the same hope of becoming successful as this sort of gradual approach. It's a big project, and there's lots of code that's still not idiomatic by any means, but the goal is to get 1% better every day.
Re:Show HN: RustyBox – a Busybox fork written in Rust by tom_mellior on Friday November 15, 2019 @12:25PM (#21546711)
> Autotranslations from C will be seen as what they are, a transliteration from a less safe language with exactly the same bugs as the preexisting codebase.

Yes. But I agree with the parent that there is a credibility problem here. The featured repository calls itself a fork "written entirely in Rust" (emphasis mine). It doesn't call itself "autotranslated to Rust". There would be enough room for that in the title, but the author decided to spend that room on calling it "free-range, non-GMO" instead. It doesn't acknowledge the point you raise, that this is apparently much closer to a starting point than to the destination.

The README is somewhat circumspect about the fact that this is autotranslated. It does mention c2rust, but doesn't actually say anything about the status of a conversion to safe, idiomatic Rust. There is a long list of commits which suggest that the author did a lot of manual fixes, so something was done beyond just autotranslation, but it's hard to judge.

So I think the credibility danger is that if HN were to get more frequent "X written in Rust" that would turn out to just be "X autotranslated to Rust", at some point the community might tire of upvoting these, and other "X actually written in Rust" submissions might get buried. Or similarly, instead of a general "it's feasible and useful to rewrite X in Rust" impression, the wider community (somewhat open to Rust but not diehard fans) might get an impression of "even Rust fans are too lazy to actually rewrite stuff in safe Rust".

Re:Show HN: RustyBox – a Busybox fork written in Rust by wtetzner on Friday November 22, 2019 @03:09PM (#21609523)
But doesn't "fork" imply that it's not actually a re-write or a clone?
Re:Show HN: RustyBox – a Busybox fork written in Rust by namewasmypw on Thursday November 14, 2019 @05:50PM (#21540377)
`unsafe` is already very prevalent in the ecosystem and this is a big point of contention.

https://github.com/actix/actix-web/issues/289

Re:Show HN: RustyBox – a Busybox fork written in Rust by arghwhat on Thursday November 14, 2019 @06:00PM (#21540453)
This would be anecdotal, and caused massive stir in the community when it was realized.
Re:Show HN: RustyBox – a Busybox fork written in Rust by beatgammit on Thursday November 14, 2019 @06:20PM (#21540616)
And a lot of the usages were promptly fixed when people made a stink about it.
Re:Show HN: RustyBox – a Busybox fork written in Rust by jturpin on Thursday November 14, 2019 @06:50PM (#21540866)
It was only fixed when a fuzzer showed a lot of vulnerabilities. Up until then the attitude was "stop demonizing unsafe, we know what we're doing."
Re:Show HN: RustyBox – a Busybox fork written in Rust by cogman10 on Thursday November 14, 2019 @07:07PM (#21540997)
I don't know about those particular authors. However, the vibe I get from the rust community as a whole is "unsafe is where dragons lay". Most, I'd say, treat it just like inline asm in C++. Sometimes a necessary evil, but not something you should be in the habit of using.
Re:Show HN: RustyBox – a Busybox fork written in Rust by nicoburns on Thursday November 14, 2019 @07:20PM (#21541078)
Actix is currently popular, but only because the rest of the ecosystem has been waiting for `async-await`, and taking a slow-and-steady approach to getting things right. I'd expect Actix's popularity to take a dramatic downturn right about when Rocket releases a async version that runs on stable Rust.
Re:Show HN: RustyBox – a Busybox fork written in Rust by Matthias247 on Thursday November 14, 2019 @07:54PM (#21541267)
> Rust is going to take credibility hits if more people do this

I disagree on that. Rust also took a credibility hit for people advertising exactly the opposite: To rewrite things from scratch. While that approach certainly helps with getting idiomatic code right from the start, years of feature development will get lost, and the chances for introducing non memory related bugs are still there.

The ability to transfer a project to Rust in 1 step, and then to gradually improve it seems like a big plus to me. Of course it would not be great if projects are just auto-translated and then kept that way. But I don't think that is the intention of most authors who do that.

Re:Show HN: RustyBox – a Busybox fork written in Rust by tiles on Thursday November 14, 2019 @05:24PM (#21540156)
Two of the bullet points they list ask for help in doing this conversion:

* Replace some extern "C" includes with more idiomatic uses. Pretty straightforward find/replace-all usually does the trick. * Pick a utility, like cat or touch, and work on translating it into safer, more idiomatic rust. There are plenty of unsafes lying around that you can tackle!

Re:Show HN: RustyBox – a Busybox fork written in Rust by dataking on Thursday November 14, 2019 @06:45PM (#21540822)
C2Rust contributor here. Yes, the conversion to unsafe is indeed only intended as a stepping stone for a rewrite into idiomatic Rust. In fact, we're hard at work on a refactoring tool that will (hopefully, one day) take some of the tedium out of that process by doing things such as identifying raw pointers that can be upgraded to proper Rust references.
Re:Show HN: RustyBox – a Busybox fork written in Rust by skainswoo on Thursday November 14, 2019 @07:11PM (#21541028)
Automatically rewriting raw pointers to Rust references would be amazing.
Re:Show HN: RustyBox – a Busybox fork written in Rust by shpongled on Thursday November 14, 2019 @05:35PM (#21540251)
Almost seems like it would be easier to just write it from scratch in idiomatic Rust than to try and refactor a code base of this size that makes such extensive use of unsafe blocks and pointers.
Re:Show HN: RustyBox – a Busybox fork written in Rust by ncmncm on Thursday November 14, 2019 @08:37PM (#21541493)
"New bugs for old! New bugs for old!"

(With apologies to to Aladdin.)

Re:Show HN: RustyBox – a Busybox fork written in Rust by TheCoelacanth on Friday November 15, 2019 @11:58AM (#21546451)
To be fair, it calls itself a fork of Busybox, which implies that most of its source originated in Busybox.