Show HN: RustyBox – a Busybox fork written in Rust
github.com
github.com
* 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!
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.
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.
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".
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.
(With apologies to to Aladdin.)
Yes, literally. But figuratively, No, because you used the C as a higher order definition language and did translation not re-implementation.
So this might (in some cases) be bug for bug compatible (a good thing?) if the bug is a logic bug, not a C boundary error or a type cast effect or something not strictly defined. It isn't an "independently implemented suite" if you wanted to e.g. use it for conformance testing to a spec.
I don't see any LICENSE or COPYING files in the repo.
It's somewhat impressive that c2rust is can translate so much code, but without following it up with refactoring into more idiomatic Rust (which is a lot of work), this is merely replacing gcc with rustc.
https://git.busybox.net/busybox/tree/networking/httpd.c
Shame the rustybox version strips all the comments:
https://github.com/samuela/rustybox/blob/master/networking/h...
int COMMAND_main(int argc, char **argv)
and that it's compilable as a library already, I wonder if it would make more sense to use bindgen or the like to start with the actual busybox C code, but with a (trivial) Rust main function. You'd have the current busybox source compiling an ever-smaller library, and a Rust lib next to it. Then move things over to the Rust side one command at a time.I just wish that all Rust implementations would include a "Git" or "Docker containers" section as a stepping stone in the right direction for other projects.
can you write a program that opens a text file and dumps its contents on STDOUT? then you can write `cat`! and there are oodles of tools that are as simple as that.
the nice thing about contributing to a busybox-like distribution of coreutils is that they intentionally leave out the bells and whistles, since the target systems are memory-constrained. and you can do the development and testing right on your workstation. busybox is designed to be suitable for embedded devices, but the tools will run on any device with a linux kernel, as long as you can compile for the target CPU.