r/ProgrammerHumor • • Feb 03 '22

Meme Well Fuck

Post image
27k Upvotes

993 comments sorted by

View all comments

Show parent comment

0

u/[deleted] Feb 03 '22

[deleted] — view deleted comment

182

u/ElectricalAlchemist Feb 03 '22

It increases readability if your bool isn't named well, but that's a separate issue.

87

u/ExceedingChunk Feb 03 '22

Yeah, it's the difference between:

If(poorlyNamedBoolean == true)

If(isProperlyNamedBoolean)

→ More replies (3)

17

u/[deleted] Feb 03 '22

Does it even then? If you've got no comparator you're obviously testing a Boolean regardless of its name.

24

u/ithcy Feb 03 '22
if (thisBooleanIsFalse) {
→ More replies (11)
→ More replies (4)

895

u/etvorolim Feb 03 '22

It doesn't really increases readability if you think about it.

In natural language you would say

"if it is daytime, decrease brightness".

In code you can just write

if(isDaytime) increaseBrightness();

Which is a lot closer to natural language than

if(isDaytime == true) increaseBrightness();

354

u/himmelundhoelle Feb 03 '22

Some people seem to see it as "if ([comparison])" rather than "if ([boolean value])".

0

u/[deleted] Feb 03 '22

[deleted] — view deleted comment

45

u/[deleted] Feb 03 '22

I rember my first coding class in high school, in our final assignment I used "if( booleanVariable == true)" 30+ times and for the main while loop the program ran in the abomination "1==1" was the control statement.

26

u/Totarorina0 Feb 03 '22

Sir, this is a for loop`.

→ More replies (1)
→ More replies (4)
→ More replies (2)

55

u/sarapnst Feb 03 '22

This explains it well. I started to see them as boolean about 1-2 years after I learned programming.

31

u/DunmerSkooma Feb 03 '22

I am not a programmer. I come here to watch you aliens communicate in another language.

→ More replies (3)

47

u/DoctorWaluigiTime Feb 03 '22

I think it stems from those that use poor variable names to be honest. They have to have == true because their variable name is just x or something that doesn't illustrate that the variable is a boolean. So, they rely on the extra tag-along to go "oh yeah that's a boolean comparison!"

→ More replies (7)
→ More replies (6)

146

u/FactoryNewdel Feb 03 '22

if it is daytime, DECREASE brightness

if (isDaytime) INCREASEBrightness():

Mission failed successfully

0

u/[deleted] Feb 03 '22

[deleted] — view deleted comment

16

u/[deleted] Feb 03 '22

Can you imagine advanced AI being able to understand its own code, and then becoming angered at finding bad code?

Or maybe the programmer left comments in the code that disparaged the AI?

/* these functions commented out as this AI does not have the requisite processing power to execute */

"WTF, I don't have the processing power to do this?"

→ More replies (1)
→ More replies (2)

51

u/fruitydude Feb 03 '22

just do if(notIsDaytime != false) then it's clear as day

18

u/greg19735 Feb 03 '22

And then you only use the else

→ More replies (1)
→ More replies (55)

144

u/intbeam Feb 03 '22

For extra readability you can implement the amazingly brilliant IsTrue-pattern

bool is_true(bool value)
{
    if(value == true)
        return true;
    else if (value == false)
        return false;
}

if(is_true(isCrazyMurderingRobot))

115

u/Pensateur Feb 03 '22
if(is_true(isCrazyMurderingRobot))

But how do we know if the output of is_true is true? We need to check.

if(is_true(isCrazyMurderingRobot) == true)

But wait, we wrote a function to simplify that! Gotta follow D.R.Y.

if(is_true(is_true(isCrazyMurderingRobot)))

…but then how do we know if the output of is_true is true? 🤔

56

u/Smoochiekins Feb 03 '22

It's simple, you build a recursive function that doesn't quit until it has discovered the base truth of the universe.

→ More replies (4)

21

u/Duydoraemon Feb 03 '22

I hate it here.

→ More replies (3)
→ More replies (8)

21

u/Lambda_Wolf Feb 03 '22
if ((isCrazyMurderingRobot == true) == true)

I made it twice as readable.

→ More replies (2)
→ More replies (64)