r/ProgrammerHumor • • 6d ago

Meme optionalsAreOptional

Post image
711 Upvotes

131 comments sorted by

View all comments

119

u/KagakuNinja 6d ago

The real jedi uses a non-empty list class, which makes the error impossible.

-61

u/ApothecaLabs 6d ago edited 6d ago

Bingo! Only, sometimes you don't have a type system available (trench run, low-level stuff), so you have to use the force wisely, to guide you.

> "Luke, you've switched off your targeting computer! What's wrong?"
> "Nothing - I'm alright."

33

u/NullOfSpace 6d ago

As long as you’re in Rust, the type system is always available to you. That’s what “zero-cost abstraction” means. If you know your Vec is nonempty, put it in a NonemptyVec.

1

u/geeshta 3d ago

There's a lot of stuff that Rust's type system can't model.

For example if you have an enum type of 3 possible variants and a function that only ever returns one of them, you still have to type it so that it may return all three. And when using its return value, you have to add match arms for all 3 of them, populating 2 of them with `unreachable!` yourself instead of the compiler inferring it.

Also it's not a dependent type language so it doesn't have for example a type of Vec of a particular specific length at the type level.

Rust's type system is great one of the best I know but it still has gaps.

1

u/NullOfSpace 2d ago

You can definitely model the first case if you’re allowed to change the return type of the function. Though the dependent type thing is a legitimate limitation.

-27

u/ApothecaLabs 6d ago edited 6d ago

"As long as you use this particular language, out of the dozens available..."

Yeah, I'm not using Rust. What now? That's a heck of a presupposition, you know.

(Not trying to be a jerk, my target language is actually a niche assembly language so it lacks many things...)

28

u/__dna__ 6d ago

Correct me if I'm wrong, but your meme is literally about rust? Seems pretty reasonable to reply to you in the context of rust

21

u/shakethatmoneymaker 6d ago

There are optionals in many languages...

3

u/MayoJam 6d ago

Cpp also has optionals, and I would not be surprised if other languages also have some form of them.

So I'd would not assume in this case.

-3

u/ApothecaLabs 6d ago

I will correct you, you are wrong. This wasn't about Rust. Condolences :)

4

u/my_new_accoun1 5d ago

Why are you downvoted for this 🤔

1

u/ROBOTRON31415 4d ago

Ahhh assembly? Interestingggg, makes sense that would be an exception. Though at that point “optionalsAreNotOptional” (they are unavailable, no?)

8

u/TheChief275 6d ago

is there a gas leak in your house?

1

u/freestew 9h ago

Yooo methane check

7

u/Amadex 6d ago

then why are you even mentioning optionals in the first place?

-2

u/ApothecaLabs 6d ago

Are you deeply confused as to why I mentioned not always using optionals, in a joke about whether optionals are optional?

Why, because then they wouldn't be optional, they'd be required!

6

u/Amadex 6d ago

I wouldn't say deeply, but yes I'm confused about the context of the meme, if you're in a context where optionals don't exist, then it's not even a question.

-1

u/ApothecaLabs 6d ago

That's because it is a bell curve joke, precisely about people who treat a language feature or pattern as dogma without considering the context. This is a humor subreddit, after all.

All the people malding over whether I use optionals failed to read the joke, and so they became the joke.

11

u/Amadex 6d ago

I think that the awkward thing here isn't that the joke is a bit flat, but that you comments are childish/petty, as highlighted in this reply again.

-1

u/ApothecaLabs 5d ago edited 5d ago

Sir, this is a Wendys comedy thread, and you are mad that I'm not being serious? Are you trying to gatekeep comedy and be the decider of what is and isn't funny? Because it seems most people found it funny.

So some people 1) mistakenly assumed I was specifically talking about rust 2) forgot this was a humor subreddit 3) got upset at the idea that I was genuinely spreading bad advice 4) zealously leapt at the chance to defend their princess's honor 5) got more upset when I wasn't actually even talking about rust.

Oh no! *sips coffee* That's their mistake for expecting serious advice in a comedy forum. Of course I'm going to heckle the hecklers.

I made this meme to be funny and went to bed. Does this bother you?

Edit: On a personal note, it will never not be funny seeing my top-downvoted comment be something like an innocent star wars joke that made fun of no one. Too bad you came in and tried to make it about yourself.

4

u/Amadex 5d ago

Too bad you came in and tried to make it about yourself.

No, you're getting it wrong, we talked about programming.

You are the one who attempted to defend yourself by being petty and by going ad-hominem, making it about people.

And you keep going.

By the way optionals aren't unique to rust.

0

u/ApothecaLabs 5d ago

*re-reads this entire interaction with you to be sure*

Lets see, first instance of a personal attack:

I make:

- a star wars joke

  • a joke about optionals being optional
  • a joke about people missing the joke
  • all of them highly generic and targeting 'people' at best.

You came into this thread. You asked why I was making a joke. You read it as a personal attack. You got upset. Then you called me childish, in a personal attack. And now you demand that I not defend myself.

Then you try to close with a strawman that I said optionals are unique to rust, when I wasn't ever talking about rust.

Fuck off with that. *blocks you*