Nice practical joke on those insanes
Yes-rs: A fast, memory-safe rewrite of the classic Unix yes command
121–130 of 170 posts
Re: Yes-rs: A fast, memory-safe rewrite of the classic Unix yes command
#122>100% Rust - No unsafe code blocks It uses an unsafe code block. https://github.com/jedisct1/yes-rs/blob/main/src/main.rs#L12... It also appears to log other stuff than y. The uutils rewrite of yes into rust doesn't use unsafe and is much simpler. https://github.com/uutils/coreutils/blob/main/src/uu/yes/src...
Re: Yes-rs: A fast, memory-safe rewrite of the classic Unix yes command
#123Earlier quoted context omitted.
It's written using unsafe Rust which means that the compiler will not be able to verify that it is safe. It's not guaranteed to be safe just because it is written in Rust. Please understand this, the author of this repo is spreading incorrect information.
The difference between a zealot and an evangelist is the ability to understand when someone is making a joke. I’ll let you figure out how you’re coming across here on your own as a growth exercise.
Re: Yes-rs: A fast, memory-safe rewrite of the classic Unix yes command
#124Lines of Code yes (GNU) 50 Yes-rs 1,302 (26x more) The cost benefit analysis on this will be interesting given this is 26X more code to manage, and could also introduce a whole new toolchain to build base.
If you are looking for a non-joke implementation[0]. Excluding the test code at the bottom, the Rust version is a bit less than 120 lines. [0] https://github.com/uutils/coreutils/blob/main/src/uu/yes/src...
Re: Yes-rs: A fast, memory-safe rewrite of the classic Unix yes command
#125Earlier quoted context omitted.
GNU core utils is 134 lines of code, not 50, so the Rust version is even slightly shorter. You can make yes a lot shorter in both C and Rust, but this size goes into speed. For reference, OpenBSD's yes is just 17 lines of code[2]. It essentially boils down to this: int main(int argc, char *argv[]) { if (pledge("stdio", NULL) == -1) err(1, "pledge"); if (argc > 1) for (;;) puts(argv[1]); else for (;;) puts("y"); } Thi…
The OpenBSD version of true is also amazing: https://cvsweb.openbsd.org/cgi-bin/cvsweb/~checkout~/src/usr... The GNU version of true/false is more interesting. All the logic is in true and false just redefined the EXIT_STATUS and imports all of true.c. https://github.com/coreutils/coreutils/blob/master/src/false...
Re: Yes-rs: A fast, memory-safe rewrite of the classic Unix yes command
#126Earlier quoted context omitted.
GNU core utils is 134 lines of code, not 50, so the Rust version is even slightly shorter. You can make yes a lot shorter in both C and Rust, but this size goes into speed. For reference, OpenBSD's yes is just 17 lines of code[2]. It essentially boils down to this: int main(int argc, char *argv[]) { if (pledge("stdio", NULL) == -1) err(1, "pledge"); if (argc > 1) for (;;) puts(argv[1]); else for (;;) puts("y"); } Thi…
> This is as simple as it gets It unnecessarily duplicates the for loop. I would have written something like: char *what = argc > 1 ? argv[1] : "y"; for (;;) puts(what);
Re: Yes-rs: A fast, memory-safe rewrite of the classic Unix yes command
#127Earlier quoted context omitted.
> This is as simple as it gets It unnecessarily duplicates the for loop. I would have written something like: char *what = argc > 1 ? argv[1] : "y"; for (;;) puts(what);
What a waste of 8 bytes! :)
Re: Yes-rs: A fast, memory-safe rewrite of the classic Unix yes command
#128Earlier quoted context omitted.
If you are looking for a non-joke implementation[0]. Excluding the test code at the bottom, the Rust version is a bit less than 120 lines. [0] https://github.com/uutils/coreutils/blob/main/src/uu/yes/src...
What do you mean non-joke? How can you tell? How is this a joke, and how is that not a joke?! What makes the distinction?
Re: Yes-rs: A fast, memory-safe rewrite of the classic Unix yes command
#129Earlier quoted context omitted.
so bad joke then??? good joke must be funny
Whether a joke is funny to a given person is context dependent. “A dog walks into a bar and says, ‘I cannot see a thing. I’ll open this one.’” Is this a good joke? Do you find it funny? If not, do you happen to be a Summerian circa 1983 BCE?
Further reading: https://www.reddit.com/r/AskHistorians/comments/tbgetc/comme...
Re: Yes-rs: A fast, memory-safe rewrite of the classic Unix yes command
#130Earlier quoted context omitted.
Which implies you get pretty much 3M syscall per second. Which is a good order magnitude to know
I don't believe puts is performing unbuffered I/O though. It's a libc function, not a direct syscall. Correct me if I'm wrong of course