243 points · by GhettoComputers · 4y ago · 314 comments
2016, 490 comments: https://news.ycombinator.com/item?id=11337399
> tldr: Rust/coreutils ( https://github.com/uutils/coreutils/ ) is now available in Debian, good enough to boot a Debian with GNOME, install the top 1000 packages, build Firefox, the Linux Kernel and LLVM/Clang.
BTW some notes on how the GNU coreutils are tested are at: https://www.pixelbeat.org/docs/coreutils-testing.html
This makes me really happy.
Separately from this, I've been wondering for a long time if there's a way for standards (and de facto standards) to share test suites for other implementers to re-use. Sort of a npm but only for test suites. Does such a thing exist? I wrote a TOML parser recently and had to re-derive the test suite from the specs.
> Could we get the best of both worlds by treating specification and compliance (testing) as a single problem? This hypothetical approach i call specification-driven development, whereby a specification document is intended both for human and machine consumption. In that case, the specification contains a written presentation of concepts, in addition to a machine-readable test suite that follows a certain format to programmatically ensure that the concepts and behavior described in the specification are implemented properly.
I've centered the document on my personal usecases (CLI and sysadmin checks) but i don't see a reason it couldn't be employed for API/ABI checks.
- Fix their own existing bugs - Help other projects to fix their bugs - Be explicit about what they support and what they don't - Help writing new libraries (eg in a faster language, or for another ecosystem)
For straightforward corner case acceptance tests (which I would assume covers most of the coreutils test suite) there's not really a danger of overfitting unless the developers are literally writing if statements that match a single input from the test and provide the correct output.
> ./target/debug/cp /dev/null /dev/zero
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Os { code: 1, kind: PermissionDenied, message: "Operation not permitted" }', src/uu/cp/src/cp.rs:1295:54
Good advice is "don't panic." Trying `mv`: > ./target/debug/mv . .
./target/debug/mv: cannot stat '.': No such file or directory
oofAnyways the point is that there's lots of legitimate institutional knowledge baked into coreutils and a naive RiiR effort will re-introduce previously fixed bugs.
The last one is a different kind. Rusts std lib indeed cannot stat . Which means they would have to translate . into the coreutils meaning manually. Their tests should have cought that one tho.
But the kernel can! I mean, stat() isn't a standard library function, it's a system call with (reasonably) well-defined semantics. And "." is a valid path, which returns a valid struct stat block representing a guaranteed-valid (cwd is always live; you're always "somewhere" even if the filesystem has removed the directory) directory.
Coming at this from the perspective of "translate . into the coreutils meaning" is almost certainly the wrong way to think about it. It's rust that has the broken picture of the filesystem environment, coreutils is just doing unix.
This isn't a Linux project, it is a cross-platform project.
There is "done" and there is "not done"...
I think we need to be more flexible than classifying things as done/not-done. Even GNU coreutils has open issues[0] - is it "done" or "not done"?
[0] = https://debbugs.gnu.org/cgi/pkgreport.cgi?pkg=coreutils
In this case, semi-done probably means what it usually means: some common cases are handled, while others aren't yet.
1. Not done. :-(
2. A lot has been done already, i.e. not just-started.
3. Not almost-done, i.e. there's significant work still to be done
I don't see the problem for something that was just released as a very preliminary version
(Though I don't know where cp is getting "PermissionDenied" from)
Fwiw the project os half a decade old.
> (Though I don't know where cp is getting "PermissionDenied" from)
Have not looked at the problematic code but e.g. copy_file_range(2) says
> EPERM fd_out refers to an immutable file.
GNU coreutils is one of the pillars of our civilization. Re-implementing it in several new languages can only benefit everybody, as it will lead to a higher understanding of all the implementations, including the original one.
So far, the tests of this Rust version seem to be used to compare against GNU coreutils, with a goal to attain feature parity. I hope in the near future, the careful memory management of Rust will motivate new tests that will be passed by the Rust version but failed bu the C one (e.g., some memory leak, or an input that triggers a segfault in the C version). Then, you will see a new curve in the graph concerning the number of tests failed by the C version, which at some point will cross the decreasing curve of the Rust version! The coverage of the rust implementation is still a bit sparse for that, but hopefully it will improve.
There is one feature, though, that is unfortunately missing in this Rust re-implementation: the fact that users of coreutils will always be able to examine the source code of the programs that they run. This is guaranteed by the original copyleft license. Βut this Rust version uses a "stealable" license that allows distributors of these programs to strip users of that right. This is really sad.
It's an interesting experiment to replace such a fundamental dependency with a rewrite. A lot of the build failures are due to uutils not implementing GNU extensions, some of which can get pretty involved.
[0] https://github.com/NixOS/nixpkgs/pull/116274
[1] https://github.com/NixOS/nixpkgs/pull/116274#issuecomment-85...
[2] https://github.com/NixOS/nixpkgs/pull/116274#issuecomment-86...
If this truly injures you, you can either do your own rewrite or, like Muse Group, outright buy the rights to the software and relicense.
https://github.com/uutils/coreutils/issues/1781
Honestly, it sounds like they're deeply scared of long-standing FSF-backed software having to compete (or even be replaced) with alternatives that just happen not to be GPL (e.g. they have similar thoughts on LLVM/clang), to the point where they decide to troll the issue trackers. It feels really childish.
LLVM/clang is worse than just GPL, as far as I understand the design of GCC is intentionally horribly bad to make it painful to integrate with a proprietary tool chain. Of course this means that things like refactoring support end up being basically impossible to build on GCC, so people move to clang out of necessity.
These days GCC does have a plugin interface, but they came up with a really funny hack to try to stop people from using proprietary plugins. Programs compiled with gcc can require linking with libgcc, and the libgcc license is "GPL, except it doesn't apply to software compiled with GCC and all-Free plugins". So their idea is that if you add a proprietary plug-in to GCC, that makes all code compiled like that have to be GPLed instead.
It is, of course, questionable whether this hack would hold up in court. It is also rather useless, because it's not hard to reimplement enough of libgcc to make it work. For example, the Linux kernel only links with libgcc for a few architectures.
They are, for good reason. Big companies hate open source, despite their claims to the contrary. Look at Apple's proprietary forks of all the BSD stuff, and handset manufacturers' proprietary forks of Android. The FSF should absolutely be doing everything in their power to minimize how often this happens.
What forks of what stuff?
Not to shit on the project, just that the title made it seem like something ready to use .. (most of the tests are still failing)
But to answer your question about Windows:
Because requiring an emulation layer is a huge step up in complexity from being able to distribute your shell as a single static binary which is just a few MB. Right now Elvish and Nushell, for example, can be deployed on Windows as binaries that don't require any external dependencies, any installation procedure, or any configuration. If they could link against uutils statically, they could also come with basic utilities without having an environment to manage.
WSL (along with MSYS2 and Cygwin) is deeply stateful. Now to make sure everything is working you have to check the compatibility of your whole system, and the versions of coreutils can still vary in addition to the version of the shell interpreter.
WSL2 also requires virtualization, which can complicate using it under virtual machines.
You may not want everything you run under your shell to depend on WSL, which is also happens with WSL2.
Even with WSL1, a script that requires a chroot environment to deploy and run it is way less portable than one that doesn't.
(rm, cp require -r, mv doesn’t, no auto-directory creation for mv - if you don’t believe me look at git/hg which don’t copy the semantics + I’d like reliable dry run and by default confirm every destructive action)
These are all like that on purpose.
mv doesn't have -r because it's a safety feature for rm and cp, since deleting or copying an entire directory is expensive so you should have to specify it explicitly. Moving a directory is really just renaming it, which isn't expensive when it's on the same filesystem (and it usually is).
The most common case for the destination directory not existing when moving something is a typo in the path. Then you'd end up creating a directory you didn't intend to, possibly on a filesystem you didn't intend to, and moving all the other arguments over there. It could be useful to make it possible to explicitly specify that you want this, similar to mkdir -p, but you could add that to the existing mv without breaking anything.
rm /home/john/some/file.txt
But you accidentally type:
rm /home/john some/file.txt
It says:
rm: cannot remove '/home/john': Is a directory
Instead of john not having a home directory anymore.
And people aren't going to use a dry run option or interactive confirmation every time they run a simple command like that.
And copying them is still actually expensive. Data expands to consume all available space. Accidentally copy a 16TB directory structure and you're going to max out the I/O on your machine for hours and maybe run it out of space. It's not a big ask to type two characters to confirm that you want to do that.
These make total sense for me.
also, a minor nit: there are still a lot of work [1] that needs to be done, and imho, it is a bit premature to title this article as is presented here.
Which isn’t to say anything about how a project ought to be licensed; just that MIT enjoys overwhelming popularity with newer projects.
For me, for example. I personally prefer my foundations on xGPL (preferably V3 and later), because some company or set of companies just can't fork and run away with it.
I personally consider computing utilities and compilers essential infrastructure and their sustainability while being completely transparent are critical for me.
What matters is whether they contribute back anything to open source. And it's a hell of a lot easier to get Legal to sign off on contributing back bug fixes and enhancements on a piecemeal basis rather than adding a recurring obligation to the books.
For me. I want my software to be as much gplv3 as possible. Not trolling. Also not arguing, it's just the way I roll.
well, ever wondered why router vendors include GPL license paper in the box? this [1] is why...
[1] https://www.crn.com/news/applications-os/205100091/busybox-s...
FreeBSD and clang communities, maybe not so much.
You have been misinformed. The GPL is a much better license for users. MIT is arguably better for the authors because they can deny certain freedoms to their users (the ability to change the code on a system, for instance).
Flame war! Flame war! Flame war!
You're stupid and probably ugly for wanting a flamewar!
I think most don’t care, and big corps love the MIT license
EDIT: Just checked, it is still there! And... It doesn't contains sudo. Can't see a good reason why.
(I understand being worried about the license of libs you're going to deploy, but the license of cli utils isn't something you need to worry about "infecting" your proprietary code.)
The problem with POSIX is that, while it's possible to implement the bare minimum, it's hard to not have a few extensions. There are some truly braindead ideas that GNU coreutils have absolutely improved upon.
Sadly, a new coreutils collection simply brings further incompatibility. There's already significant switching logic out there to handle BSD vs GNU coreutils (have you ever used sed -i?), adding another flavor makes this sort of thing dead on arrival, at least to me. I'm not retrofitting my scripts to support these implementations too.
Aside, Nix is the only real solution to this problem, as it can replace these tools wholesale, hermetically. Being able to depend on a specific implementation in a portable manner is rather compelling.
I wonder why some people in the Rust community seem to remind us every few sentences how Rust is superior to C because it's safer.
/s And now it's C, yesterday it was C++... what's next, ASM ?
than
"We did it in Rust, and we believe it's better because ..."
?
> However, those projects are written in platform-specific C, a language considered unsafe compared to Rust
Or to paraphrase it using your wording: "We did it in Rust and we believe it is better because it does not have memory unsafety issues that are the number #1 reason for security issues every year"
I know in GNU Guix the more Rust is used has lead to struggles in packaging and building from source for non-x86-64 architectures (demands of building the Rust toolchain, bootstrapping), e.g. [0]. With something like librsvg [1] being a very low level dependency now, Rust has become rather integral to many parts, with any changes to these libraries requiring massive rebuilds for a source-based reproducible distro like GNU Guix.
[0] https://lists.gnu.org/r/guix-devel/2021-11/msg00197.html
I fell in love with the performance of rust CLI tools and mainly see its utility as a fast performing binary, memory safety is a bonus but if I had known about its performance earlier I would have ignored anti rust propaganda like quoting Linus saying “Nothing better than C”.
And, yes, so-called "free concurrency" ended up being an incredible performance story, although, full disclosure, I/we were just able to use rayon in many places because Rust is just that composable.
This article is a good example
http://dtrace.org/blogs/bmc/2018/09/28/the-relative-performa...
EDIT: You may also be interested in https://github.com/mvdan/sh
Go and Rust are optimized for different types of environments. There are a lot of situations when selecting Go over Rust would be a more pragmatic choice. I don't see how coreutils is one of these.
I would feel differently if it were something else, like gawk, for example. Rust would be a better fit there.
https://news.ycombinator.com/item?id=29456115
I've tried making non-confrontational arguments in favor of the switch. Consider adding to them if you agree (or counter-arguing if you oppose, I guess) - but please keep the tone there less argumentative than here.
[1] And gcc with clang when bootstrapping
There's nothing wrong with GNU coreutils.
https://github.com/uutils/coreutils/issues/1781
I'm curious as to what extent GNU coreutils governance is tied to the FSF these days.
"While this may superficially look like a noble strategy, it is a condition that is typically unacceptable for commercial use of software. So in practice, it usually ends up hindering free sharing and reuse of code and ideas rather than encouraging it..."
If someone makes proprietary extensions to "ls", they are just going to be stuck maintaining a fork. There is no realistic threat here.
"Were all Unix commands re-written in Linux?"' https://unix.stackexchange.com/questions/85189/were-all-unix...
"Is the GNU Coreutils copied from Unix?" https://unix.stackexchange.com/questions/81302/is-the-gnu-co...
Personally, most of the software I write is under a 3-BSD or MIT license - unfortunately. I wish I were in a position to write more GPL code.
GNU coreutils are protected against a hypothetical proprietary ownership and I value that protection a lot.
As anybody can also see, from the reference you provided, the way the discussion was closed, with not a hint of an effort to reply, already raises a small red light. Had the project replied along the lines of: "Its the one we choose for the project" even without a rationale attached, would turn it less into the interesting event I think it is.
I think closing the discussion like that was entirely the right choice; this project already had to deal with a prior issue from FSF-affiliated individuals complaining about the license choice. It isn't the FSF's job to go around telling people their license choice is wrong on their issue trackers. This is just a waste of everyone's time.
As the project is called Coreutils...Its not to the FSF to tell others what license to use but its reasonable to ask for a clarification the project uses a different license.
As we seem to try to save time for everybody...Do you know if the project has a public reference, with the rationale for the current choice of license? ( Note: No criticism implied concerning their current choice)
a key person from FSF commented on the project. he didnt say it is not notable
on the other hand this is a rewrite of GNU coreutils, and as such FSF has every right to comment in the project
disclaimer: I did actually make the first commit on one of these tools, but I didn't look at the source of the original C code.
Not looking is a strong legal defense for whatever you wrote not being a derivative work. Looking just means you can't use that defense, it doesn't mean you actually copied code.
Given the significantly different paradigms of Rust and C, and that most coreutils don't really do that much algorithmically, it would be pretty easy to avoid accidental copying with this kind of project.
For example, significantly identical code flow, variable naming, or function structure would be red flags, especially if it's not the "obvious" implementation.
Seems a bit counterproductive.
True, it's incredible how badly the FSF has done in terms of actually marketing their licensing structure. At this point I doubt most developers care much.
>Rust provides a good, platform-agnostic way of writing systems utilities that are easy to compile anywhere, and this is as good a way as any to try and learn it.
If you want some software to be platform agnostic, you can write it in C in a way that is not platform specific. So rewriting some software in Rust to be platform agnostic doesn't seem a good reason for a rewrite. Also, even if the C software to be rewritten isn't platform-agnostic, at least some part of it is, so by using C you don't have to rewrite everything.
I'm sure that Rust can have a lot of valid use cases but the trend of "Hey, let's rewrite X in Rust just because ..." I don't agree with.