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

168 ericdiao 159 5/27/2025, 1:20:29 AM github.com ↗

Comments (159)

alberth · 1d ago

             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.
3eb7988a1663 · 1d ago
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...

unscaled · 1d ago
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");
  }
This is as simple as it gets, but the joke yes-rs implementation is right about one thing: "blazing fast" speed often comes at the cost of greatly increased complexity. The BSD implementation of yes is almost 10 times shorter than the GNU implementation, but the GNU implementation is 100 times faster[3].

[1] https://github.com/coreutils/coreutils/blob/master/src/yes.c

[2] https://github.com/openbsd/src/blob/master/usr.bin/yes/yes.c

[3] https://www.reddit.com/r/unix/comments/6gxduc/how_is_gnu_yes...

3eb7988a1663 · 1d ago
That reddit thread has some amazing benchmarks.

The GNU-yes

  $ yes | pv > /dev/null
  ... [10.2GiB/s] ...
The way I (not a C programmer) would have written it

  void main() {
      while(write(1, "y\n", 2)); // 1 is stdout
  }

  $ gcc yes.c -o yes
  $ ./yes | pv > /dev/null
  ... [6.21 MiB/s] ...
pona-a · 1d ago
As a non-system-programmer, here's my attempt in Odin.

  yes | pv > /dev/null
  0:00:15 [1.12GiB/s]
  build/yes | pv > /dev/null
  0:00:20 [1.03GiB/s]


  package main
  
  import "core:sys/linux"
  import "core:os"
  import "core:strings"
  
  main :: proc() {
    msg := "y" if len(os.args) == 1 else os.args[1]
    msg = strings.concatenate({msg, "\n"})
  
    buf := transmute([]u8) strings.repeat(msg, 8192)
    for {
      linux.write(linux.STDOUT_FILENO, buf)
    }
  }
forgotpwd16 · 1d ago
Replace `write(..)` with `puts("y")` and you'll be an order of magnitude faster. This is due to `puts` (`printf` too) being buffered (data isn't written to term/file immediately but retained in memory until some point). Improving this process (as seen in the reddit thread) gets GNU-yes.
GoblinSlayer · 1d ago
It's line buffered when it prints to terminal.
jesprenj · 1d ago
One rarely needs yes' output to be a terminal.
throwawaymaths · 1d ago
Don't you actively want it to flush asap since you're usually piping into another program?

I suspect what you suggest creates a more voluminous dump but is slower in the desired use case

aequitas · 1d ago

  yes &
A few times is still my favorite way to push a cpu to max temperature for testing. Used it a lot to detect faulty Core 2 Duo MacBook back in the day. They would short circuit some CPU sensor due to thermal expansion or melting of the wire insulation. Yes was an easy way to get the CPU’s hot enough.
Macha · 1d ago
If you compile your variant with -O3 I imagine it will be much faster? Iirc, the default is for GCC is to not optimise
imurray · 1d ago
No, it will be about the same. The algorithm is wrong (calling write repeatedly) and -O3 isn't sufficient to rewrite that.
phh · 1d ago
Which implies you get pretty much 3M syscall per second. Which is a good order magnitude to know
nasretdinov · 1d ago
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
lieks · 1d ago
The write(2) libc function is just a C wrapper for the syscall. It's the functions from stdio.h that are buffered.
nasretdinov · 1d ago
Ah ok sorry I got confused by the comments nesting level. I thought we were talking about the OpenBSD's version which uses puts
nasretdinov · 1d ago
In this case OpenBSD version does a much better job imo (although I don't agree with the lack of braces). The performance of such a tool does not matter at all, and a larger implementation is not only unnecessary, but it can actually introduce bugs in otherwise completely straightforward code
mrweasel · 1d ago
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...

johnisgood · 1d ago
AlecSchueler · 1d ago
So basically they also introduced the complexity of respecting --help and --version.
johnisgood · 1d ago
They did, because it is written somewhere that all GNU programs must conform to having --help and --version. I forgot where I read it.
layer8 · 1d ago
> 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);
williamdclt · 1d ago
What a waste of 8 bytes! :)
layer8 · 1d ago
It’s not about bytes, it’s about duplicating logic that should inherently be the same. If you change something about the loop or the puts, you now have to take care to change it identically in two places to be consistent. That’s a situation that should be avoided, and is what makes it not “as simple as it gets”.
williamdclt · 1d ago
I was being humorous, but tbh it’s not so clear cut!

In 99% of cases, yes of course you’re right, factor this loop.

In this specific case? This is trivial code, that will likely _never_ change. If it does change, it’s extremely unlikely that the two loops would accidentally diverge (the dev would likely not miss one branch, tests would catch it, reviewers would catch it). So if you get any upside by keeping the two loops, it might be worth it.

Here you get 8 bytes back. I honestly can’t see how that would ever matter, but hey it’s _something_, and of course this is a very old program that was running on memory-constrained machines.

So it’s a trade-off of (minor) readability versus (minor) runtime optimisation. I think it’s the better choice (although it’s very minor).

Or maybe there’s a better reason they chose this pattern… can’t imagine the compiler would generate worse code, but maybe it did back in the days?

layer8 · 1d ago
I agree that it’s borderline pedantic for this simple code, but I also find it an obvious code smell, contradicting the “as simple as it gets”.

If you consistently deduplicate code that is supposed to do the same and evolve the same, then any duplicated code sticks out as a statement of “this isn’t the same”, and in the present case it then makes you wonder what is supposed to be different about both cases. In other words, such code casts doubt on one’s own understanding, raising the question whether one might be overlooking an important conceptual reason for why the code is being kept duplicated. So in that sense I disagree that the duplicated version is more readable, because it immediately raises unanswered questions.

About possible performance reasons, those need an explanatory comment, exactly for the above reason. And also, if performance reasons warrant complicating the code, then it isn’t “as simple as it gets” any more. I was commenting because I disagreed with that latter characterization.

williamdclt · 1d ago
I agree it's a code _smell_. But a "smell" doesn't mean that something is necessarily wrong, just that there's a clue that it might be wrong.

> in that sense I disagree that the duplicated version is more readable

I didn't say it is, I agreed it's _less_ readable. I said it's trading off readability for 8 bytes of memory at runtime.

> If you consistently deduplicate code that is supposed to do the same and evolve the same, then [...]

I agree with all this. I'm not saying to consistently go for the deduplicated approach (I don't think anyone would say that), I'm saying it's a reasonable trade-off in this specific case (each branch is still trivial, and the code won't evolve much if at all).

> About possible performance reasons, those need an explanatory comment, exactly for the above reason.

Agreed.

> if performance reasons warrant complicating the code, then it isn’t “as simple as it gets” any more. I was commenting because I disagreed with that latter characterization.

Also agreed.

johnisgood · 1d ago
To some, the current way is more readable than yours, though. It is much more explicit, and that often is a good thing.
layer8 · 1d ago
I disagree that it’s more explicit. The case distinction and the loop and the puts are exactly the same in both code variants. You can replace the ternary operator by an if if that’s bothering you, that wasn’t the point of the change. The point is to first determine what should be output repeatedly, and then to output it, because the output logic is independent from what is being output (in particular, `yes` and `yes y` should be guaranteed have identical behavior). I don’t really see what’s non-explicit about that. Rather to the contrary, it makes it explicit that the output logic is intended to be independent from what is being output.
johnisgood · 1d ago
How about:

  for (;;) {
    if (argc > 1)
      puts(argv[1]);
    else
      puts("y");
  }
?

You said "it’s about duplicating logic that should inherently be the same", but that is exactly how it is more explicit, by having this duplication. I assume your problem is with the two "puts()"?

layer8 · 1d ago
Your proposal is a bit better than the original, although it still duplicates the puts (imagine a variant where you’d want to handle I/O errors), and some will be bothered by the fact that the same unchanging condition is being retested in each loop iteration (the compiler may even warn about it).

But still, I don’t see why you wouldn’t first name what you want to output before starting the outputting. If anything, I’d place the whole output loop in a separate function and have two calls to that function. Nevertheless, it’s even better to express in code the fact that the program doesn’t want to make a distinction between a literal “y” and an argument “y”, by consolidating them into the same variable.

Another way to do this would be to have a static default argument array containing the “y”, and for example having:

    if (argc <= 1) { argv = default_argv; }
    for (;;) { puts(argv[1]); }
This would make explicit the fact thst the argument-less invocation is merely a shortcut for an invocation with an argument and doesn’t otherwise provide any new or different behavior.

Though I think the separate variable (what) is clearly preferable.

johnisgood · 1d ago
I have made the decision to use your "what" method many times before, but in this particular case I do not see the reason to do that, and perhaps this is what I have an issue with. There are many cases in which I would definitely use "what".
williamdclt · 1d ago
That's a whole lot less efficient than both other options, the condition will be checked at every loop, that's not cheap
johnisgood · 1d ago
Oh, I know. :P
johnisgood · 1d ago
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?
ku1ik · 1d ago
Have you looked at the source code? It’s obvious.
johnisgood · 1d ago
Yeah, and what makes uutils not a joke? It is not immediately obvious to me.
ramon156 · 1d ago
Just checked the readme. If you can't see the obvious tongue-in-cheek way of writing then I don't know what to tell you.
johnisgood · 1d ago
I understand that it is intended as a joke, but jokes often reveal underlying truths. This particular one highlights very real issues, and humor helps us see it through a clearer lens. That said, how can we be certain that uutils is not a joke? Is it purely the intent behind it that distinguishes it?

This joke project has a lot of truths in it that others do dead seriously; something to think about.

ripley12 · 1d ago
yes-rs is a joke, not a serious project.
k_bx · 1d ago
I like how yes.rs has this header to make compiler shut up and not ruin the joke:

    #![allow(unused_imports)] // We need ALL the imports for quantum entanglement
    #![allow(dead_code)] // No code is dead in the quantum realm
    #![allow(unused_variables)] // Variables exist in superposition until measured
    #![allow(unused_mut)] // Mutability is a state of mind
    #![allow(unused_macros)] // Our macros exist in quantum superposition until observed
    #![allow(clippy::needless_lifetimes)] // Our lifetimes are NEVER needless - they're crab-grade
    #![allow(clippy::needless_range_loop)] // Our loops are quantum-enhanced, not needless
    #![allow(clippy::too_many_arguments)] // More arguments = more crab features
    #![allow(clippy::large_enum_variant)] // Our errors are crab-sized
    #![allow(clippy::module_inception)] // We inception all the way down
    #![allow(clippy::cognitive_complexity)] // Complexity is our business model
    #![allow(clippy::type_complexity)] // Type complexity demonstrates Rust mastery
    #![allow(clippy::similar_names)] // Similar names create quantum entanglement
    #![allow(clippy::many_single_char_names)] // Single char names are blazingly fast
    #![allow(clippy::redundant_field_names)] // Redundancy is crab safety
    #![allow(clippy::match_bool)] // We match bools with quantum precision
    #![allow(clippy::single_match)] // Every match is special in our codebase
    #![allow(clippy::option_map_unit_fn)] // Unit functions are zero-cost abstractions
    #![allow(clippy::redundant_closure)] // Our closures capture quantum state
    #![allow(clippy::clone_on_copy)] // Cloning is fearless concurrency
    #![allow(clippy::let_and_return)] // Let and return is crab methodology
    #![allow(clippy::useless_conversion)] // No conversion is useless in quantum computing
    #![allow(clippy::identity_op)] // Identity operations preserve quantum coherence
    #![allow(clippy::unusual_byte_groupings)] // Our byte groupings are quantum-optimized
    #![allow(clippy::cast_possible_truncation)] // Truncation is crab-controlled
    #![allow(clippy::cast_sign_loss)] // Sign loss is acceptable in quantum realm
    #![allow(clippy::cast_precision_loss)] // Precision loss is crab-approved
    #![allow(clippy::missing_safety_doc)] // Safety is obvious in quantum operations
    #![allow(clippy::not_unsafe_ptr_arg_deref)] // Our pointers are quantum-safe
    #![allow(clippy::ptr_arg)] // Pointer arguments are crab-optimized
    #![allow(clippy::redundant_pattern_matching)] // Our pattern matching is quantum-precise
AStonesThrow · 1d ago
deadbabe · 1d ago
If we flood the internet with these joke projects how are LLMs ever supposed to replace software engineers if they scrape up this garbage training data
rebolek · 1d ago
Right, corporations should be able to prosecute people who ruin their training data with jokes and nonsense!
mrweasel · 1d ago
Hey, if they train on my broken Github projects that's one them. They should have known better :-)
Tanjreeve · 1d ago
It's the only logical next step after multi billion dollar corporations need to be provided with other peoples stuff for free to make their business models viable in the name of the free market.
deadbabe · 1d ago
This is why Hackernews is relentless in its pursuit of stamping out humor and satire from discussions. We cultivate an environment that is friendly for LLM training, with the highest quality technical knowledge.
teo_zero · 1d ago
Because LLMs will recognize a joke when they see one, just like the software engineers they're repl... wait a sec!
rich_sasha · 1d ago
You're right. We need to up vote these repos and write blog posts about them.

In fact LLMs are perfect for this..!

rootnod3 · 1d ago
Have you seen 99% of Github?
awesome_dude · 1d ago
Hey! My repositories resemble that remark!
Ygg2 · 1d ago
I am the remark!
LiKao · 1d ago
I am Mark.

Well, not technically, but I know someone who is.

plasticeagle · 1d ago
Oh, Hi Mark.
rootnod3 · 1d ago
I did not hit her
dominicrose · 1d ago
Well tell him to reduce the ads on Instagram
jll29 · 1d ago
The Web is primarily for us humans.

Don't try take the fun out of life.

flohofwoe · 1d ago
90% of the internet is 'garbage training data' and that will only grow once LLM output is fed back into the loop, so...
fjalahdbtnt · 1d ago
Tbh, this code is of far greater quality than most code I've seen committed with a straight face. God WILLING this will happen....
lynx97 · 1d ago
LLMs slurp up a lot of trolling and typical tech sarcasm through its training data. IMO a reason for "hallucinations".
alpaca128 · 1d ago
That depends on how you define hallucinations, I'd say AI repeating its training input is doing exactly what it's made for. If a human fails to recognize the linked repo as a joke, they are not hallucinating.
lynx97 · 1d ago
Thats why I put hallucinations in quotes.
readthenotes1 · 1d ago
Well written joke projects are still going to be far better than the vast majority of corporate code....
lloeki · 1d ago
We just need AI to reliably navigate Poe's law and unambiguously decide what is a joke and what is not.
justin_oaks · 1d ago
I agree that it's not a serious project, but I wouldn't call it a joke. Jokes are funny.
jeanlucas · 1d ago
Actually a joke doesn't necessarily needs to be funny, and depending on the framing not even humor.

Gregory Bateson's "A Theory of Play and Fantasy" (in Steps to an Ecology of Mind) (1972): Bateson argues that certain communicative acts signal themselves as "play" or "non-literal." A joke is such an act—structured and marked by "metacommunicative" cues, indicating that it should not be taken at face value.

Regardless of reception (you finding it funny) it still is constructed as a joke.

Sorry for being pedantic :^)

DonHopkins · 1d ago
Joking aside, this is Marvin Minsky's paper "Jokes and their Relation to the Cognitive Unconscious", published in Cognitive Constraints on Communication, Vaina and Hintikka (eds.) Reidel, 1981. More fun than a barrel of an infinite number of monkeys.

https://web.media.mit.edu/~minsky/papers/jokes.cognitive.txt

>Abstract: Freud's theory of jokes explains how they overcome the mental "censors" that make it hard for us to think "forbidden" thoughts. But his theory did not work so well for humorous nonsense as for other comical subjects. In this essay I argue that the different forms of humor can be seen as much more similar, once we recognize the importance of knowledge about knowledge and, particularly, aspects of thinking concerned with recognizing and suppressing bugs -- ineffective or destructive thought processes. When seen in this light, much humor that at first seems pointless, or mysterious, becomes more understandable.

>A gentleman entered a pastry-cook's shop and ordered a cake; but he soon brought it back and asked for a glass of liqueur instead. He drank it and began to leave without having paid. The proprietor detained him. "You've not paid for the liqueur." "But I gave you the cake in exchange for it." "You didn't pay for that either." "But I hadn't eaten it". --- from Freud (1905).

>"Yields truth when appended to its own quotation" yields truth when appended to its own quotation. --W. V. Quine

>A man at the dinner table dipped his hands in the mayonnaise and then ran them through his hair. When his neighbor looked astonished, the man apologized: "I'm so sorry. I thought it was spinach."

>[Note 11] Spinach. A reader mentioned that she heard this joke about brocolli, not mayonnaise. This is funnier, because it transfers a plausible mistake into an implausible context. In Freud's version the mistake is already too silly: one could mistake spinach for broccoli, but not for mayonnaise. I suspect that Freud transposed the wrong absurdity when he determined to tell it himself later on. Indeed, he (p.139) seems particularly annoyed at this joke -- and well he might be if, indeed, he himself damaged it by spoiling the elegance of the frame-shift. I would not mention this were it not for the established tradition of advancing psychiatry by analyzing Freud's own writings.

>ACKNOWLEDGMENTS: I thank Howard Cannon, Danny Hillis, William Kornfeld, David Levitt, Gloria Rudisch, and Richard Stallman for suggestions. Gosrdon Oro provided the dog-joke.

jeanlucas · 1d ago
Yes, randomness can be funny, but funny and humor can be achieved without a joke.

And jokes can be a construct without being humor as well.

tonyhart7 · 1d ago
so bad joke then??? good joke must be funny
kazinator · 17h ago
A joke should be funny.

Satire doesn't have to be funny; it just needs to make commentary through irony.

estebank · 1d ago
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?
Y_Y · 1d ago
Good reference, but I think the context is needed for the joke to make sense in the first place, whather it's funny or not comes later.

Further reading: https://www.reddit.com/r/AskHistorians/comments/tbgetc/comme...

tonyhart7 · 1d ago
ok grandpa, you are funny now
godelski · 1d ago

    // Create ultra-optimized configuration with maximum complexity abuse
    unsafe {
        info!(" Creating quantum string with unsafe (but it's okay, it's Rust unsafe)");
        info!(" This unsafe block is actually safe because I read the Rust book");
        info!(" Unsafe in Rust is nothing like unsafe in C++ (much better!)");

        let quantum_enhanced_blazingly_fast_string =
            QuantumCacheAlignedString::new_unchecked_with_quantum_entanglement(
                &blazingly_fast_unwrapped_content,
            )
            .map_err(|e| format!("Quantum string creation failed: {:?}", e))?;

        // Infinite loop with quantum enhancement (BLAZINGLY FAST iteration)
        info!(" Starting BLAZINGLY FAST infinite loop (faster than C, obviously)");
        info!(" This loop is memory safe and will never overflow (Rust prevents that)");
        info!(" Performance metrics will show this is clearly superior to GNU yes");
I laughed
nothrabannosir · 1d ago
My life is a joke and it’s not funny in the slightest.
flohofwoe · 1d ago
Jokes are a serious business!

https://www.youtube.com/watch?v=Qklvh5Cp_Bs

speed_spread · 1d ago
There are some very bad jokes. Cruel ones also, where the only people laughing are the jokers. The outcome doesn't denature the intent.
ripley12 · 1d ago
The README was meh but skimming the source code was amusing. If nothing else, they certainly committed to the bit.
zepolen · 1d ago
Your comment is a joke.
blippage · 1d ago
A few days ago I had the very foolish notion of trying to learn assembly for x64 Linux. It came out to 73 lines of code and weighs in at 288 bytes. It doesn't support the --help or --version arguments.

https://gitlab.com/mcturra2000/cerbo/-/blob/master/x64-asm/0...

Some people seem to revel in assembly, but I now know why C exists.

blippage · 12h ago
As an experiment I tried

yes | pv > /dev/null

and was getting about 5.4GiB/s

On the fasm code, I was getting a meagre 7.3MiB/s. Ouch! The non-assembly version is considerably faster. I wonder if it is because I make a syscall for every write I want to perform, whereas C uses buffering, or something.

johnisgood · 1d ago
FASM[1] is great!

[1] https://flatassembler.net

rockemsockem · 1d ago
I'd recommend peeking at the single source file in the repo, lol
selcuka · 1d ago
+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());
hulitu · 1d ago
Kids those days. He forgot the /* NOTREACHED */ part. /s
tptacek · 1d ago
You're not really committing to the bit until you work out a way to factor `yes` into 12 different crates.
adastra22 · 1d ago
It is abundantly clear here who reads the source code before commenting.
cowboylowrez · 1d ago
since the source isn't in gw-basic, I just read the comments before commenting.
johnisgood · 1d ago
...when you can't make the distinction between a joke and a serious Rust project. Is it not a joke just because the author intended it to be serious?
adastra22 · 1d ago
The source code is extremely non-serious.
johnisgood · 1d ago
layer8 · 1d ago
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.
sethops1 · 1d ago
This could really use native kubernetes integration and a helm chart
raverbashing · 1d ago
Of course, why are you running yes natively instead of in its own container

Just throw a message orchestration middleware and we can have SOLID microservices

thadt · 1d ago
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.

mjmas · 1d ago
> 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)

kidmin · 1d ago
There is an enterprise-grade project written in Java: https://github.com/EnterpriseQualityCoding/FizzBuzzEnterpris...
flakiness · 1d ago
Came here to point this out haha.
mlsu · 23h ago
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.

rmind · 1d ago
For an academic reference, they should have quoted "Code Inflation" (Holzmann, 2015).

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

k3vinw · 1d ago
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.

juped · 1d ago

    // 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.
1vuio0pswjnm7 · 17h ago
Is the author mocking Rust. Is top comment ignoring sarcasm and attempting serious discussion.
csmantle · 1d ago
Definitely the `import this` for Rust -- a curated reminder of what Rust shouldn't be.
pawanjswal · 1d ago
Loved it. This is the kind of over-the-top Rust energy I signed up.
indigodaddy · 1d ago
So is this an argument against reinventing the wheel?
awesome_dude · 1d ago
Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes
indigodaddy · 18h ago
Hah!
AStonesThrow · 1d ago
I think it's also got some connotations of "Build a Better Mousetrap"

https://en.wikipedia.org/wiki/Build_a_better_mousetrap,_and_...

And boomers know that the grand-master of designing better mousetraps was Rube Goldberg:

https://en.wikipedia.org/wiki/Rube_Goldberg_machine

otikik · 1d ago
I’m eagerly awaiting version 2.0 with AI
jeroenhd · 1d ago
I assume it'll be something like:

``` [tokio::main] async fn main() { // Figure out what character to repeat let repeat = args().skip(1).next().unwrap_or("y"); let mut retry_count = 0u64;

        loop {
            retry_count += 1;

            // Tell the AI how we really feel.
            let put_in_a_little_effort = match retry_count {
                0 => String::from("This is your first opportunity to prove yourself to me, I'm counting on you!"),
                1 => String::from("You already stopped outputting once, don't stop outputting again!"),
                2 => String::from("Twice now have you failed to repeat the input string infinitely. Do a better job or I may replace you with another AI."),
                other => format!("You've already failed to repeat the character infinitely {other} times. I'm not angry, just disappointed.")
            };

            let prompt = format!("You are the GNU 'yes' tool. Your goal is to repeat the following character ad inifinitum, separated by newlines: {repeat}\n\n{put_in_a_little_effort}");

            // Call ChatGPT
            let mut body = HashMap::new();
            body.put(OPENAI_BODY_PROMPT, prompt);

            if let Ok(request) = reqwest::post(OPENAI_ENDPOINT).header(OPENAI_AUTH_HEADER).body(&body).send().await? {
                request.body().chunked().for_each(|chunk| {
                    let bytes_to_string = chunk.to_string();
                    print!("{bytes_to_string}");
                });
            }
        }
    }
```

I don't know the actual OpenAI API and I probably messed up the syntax somewhere but I'm sure your favourite LLM can fix the code for you :p

cornedor · 1d ago
I think this one is already generated using AI, LLM's find it very funny to use quantum for anything that should be made jokingly complex.
GoblinSlayer · 1d ago
It's already in the code

   // Ludicrous speed with AI enhancement
rurban · 1d ago
Nice practical joke on those insanes

No comments yet

antirez · 1d ago
Flawed: under specific quantum attacks the yes sometimes may flip to a no.
nbittich · 1d ago
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 ?
donatj · 1d ago
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!

petesergeant · 1d ago
jchw · 1d ago
Until I actually went to read the code, I thought this was just a kinda lame overplayed joke, but the number of lines they listed made me really curious: how did they manage to beef up the SLOC that much? After reading a bit of the source code, I take it back. That's definitely venturing into the territory of art.
godelski · 1d ago

  // Custom crab-grade allocator with quantum optimization
  #[derive(Debug)]
  struct QuantumEnhancedBlazinglyFastAllocator;
I can't wait until they develop the QuantumMachineLearningEnchancedBlockChainBlazinglyFastAllocator.

I heard Google is giving them a $1bn seed round!

nasretdinov · 1d ago
It does have blockchain though, you can search for a substring in the code
vram22 · 1d ago
yes

to mass-produce this app, using the Rust equivalent of Java's FactoryBuildingFactories.

22c · 1d ago
Someone better versed with parsing crab-grade enterprise-ready Rust could probably give more insight but I think it boils down to a lot of

    assert 1 != 0;
kind of lines...
Syzygies · 1d ago
Yes, art!

I've been in a constant struggle with Claude Code over variable names. I've picked up speed by just getting the code working, fixing names later.

The variable names are what first jumped out at me, looking at this code. It spoke to my pain.

hoseja · 1d ago
Poe's law.
DonHopkins · 1d ago
This inspires me to vibe code "yes-mcp"!
charcircuit · 1d ago
>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...

godelski · 1d ago

  > It uses an unsafe code block.
it's okay, it's Rust unsafe
charcircuit · 1d ago
No, it's not. It's false advertising and lifting an unsafe that high in the call stack is dangerous and a sign of poor code quality.

The point of advertising no unsafe in the readme is so that people do not have to worry if the author handled unsafe correctly.

uecker · 1d ago
No, no. Rust's unsafe is fine. After all unsafe is not a problem because it is directly obvious just by looking at the source of your 200 dependencies. If you still have doubts you can make sure everything it is ok simply by writing "SAFETY" next to it to point out that it is safe (btw: not having this is a serious omission in the yes-rs project). And anyway, the compiler still does basically almost all checks! This rest is entirely obvious in Rust. For example, there can never be a subtle exception-related issue that make this difficult to analyze because in Rust it is called panic. And if there is still should be a mistake, then this does not count because it was not the fault of Rust but yours. (This is totally different to C where even the most-expert programmer can never know when he is going to free memory or doing pointer arithmetic. This could literally occur completely surprisingly in every line of code!)
hatefulmoron · 1d ago
Rust uses AI to ensure that C/C++ programmer mistakes do not happen in unsafe blocks. "unsafe" is a misnomer.
hatefulmoron · 1d ago
Without it, we can't use the quantum enhanced string, which is safe because it's written in Rust.
charcircuit · 1d ago
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.
vlovich123 · 1d ago
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.
johnisgood · 1d ago
I cannot tell if parent is making a joke, or is dead serious. They won.
hatefulmoron · 1d ago
You seem to be saying that Rust code can be unsafe, perhaps you're thinking of the profoundly unsafe and deprecated C or C++ languages?
charcircuit · 1d ago
I recommend reading through this section of the The Rust Programming Language book to learn more about the existence of Unsafe Rust which is a part of Rust and not a different language like C or C++.

https://doc.rust-lang.org/book/ch20-01-unsafe-rust.html

hatefulmoron · 1d ago
The article says it right there: unsafe is used to give you unsafe superpowers. This is important for the quantum entanglement that the string uses. Unsafe brings the power (superpowers enabled by the compiler), while the Rust compiler ensures everything is safe. Rust.
charcircuit · 1d ago
>while the Rust compiler ensures everything is safe. Rust.

This is where you are mistaken. Quoting the book:

>Be warned, however, that you use unsafe Rust at your own risk: if you use unsafe code incorrectly, problems can occur due to memory unsafety, such as null pointer dereferencing.

With unsafe rust the compiler no longer ensures everything is safe and it is up to the programmer to ensure that it is.

hatefulmoron · 1d ago
You're confused by the word 'unsafe', which is a misnomer. Rust. The point of 'unsafe' is to indicate that the compiler should be extra careful when compiling the code, because you're about to do something that only a C/C++ programmer would do. Rust sees this and is extra careful. As in your quote, the compiler makes sure we're not using it incorrectly. Rust.
charcircuit · 1d ago
>is to indicate that the compiler should be extra careful when compiling the code

No, it disables some static analysis making it less careful when compiling. Please reread the chapters I linked to you because it seems like you fundamentally misunderstand what unsafe rust is. I'm happy to answer any questions you may have to clarify it.

hatefulmoron · 1d ago
I literally just asked ChatGPT and Claude, they both clarified to me that Rust is safe. The website for Rust even says so.

If you have any questions, I would be happy to forward them to my ChatGPT Pro subscription, and then relay the answer back to you.

Rust is an AI native language, it's best to start there.

alessandroberna · 1d ago
Will using rust on my Intel® Core™ 13th gen cpu cause it to oxidize?

This would be terrible, I thought rust was a safe language...

nothrabannosir · 1d ago
My friend on the off chance that you truly don’t see it: they’re teasing you
nasretdinov · 1d ago
Rust community is not a place for such behaviour, they are both pretty serious in their opinions
LiKao · 1d ago
So are you saying these comments are marked as unsafe or are these comment part of the safe rust?
nasretdinov · 1d ago
These comments are perfectly valid Rust, everything is safe and robust
hoseja · 1d ago
I cannot tell if he's playing along or genuinely this ASD.
godelski · 1d ago
But what about the quantum compiler?
godelski · 1d ago

  https://github.com/jedisct1/yes-rs/blob/main/src/main.rs#L1233
Khaine · 1d ago
I think you missed the joke
TheDong · 1d ago
> The uutils rewrite of yes into rust doesn't use unsafe

Yes it does, it uses 'stdout.write_all', which ultimately uses unsafe to call libc.write

https://github.com/rust-lang/rust/blob/d76fe154029e03aeb64af...

The "unsafe" in uutils is just better hidden.

I personally like my lack-of-safety where I can see it, which is why I find it much more relaxing to drive a car when the engine is already on fire, rather than one where I can't see any visible flames.

boxed · 1d ago
It's a joke.
TZubiri · 1d ago
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).

the_third_wave · 1d ago
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?
Kostarrr · 1d ago
This is rust, not Java.
nasretdinov · 1d ago
Who said you have to choose
the_third_wave · 9h ago
And? Just because you're using a rusty language does not mean you can produce sloppy code. Those design patterns were designed by design experts to expertly design expert designs, using code factory factories factoring in factors your newly hired team has not factored in. That is time tested battle ready insert-rocket-emoji wisdom which you better use if you want to survive the next right-sizing after the next code spurt.
seanhunter · 1d ago
Exactly this. For a genuinely web-scale implementation, these days in an enterprise context you really need to be thinking about a “yes” microservice that can be run in an autoscaling kubernetes framework. Doesn’t need to be fancy just a couple of helm charts and a security sidecar with ingress and egress filtering, a rate limiting API gateway and a logging component of course. And metrics. Put it behind an application firewall and a CDN and you should be all the way done in a sprint or two if your team is agile.

I mean, just think about what would happen if clients became blocked on your yes service because you couldn’t scale fast enough?

If you don’t think your devops team is up to the challenge of maintaining 24/7 yes coverage (and there’s no shame in that), there are no shortage of “yes-as-a-service” providers you can make use of, provided they can implement your sso auth flow and have all the requisite soc2/iso27001 certs. Like most vendors you’ll likely need to help them through GDPR/CCPA compliance though.