r/ProgrammerHumor 16h ago

Meme iHateThisPassiveAgressiveBehaviourRuby

Post image
2.3k Upvotes

262 comments sorted by

View all comments

0

u/Key_Conversation5277 16h ago

But wtf is a "truthy" value? It doesn't make any sense nor mathematically nor programmatically

5

u/cosmo7 16h ago

Dynamic typing is like the dark side of the Force. At first it feels more powerful, but then it turns you into a murderous psychopath.

2

u/deceze 16h ago

Any value that causes an if statement to run its associated block, instead of going to else/doing nothing.

2

u/Nimeroni 16h ago

His argument is that you should make your if statement explicit.

1

u/deceze 16h ago

Ah, my bad.

if (thing is truthy) {
    print('Yeah, much better');
}

1

u/rosuav 14h ago

I'd venture to guess that everyone who whines that truthiness should be replaced with explicit comparisons has never programmed in REXX, and probably won't even understand why I'm making that reference.

2

u/Embarrassed_Death69 16h ago

Because just like yellowy isn't perfect yellow, certain values aren't Boolean type but will coerce to one, so not truth but truthy.

2

u/ReefNixon 16h ago

What do you mean it doesn't make any sense programmatically? All 'truthy' means is that it evaluates as true in a conditional, truthy (and falsey) values are completely normal concepts in high level programming.

1

u/Key_Conversation5277 15h ago

if(42) -> true

What fucking sense does this make? A number is a number, not something to be coerced to a boolean. Thankfully Java doesn't have this nonsense

1

u/ReefNixon 15h ago

Ok, so what would you like if(42) to do instead?

2

u/Key_Conversation5277 15h ago

... An error? Lol

-1

u/ReefNixon 15h ago

Yeah, not false.

If being explicit here matters, why not force the programmer to also explicitly manage registers, memory addresses, machine instructions, whatever? Because abstracting away concerns is the reason high level languages exist.

Truthy is just a way of abstracting away concerns about whether a value is intended to pass a conditional or not.

Picking your preferences over which features you like and don't like is one thing, but saying it doesn't make programmatic sense is something else. Nobody is forcing you to write if(42), you don't have to, but surely it makes sense that nobody who writes if(42) is hoping for falsey?

1

u/Unlikely-Bed-1133 15h ago

Implicit casting is a thing that makes sense both programmatically and mathematically. You just prefer strongly typed languages.