Yes-rs: A fast, memory-safe rewrite of the classic Unix yes command

by ericdiaoon 5/27/2025, 1:20 AMwith 161 comments

by alberthon 5/27/2025, 3:02 AM

             Lines 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.

by selcukaon 5/27/2025, 3:56 AM

+1 for robust error handling:

    error!(" Quantum verification failed (this literally cannot happen in Rust)");
    error!(" The borrow checker should have prevented this...");
    error!(" This is probably a cosmic ray bit flip, not a Rust issue");
    error!(
        " In C++ this would have been a segfault, but Rust gave us a nice error"
    );
    return Err(format!(" Rust error (still better than C++): {:?}", e).into());

by tptacekon 5/27/2025, 5:04 AM

You're not really committing to the bit until you work out a way to factor `yes` into 12 different crates.

by adastra22on 5/27/2025, 4:26 AM

It is abundantly clear here who reads the source code before commenting.

by jupedon 5/27/2025, 4:36 AM

    // TODO: hide the unsafe keyword in a dependency
I don't get the quantum meme, but this is pretty on-point. "Output generation encountered a fearless concurrency issue" was pretty funny too.

by layer8on 5/27/2025, 10:27 AM

Looking at the source code, this seems to be missing localization. I would have thought that Rust’s type system would catch that. For example, the Uzbek word for “no” starts with a “y”, so this will lead to insidious bugs in that locale. Not locale-safe at all.

by sethops1on 5/27/2025, 5:07 AM

This could really use native kubernetes integration and a helm chart

by mjmason 5/27/2025, 12:12 PM

> DEPRECATION NOTICE: This crate will be abandoned in 6 months as per Rust ecosystem best practices. Start migrating to:

> • yes-rs-2 (rewritten with different dependencies)

> • yes-rs-ng (Angular-inspired architecture)

> • yes-oxide (WebAssembly-first approach)

> • yep (minimalist reimplementation)

by thadton 5/27/2025, 7:10 AM

This is a rather new project so this should be obvious, but anyone looking to use this should be wary of it's quantum resistant security claims (on line 1 no less). Scanning through the code, I didn't see any reference to any state of the art post-quantum algorithms. In its current state, it seems entirely possible that the output of this code could be broken by a future quantum computer.

I see there is an optimization flag for 'MICROSERVICE_ARCHITECTURE' and 'BLOCKCHAIN_ENABLED' which doesn't seem to be used anywhere else in the code yet. Perhaps that's part of the roadmap toward resolving this issue, and it's just not ready yet.

by petesergeanton 5/27/2025, 3:05 AM

The source is worth a look too:

https://github.com/jedisct1/yes-rs/blob/main/src/main.rs

by kidminon 5/27/2025, 12:02 PM

There is an enterprise-grade project written in Java: https://github.com/EnterpriseQualityCoding/FizzBuzzEnterpris...

by charcircuiton 5/27/2025, 3:49 AM

>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...

by TZubirion 5/27/2025, 3:25 AM

I feel like the safe equivalent of this is not to have it at all. You know when something FEELS wrong?

Like using selenium to automate a web task? Or like using javascript on the kernel? Or using C# on linux?

It just doesn't feel right to write an application whose mode of operation is unsafe (sending a string over IO) whose raison d'etre is unsafe (saying yes to everything without reading it), and to write it in a memory safe way.

It's like using a seatbelt when driving at 100mph, switching lanes in the highway, and drinking rum n coke(but with diet coke).

by rmindon 5/27/2025, 3:39 PM

For an academic reference, they should have quoted "Code Inflation" (Holzmann, 2015).

https://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=705...

by k3vinwon 5/27/2025, 9:40 AM

I’m glad to see that even the project issues get the same level of dedication and commitment to the cause: https://github.com/jedisct1/yes-rs/issues/2

This whole project is a work of art.

by csmantleon 5/27/2025, 5:13 AM

Definitely the `import this` for Rust -- a curated reminder of what Rust shouldn't be.

by mlsuon 5/27/2025, 8:46 PM

Related work here: https://github.com/mTvare6/hello-world.rs

It's great to see more of these utils written in blazing fast memory safe Rust.

by pawanjswalon 5/27/2025, 5:03 AM

Loved it. This is the kind of over-the-top Rust energy I signed up.

by indigodaddyon 5/27/2025, 4:23 AM

So is this an argument against reinventing the wheel?

by otikikon 5/27/2025, 7:13 AM

I’m eagerly awaiting version 2.0 with AI

by 1vuio0pswjnm7on 5/28/2025, 2:30 AM

Is the author mocking Rust. Is top comment ignoring sarcasm and attempting serious discussion.

by rurbanon 5/27/2025, 7:12 AM

Nice practical joke on those insanes

by the_third_waveon 5/27/2025, 5:02 AM

Nicely done but not enterprise ready if you ask me (which you did not but let's assume you did). Where is the 'y' factory factory factory method? Do you really think I can present this code as being ready for company-wide deployment (me and my virtual friends) without the solid foundation of all 26 design patterns clearly being implemented? Where is the code diversity statement, where is the code code of code coding conduct code code? How can I justify a team lead and product manager for a code base which fits in a thimble?

by antirezon 5/27/2025, 7:48 AM

Flawed: under specific quantum attacks the yes sometimes may flip to a no.

by nbittichon 5/27/2025, 5:28 AM

interesting, but we need the ability to also say no, using cuda core, quantization, distillation and vibe coding. do you think it's achievable with rust ?

by DonHopkinson 5/27/2025, 9:39 AM

This inspires me to vibe code "yes-mcp"!

by donatjon 5/27/2025, 10:15 AM

With the only real tangible thing I know about rust being that the "Rust by Example" introduced a macro in the very first example, it took me waaay too long before it clicked that this might be a joke.

The WASM related annotations had me rolling my eyes a bit, yet I'd seriously read to around line 200 before I started thinking "are you kidding me"

Good on you, you got me!

by hosejaon 5/27/2025, 9:51 AM

Poe's law.