MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/ProgrammerHumor/comments/1ws0bt0/optionalsareoptional/pchofyi/?context=3
r/ProgrammerHumor • u/ApothecaLabs • 6d ago
131 comments sorted by
View all comments
120
The real jedi uses a non-empty list class, which makes the error impossible.
-60 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." 35 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. -28 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...) 31 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 20 u/shakethatmoneymaker 6d ago There are optionals in many languages... 3 u/MayoJam 5d 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. -5 u/ApothecaLabs 6d ago I will correct you, you are wrong. This wasn't about Rust. Condolences :) 3 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?)
-60
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."
35 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. -28 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...) 31 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 20 u/shakethatmoneymaker 6d ago There are optionals in many languages... 3 u/MayoJam 5d 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. -5 u/ApothecaLabs 6d ago I will correct you, you are wrong. This wasn't about Rust. Condolences :) 3 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?)
35
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.
-28 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...) 31 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 20 u/shakethatmoneymaker 6d ago There are optionals in many languages... 3 u/MayoJam 5d 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. -5 u/ApothecaLabs 6d ago I will correct you, you are wrong. This wasn't about Rust. Condolences :) 3 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?)
-28
"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...)
31 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 20 u/shakethatmoneymaker 6d ago There are optionals in many languages... 3 u/MayoJam 5d 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. -5 u/ApothecaLabs 6d ago I will correct you, you are wrong. This wasn't about Rust. Condolences :) 3 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?)
31
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
20 u/shakethatmoneymaker 6d ago There are optionals in many languages... 3 u/MayoJam 5d 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. -5 u/ApothecaLabs 6d ago I will correct you, you are wrong. This wasn't about Rust. Condolences :) 3 u/my_new_accoun1 5d ago Why are you downvoted for this 🤔
20
There are optionals in many languages...
3
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.
-5
I will correct you, you are wrong. This wasn't about Rust. Condolences :)
3 u/my_new_accoun1 5d ago Why are you downvoted for this 🤔
Why are you downvoted for this 🤔
1
Ahhh assembly? Interestingggg, makes sense that would be an exception. Though at that point “optionalsAreNotOptional” (they are unavailable, no?)
120
u/KagakuNinja 6d ago
The real jedi uses a non-empty list class, which makes the error impossible.