4 ms·
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 mundan
by comex 7y ago
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.
- tiles 7y agoTwo 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!
- shpongled 7y agoAlmost 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.
- ncmncm 7y ago"New bugs for old! New bugs for old!" (With apologies to to Aladdin.)
- deleted 7y ago[deleted]
- dman 7y agoRust 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.
- estebank 7y agoI 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.
- namewasmypw 7y ago`unsafe` is already very prevalent in the ecosystem and this is a big point of contention. https://github.com/actix/actix-web/issues/289 https://github.com/actix/actix-web/issues/289
- arghwhat 7y agoThis would be anecdotal, and caused massive stir in the community when it was realized.
- beatgammit 7y agoAnd a lot of the usages were promptly fixed when people made a stink about it.
- jturpin 7y agoIt 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."
- cogman10 7y agoI 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.
- Matthias247 7y ago> 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.
- dataking 7y agoC2Rust 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.
- skainswoo 7y agoAutomatically rewriting raw pointers to Rust references would be amazing.
- TheCoelacanth 7y agoTo be fair, it calls itself a fork of Busybox, which implies that most of its source originated in Busybox.