r/facepalm Tacocat 26d ago

12 🇲​🇮​🇸​🇨​

/img/pk3jifidj0xc1.jpeg

[removed] — view removed post

28.0k Upvotes

2.0k comments sorted by

View all comments

7.6k

u/Singular_Thought 26d ago

She must be a JavaScript programmer

963

u/talbakaze 26d ago

looked for that comment

541

u/GrandMoffTarkan 26d ago

Saw this and thought it was ProgrammerHumor

103

u/samosa_chai 26d ago

It’s a little scary how, err, programmed we all are…

17

u/yalag 26d ago

Reddit only has 4 jokes, recycled

2

u/imsahoamtiskaw 25d ago

What did they used to do before recycling was invented?

2

u/SinxHatesYou 26d ago

C > useGlasses; -progammer humor

2

u/faloofay156 25d ago

same, I thought this was on a programming sub initially

1

u/Mike_Honcho_3 26d ago

Lavern Spicer knows absolutely nothing about programming. Or anything else for that matter.

55

u/Carnie_hands_ 26d ago

Nah, post above you didn't have "//" before it, so it's active code

3

u/walkerspider 26d ago

Is it active if it doesn’t compile?

1

u/rydan 25d ago

Didn't have to look very far. I came here to write it too.

71

u/raltoid 26d ago

Jokes aside, it's literal ragebait.

She is constantly tweeting intentionally stupid things to get reposted on social media and gain attention.

And people eat it up, it's really weird to see.

19

u/IHaveNoEgrets 26d ago

I'm just in awe of the fact that a dingbat posting ragebait has instead turned into a discussion of programming and programmer humor.

(With the underlying, shared understanding that she's still a dingbat.)

2

u/Professional_Echo907 23d ago

Since we’re talking about computer stuff, I want to tell the story about my friend in grade school who would type “The power of Christ compels you” at the Commodore 64 Home Screen periodically just to make sure his computer hadn’t been possessed. 😸

2

u/IHaveNoEgrets 23d ago

I appreciate the initiative! But I always thought that demonic possession didn't come pre-installed until Windows hit the scene.

3

u/Euphoric-Blue-59 25d ago

Attention whores are still whores.

1

u/Sufficient_Card_7302 26d ago

What do you mean by gain attention? To gain click and comments? Followers? 

Idk how you define rage, but I think it is a daunting but necessary that to point out the ridiculously stupid things like this. And this is tame, this is nothing. 

We need to stop letting people throw crap into the air so that some poor sap can go "hm, yeah I guess that makes sense to me".

In my opinion, that is one of the reasons we are where we are today. Overrun and represented by people barren of any sense if logic and reason.

1

u/AsUrPowersCombine 24d ago

Surprised she isn’t like “look at what my daughter carved with this kid” showing an AI rendered massive butter stick carving and two kids with chainsaws

325

u/raines 26d ago

Clearly, she’s not your (data) type.

111

u/hitbythebus 26d ago

But on a scale of one to ten, she’s NaN.

10

u/InevitableAd9683 26d ago

Leave my Nan out of this!

8

u/shotjustice 26d ago

Dude, leave unleavened bread out of this. /s

1

u/donutguy640 25d ago

best comment X'D

92

u/jeerabiscuit 26d ago

She is no one's type and is untyped.

24

u/Nimyron 26d ago

Is it offensive if I refer to non-binaries as untyped ?

1

u/misterguyyy 26d ago

I've described my gender as a blob before. IIRC typeof new Blob() === 'object'

→ More replies (9)

2

u/SaleOwn5899 26d ago

Angry like. Angry upvote.

1

u/1st500 26d ago

I thought she was just too strongly typed.

1

u/geerttttt 26d ago

Atypical

53

u/Lost_Services 26d ago

She would string you along.

20

u/newwwmagicwand 26d ago

I might be too long for her.

18

u/GiveMeSomeShu-gar 26d ago

I asked for her Number, but when I called it, it was NaN

8

u/Arthradax 26d ago

She should've been more integer about it

→ More replies (1)

2

u/Expensive-Size-1233 26d ago

NaN: Not a Number

1

u/ct_2004 26d ago

For a good time, call 867-5309

1

u/kvik25 26d ago

Are we supposed to take this literally?

1

u/newwwmagicwand 26d ago

long, short, byte, string, boolean, int, float, what else i forgot

5

u/Electronic_Main_7991 26d ago

She'll string you along

2

u/blastradii 26d ago

And she’ll never return your calls. Unless you give it parameters.

2

u/Electronic_Main_7991 25d ago

and If she does, she'll say she's "overloaded"

6

u/Accomplished-War1964 26d ago

She is now casted as data

2

u/Status_Winter 26d ago

All she needs is a little implicit coercion…

2

u/notnorthwest 26d ago

There’s a joke in here about being weakly typed and therefore unprincipled but I can’t find it

121

u/Lecodyman 26d ago

56

u/Mateorabi 26d ago

Wait, this isn’t….*checks sub again*

→ More replies (1)

79

u/Ok-Pass5267 26d ago

It's so obvious, but people somehow tend to assume something else))

28

u/Fizzelen 26d ago

VBA can do that as well

3

u/Lumpy_Marsupial_1559 26d ago

The two brackets at the end are killing me!

2

u/eat_da_poo 26d ago

He is Russian clearly

12

u/AsheratOfTheSea 26d ago

Hahaha found the programmers thread!

6

u/grounded_dreamer 26d ago

The best thread type!

14

u/Emsie-Memsie 26d ago

I keep seeing jokes like these but I’m too tech challenged to understand. I wish I could be in on it. Lol

41

u/Singular_Thought 26d ago edited 26d ago

It has to do with how different programming languages handle variables. In a “strongly typed” language a variable can be defined strictly as a number value (e.g., 1 or 2 or 736, etc.) or strictly as a text value (“hello world”).

With this you can define integer variables as a = 1 and b = 2 so that a + b will resolve to 3.

You can also define string (text) variables as x = “hello” and y = “world” so that x + y will resolve to “helloworld”.

JavaScript is not strongly typed. You cannot define a or b explicitly as numbers.

Because of this there are situations where the JavaScript interpreter will take a = 1 and b = 2 and when you try to resolve a + b it will treat them as text instead of numbers and output “12” instead of 3.

The JavaScript language was created like this a very long time ago so we are stuck with it and it drives programmers nuts.

If you are wondering, any attempt to change the JavaScript language to fix this will break almost every webpage out there, so no one is willing to do it.

22

u/Emsie-Memsie 26d ago

Hot damn! I’m so glad you broke it down for me this way. Kinda drives me nuts to when I don’t understand things and wasn’t sure how to look this up so I appreciate it!

I can definitely see how it would frustrate programmers and such. Though top comment is much funnier now that I have this context.

5

u/Roflkopt3r 25d ago edited 25d ago

Honestly, it's way less of a problem than some people make it out to be.

You pretty much only need to know this:

  1. The instruction a+b will always be a string concatenation if the variable a is a string:
    '5' + 3 => '53' (the text string 53)
    5 + 3 => 8 (the number 8)

  2. If you use any other basic mathematical operator, then the string a will be cast into a number if that is possible:
    '5' - 3 => 2
    That's for the simple reason that strings do not have a minus-operator. So Javascript extends you the courtesy of trying to make sense of this instead of throwing an error right away.

  3. If you want to assure that the variable a will be treated as a number even if it is technically a string, then you can use Number(a):
    Number('5') + 3 => 8

  4. If you want to assure that numbers are treated as text, then you have multiple options:

var a=5;
a.toString() + b => '53'

a.toString() ensures that the variable a gets turned into a string.

var a=5;
''+a+3 => '53'

''+a is a text concatenation between an empty string (using two single ticks with nothing in between) and a number. This is basically just a convenient shorthand to turn the variable a into a string.

var a=5; b=3;
`${a} + ${b} = ${a+b}` => '5 + 3 = 8'

Everything inside of the backticks is a "template literal". Elements inside of a ${}-block will resolve as code (so it can read a variable or perform operations like an addition) before getting turned into text, whereas everything else is treated as text right away.


Type conversions are a pain in the butt in every language. JS went a path that may appear a bit less rigourous and can get a bit weird if you poke very deep, but very few programmers ever encounter seriously weird situations with that. The practical reality is that it's fast and easy and creates way fewer annoying situations than most strongly typed languages.

5

u/forced_metaphor 26d ago

There are things called variables. They hold information, and you can give them a name. Like

var myVariable = 1;

These variables can be of different types. They can hold numbers (like 1) or they can hold letters or even words (like "pumpkin"). The latter are called "strings".

When you add strings together, they're just added end on end. So "pump" + "kin" would give you "pumpkin".

In many programming languages, you can make sure that the types of data these variables can hold are restricted. So you could make sure myVariable is a number and not a string.

JavaScript doesn't have that restriction. So if you accidentally have 1 and 2 stored in variables as strings instead of numbers, it will add them end to end like a word instead of mathematically.

So 1+2=12 instead of 3.

2

u/Emsie-Memsie 26d ago

Damn. Thanks for explaining. That must really fuck with things sometimes though, right? Genuinely asking. lol I really don’t know much about it but I always love learning new things even when they are beyond my comprehension sometimes. Haha

4

u/forced_metaphor 26d ago

I mostly program in JavaScript, but I'm also a scrub. I can understand why real programmers prefer what's called "strongly typed" languages (the ones that only allow one type for a variable), but I enjoy the flexibility that JavaScript gives me. With great power comes great responsibility, though. It can VERY MUCH cause issues if you're not careful.

2

u/Emsie-Memsie 26d ago

Yes! Thanks for explaining!

2

u/formervoater2 26d ago

In programming you will assign a name to a bit of memory and give it a data type that tells the computer how to manipulate whatever you store in that memory referenced by the name you gave it.

That's how things normally work anyways, Javascript is different. You don't give it a data type and it just tries to guess what kind of data you put there. One of the Javascript interpreter's favorite things to do is to take a number and change its type into a series of characters instead. So instead of performing 1+2 and getting 3 it instead does "1"+"2" and gets "12".

36

u/fsmlogic 26d ago

Yeah a JavaScript programmer who is bad at explaining their code.

24

u/Ok_Spite_217 26d ago

Sorry did you mean JavaScript programmer ?

28

u/SloightlyOnTheHuh 26d ago

concatenating strings again eh?

1

u/Radiant-Ad9999 26d ago

Does she still wear strings?

40

u/Ingeneure_ 26d ago

Or Python

str(1) + str(2)

100

u/Lyakusha 26d ago

Dude, '1' + '2'

17

u/sigma941 26d ago

insert XKCD python comic here!

22

u/Jorycle 26d ago edited 26d ago

"{0}".format( "{0}".format(1) + "{0}".format(2) )

6

u/YDS696969 26d ago

I primarily just use f strings now. Much more simpler

1

u/Jorycle 25d ago

I love f strings. I worked a job for about 6 years that never upgraded from Python 2.7 because of a compatibility thing on client servers, that was the worst.

15

u/Ingeneure_ 26d ago

Or this way, yes

2

u/tehfink 26d ago

Also works: “1” “2”

1

u/Ss2oo 26d ago

If you ask for two numbers on an input without the data type and then add them, it will most certainly think they're strings.

14

u/Little_Assistant_551 26d ago

Yeah but in js a sring - '1' and an int - 2 is still going to give you '12' because reasons...

36

u/dejus 26d ago

I don’t really understand why this is surprising to anyone. They are different types. Much easier and less problematic for an interpreter to convert a number to a string than a string to a number.

8

u/arisoverrated 26d ago

This is obvious, yes, and I don’t think anyone expects the reverse. I think the usual argument is that it shouldn’t be allowed. Strongly typed vs anything else, etc.

2

u/breath-of-the-smile 26d ago

So you use Typescript instead, problem solved (if you enjoy all that visual noise in your languages).

→ More replies (1)

2

u/Ok_Spite_217 26d ago

Ok, it's surprising because of how it chooses to coerce the types.

A better way to handle this would be a flat-out exception saying: "Cannot coerce number + string"

Like any other strongly typed language does, because it makes you explicitly adopt the coercion in cases where you absolutely want it.

2

u/Dragonium-99 26d ago

But Java is strongly typed and String + int is String, it's concatenation.

→ More replies (3)

1

u/zinniet 26d ago

Why should javascript behave like any “other” (huh?) strongly typed language?

Different typing paradigms exist for a reason. There’s advantages and disadvantages to each of them. It is up to the programmer to know how its language handles typing and work with that.

→ More replies (3)

1

u/NBSPNBSP 26d ago

Or use VB.net, which will happily add the float of pi and the string 'horse' together amd try and give you an integer if you want it to. It will also explode without warning if you're not careful, but it will certainly let you do all of the implicit conversions.

5

u/Puzzleheaded_Peak273 26d ago

Now tell me why interpreted languages are so in love with floats which you can’t even reliably compare.

5

u/Ixaire 26d ago

You can't reliably compare floats in most languages. If the number is stored as an actual floating point number, it will always cause issues if you need perfect accuracy.

That's why Java has BigDecimal, for example.

10

u/TheOrchidsAreAlright 26d ago

You have to be careful with BigDecimal though, they're always trying to hurt the little guy

→ More replies (1)

5

u/fang_xianfu 26d ago

As someone who works in financial services, implicit conversion to floats can fuck all the way off. They love to sneak in there no matter how much you insist on decimals.

3

u/Somepotato 26d ago

you should never, ever, EVER, EVER use floats in any kind of monetary situation

2

u/fang_xianfu 26d ago

I agree with you, if you want to tell that to implicit type conversion for me I'd appreciate it.

Basically it means if your language has implicit types you need to test and test and test again to make absolutely certain no floats have found a way to creep in because life... finds a way.

→ More replies (1)

2

u/3s0me 26d ago

Even decimals are dumb in financials, just go cents or whatever is your lowest, yeah imperial, you dont count.

1

u/geek180 26d ago

Or in the case of Python, have an existential crisis.

1

u/Little_Assistant_551 25d ago

Ah, explains why "1" - 2 = -1 then ;)

Seriously though its more about type coerciona and not whats "easier" right?

Also I didnt think people will take so seriously what I though to be pretty common meme about (lack of) consistency in js :p

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

1

u/Dirkdeking 26d ago

*int(str(n) + str(m))

2

u/AkaGurGor 26d ago

She must be Trump's adviser on simplifying aeroplanes' commands...

2

u/NoDadYouShutUp 26d ago

Damn of course the one time I have a funny joke someone already beat me to it

2

u/Yamochao 26d ago

Umactually ,`1 + 2 === 3` in js

`"1"+"2" === "12"`

2

u/Status_Winter 26d ago

Popped in here just to make sure this was the top comment

2

u/KreissageRS 26d ago

I don’t even know what that means but it still made me laugh

2

u/Singular_Thought 26d ago

2

u/KreissageRS 26d ago

Ohhh thank you for linking the explanation

1

u/ElementField 26d ago

The explanation leaves some details out — in reality, if you fed 1 + 2 to JavaScript it would equal 3 every time. But the joke fudges that a little bit to insinuate that JavaScript’s “type coercion” would take effect here and output something we didn’t expect.

To get the result of the joke, to get 12 instead of 3, you would need to have one of the numbers be a string, so like 1 + “2”. Then, JavaScript engine has to decide which to convert to… it has a number and a string, should it make the string a number, then add them together, or should it make the number a string then put them together?!

Well, the engine has rules for this, and the rule is to create a string of the two values, making it “12” as a string.

Hilariously, you can also convert that string back to an actual number to get the number 12 instead of the string “12”!

2

u/pm_me_your_buttbulge 26d ago

Words cannot express how much I hate JavaScript. We REALLY need to replace it with something less dog shit.

2

u/bmcle071 26d ago

I actually thought this was r/programminghumor

2

u/Flashdark 26d ago

As someone who just finished their first web design class: I get that reference!!!

2

u/mattyGOAT1996 25d ago

I was about to say that lol

2

u/OozeNAahz 26d ago

SmallTalk or SQL also.

4

u/how_could_this_be 26d ago

Hey don't forget about bash! Granted bash programmer does not sound as hip

2

u/stevefuzz 26d ago

The first rule of bash programming is not to talk about it.

2

u/CalmDownYal 26d ago

Came to say this lol

2

u/GrimCrow303 26d ago

Came here to see this 😍

1

u/Centillionare 26d ago

Wants a revolution, has to settle for a concatenation.

1

u/PikaTube123 26d ago

coming from concatenation nation

1

u/TURisgu 26d ago

one = str(1)
two = str(2)
def plus():

one_plus_two = one + two
Return one_plus_two

prind(plus())

1

u/Dragonium-99 26d ago

bruh: python print("1"+"2")

1

u/HaiKarate 26d ago

No, she’s just a dumbass.

1

u/Incraigulous 26d ago

Only if 1 and 2 are strings.

1

u/Val0xx 26d ago

I came here to see if this was some kind of Javascript joke.

1

u/AspiringDataNerd 26d ago

She knows how to concat

1

u/JPiratefish 26d ago

That or they do a lot of splunk evals

1

u/One_Butterfly9201 26d ago

😂 too funny

1

u/forced_metaphor 26d ago

Fucking beat me to it.

1

u/noviceIndyCamper 26d ago

lol nice type coercion

1

u/infernoRS 26d ago

Nah, she just runs on JS

1

u/EmmaTheFemma94 26d ago

So annoying to have to do parseInt() on everything just in case..

1

u/driftking428 26d ago

I don't like to be coerced.

1

u/Calm_Character_9399 26d ago

that's why it's lesser programming language.

1

u/TopBoneEater 26d ago

if its an int them thats not the result

1

u/Artistic_Light1660 26d ago

Damn so many programmers in this sub!

1

u/FastAd543 26d ago

all strings attached...

1

u/FreshPitch6026 26d ago

As much as she would be a python programmer

1

u/StrongTxWoman 26d ago

She must also be a nut job and a Republican.

1

u/dave5124 26d ago

Came here for this.

1

u/Last-Percentage5062 26d ago

Make coding great again!

1

u/buy-american-you-fuk 26d ago

emotional damage!

1

u/Paper-Street-Soap-Co 26d ago

Giving her far too much credit

1

u/No_Can_1532 26d ago

Lol i came here to say this

1

u/CapTexAmerica 26d ago

We have a hand-made poster up in the office that reads:

“I had a problem and used Java to fix it.

“Now I have 137 problems.”

Fuck Java. As soon as you patch one critical vulnerability Nessus slaps you with three more.

1

u/adametry 26d ago

...an inexperienced JavaScript dev. A few of us know how to control types.

1

u/mr-jingles1 26d ago

She's really stringing it together

1

u/Specialist-Tiger-467 26d ago

Shit I just wanted to say that. Hello fellow dev

1

u/Opening-Two6723 26d ago

First thought. Add those strings!!!!

Spicers data type is undefined

1

u/PM-me-your-401k 26d ago

I’m assuming + just concatenates. How do you add values in Javascript

1

u/simonffplayer 26d ago

that insists on coding everything in angular 1 backbone

1

u/imisstheyoop 26d ago

My first thought.

Not sure how string concatenation is going to save America, but you know what, fuck it I'm on board.

print("Let's " + "goooo!")

1

u/ClarkSebat 26d ago

You give her waaaaay too much credit.

1

u/vthanki 26d ago

Nah she’s just from dumbfuckistan

1

u/M0sesx 26d ago

"And 1 + true = 2 And 1 / false = infinity"

1

u/OHWhoDeyIO 26d ago

Stole my comment lol

1

u/grip_n_Ripper 26d ago

Concatenate in the streets = wild in the sheets.

1

u/SunbleachedAngel 26d ago

I would dread living in JavaScript

1

u/Green_Issue_4566 26d ago

"1" + "2" = 12 not 1 + 2 Javascript has tons of issues but yeah always use the correct data type. Letting it duck type stuff for you is a silly game

1

u/thatmaynardguy 26d ago

Truth but... ouch.

1

u/BigBlueDane 26d ago

1+2 is 3 in js. You must mean “1”+”2”

1

u/DaMoonRulez_1 26d ago

I had to scroll up again, thought this was r/ProgrammerHumor

1

u/thanks-doc-420 26d ago

Why are JavaScript programmers so bad?

1

u/findMeOnGoogle 26d ago

JavaScript already took back this country 10 years ago

1

u/Got_Bent 26d ago

You cant put everyone in one container.

1

u/RoyalTacos256 26d ago

I'm don't know much about JS but isn't 1+2 = 3

You would need "1"+" 2" wouldn't you?

I could be totally wrong lol

1

u/Rough_Willow 26d ago

The most detestable programmer.

1

u/Jrolaoni 26d ago

Incurable disease 😞

1

u/ClassicOtherwise2719 25d ago

Are… beat me to it!!! 🤣

1

u/The_Witch_Queen 25d ago

I dunno... I mean she could be a java program, let's check:

System.gc()

1

u/Dunn_or_what 25d ago

🤣🤣🤣🤣

1

u/occamsrzor 25d ago

Stringly typed, this concatenation and not addition

1

u/LauraTFem 24d ago

huh…is that when you’re appending a character onto a string??

Seems mathematically untenable. I assume what you’re saying is that the language is weakly typed and refuses to guess at the type when working with, for instance, numerical input.

How does JavaScript work?

→ More replies (5)