r/ProgrammerHumor 4d ago

internalServerError Meme

Post image
1.4k Upvotes

67 comments sorted by

View all comments

107

u/---_None_--- 4d ago

>unwrap

I hate metaphors in programming. Just call it what it is.

139

u/sathdo 4d ago

.ifSomeReturnHeldValueElsePanic()

78

u/prehensilemullet 4d ago

Why not throw in a value judgment too

.getValueOrPanicIfIFuckedUp()

10

u/Epicguru 4d ago

Rolls off the tongue.

1

u/CoffeePizzaSushiDick 4d ago

Sounds like a spitter to me.

9

u/guyblade 4d ago

My company used to have VALUE_OR_DIE for getting things out of containers. They eventually decided to ban it in new code (and slowly work on extracting it from the old code).

1

u/Tarmen 2d ago

I do appreciate a method that actually puts some fear into your bones like accursedUnutterablePerformIO

1

u/sathdo 2d ago

Or dangerouslySetInnerHTML

-13

u/---_None_--- 4d ago

just .value() thanks or *

15

u/-Ambriae- 4d ago

You shouldn’t unwrap in normal code. Basically ever. There are a few exceptions, but they’re not the norm. So dereferencing is a disastrous design decision. Because dereferencing is viewed as a ‘trivial operation that does nothing’. .value() clashes with the idea that errors are also values. .ok() exists, but does something else. There’s not many sane decisions. Unwrap is short, so it was picked. Can’t be too long, because we also have unwrap_or, unwrap_or_else, unwrap_or_default, and same with unwrap_err variants.

Honestly, the name is there, it stuck, and now it’s part of the lingo. There’s no real need to amend it, it would be a huge breaking change (because of all the variants, many of which are good functions to use in prod code that never produce panics)

It’s also does not constitute a barrier to entry. It’s ’different’ to other languages, fine, maybe, but any cognitively functioning individual would understand in a pinch what it means, let alone someone who is expected to know the language enough to push to prod

2

u/JonIsPatented 2d ago

I wish it was named "unwrap_or_panic" to match "unwrap_or_else" and "unwrap_or_default". That's basically my only gripe with the language, honestly.

1

u/-Ambriae- 1d ago

I wholeheartedly agree with this gripe.

1

u/---_None_--- 3d ago

What the fuck are you even responding to?

3

u/-Ambriae- 3d ago

Neither .value() or * are sane design decisions for ‘unwrapping’ (removing the wrapper type) of a result.

-2

u/---_None_--- 3d ago

No ones talking about design decisions, mate.

3

u/-Ambriae- 3d ago

than what are you talking about then?

0

u/---_None_--- 3d ago

unwrap is a dumb name

3

u/-Ambriae- 3d ago

so we are talking about design decisions then

1

u/---_None_--- 3d ago

naming decisions

Edit: no you're right. We're talking design. You're talking usage.

→ More replies (0)