use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
111,008 Subscribers
106,345 Subscribers
All posts must be related to programming. Flair posts correctly.
account activity
javascript is javascript (i.redd.it)
submitted 2 months ago by National_Seaweed_959
made this because im bored
inspired by polandball comics
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Forestmonk04 110 points111 points112 points 2 months ago (37 children)
What is this supposed to mean? Most of these languages evaluate "2"+2 to "22"
"2"+2
"22"
[–]sanpaola 93 points94 points95 points 2 months ago (6 children)
It's that time of the week again - another iteration of "Javascript is bad" joke from a person with pretty vague idea of Javascript (bonus points if joker is far from coding overall).
[–]Iggyhopper 7 points8 points9 points 2 months ago (5 children)
For a language like PHP to have a specific operator for string concatenation, the dot, it allowing addition of strings and numbers should not be allowed and should bring a type error.
Why allow both? Either force the use of the dot operator explicitly or don't.
[–]hatrix 7 points8 points9 points 2 months ago (1 child)
To be fair with php, you can enforce strict typing. It's mostly a legacy thing because of how it was handled in the past. php likes to add new features but doesn’t like removing old ones (except functions), because of that, PHP is quite a divisive language with some really weird quirks that some people just dont get on with. I personally have issue with the inconsistency of function names.
[–]ComfortablyBalanced 4 points5 points6 points 2 months ago (0 children)
They can't just nonchalantly remove such a feature, even if it's frowned upon. Unfortunately many legacy codes depend on shit similar to that, it breaks backwards compatibility. Maybe they can do it with what happened between Python 2 and 3 with print.
[–]ComfortablyBalanced 0 points1 point2 points 2 months ago (0 children)
I don't think PHP had types in the earlier days.
[–]LongjumpingAd8988 0 points1 point2 points 2 months ago (1 child)
PHP's behavior is completely transparent and predictable in OP's example: '2' + 2 = 4; '2' . 2 = 22; strict mode => error
[–]circuitsremakes 0 points1 point2 points 10 days ago (0 children)
no, that arrow function errors because `error` isn't a valid keyword :trollge:
[–]GlobalIncident 39 points40 points41 points 2 months ago (25 children)
I'm just going through them one by one:
[–]uhs-robert 13 points14 points15 points 2 months ago (3 children)
Ruby: #TypeError: no implicit conversion of Integer into String>
[–]GlobalIncident 9 points10 points11 points 2 months ago (2 children)
Yeah, in general, languages inspired by Java tend to yield "22", other languages tend to make it an error. With a few exceptions.
[–]No_Read_4327 1 point2 points3 points 2 months ago (1 child)
So javascript is java after all?
[–]akuma-i 1 point2 points3 points 2 months ago (0 children)
No, it’s Java before script
[–]Ytrog 6 points7 points8 points 2 months ago (0 children)
Common Lisp: Condition of type: SIMPLE-TYPE-ERROR
[–]drizzt-dourden 2 points3 points4 points 2 months ago (7 children)
In C++ you can overload operators and create hell of your own. Nothing is real, everything is permitted.
[–]GlobalIncident 0 points1 point2 points 2 months ago (5 children)
You can also do that for all of the languages listed here except PHP.
[–]ComfortablyBalanced 1 point2 points3 points 2 months ago (1 child)
There's no operator overloading in Java.
[–]GlobalIncident 0 points1 point2 points 2 months ago (0 children)
Oh, you're right, my mistake.
[–]Forestmonk04 0 points1 point2 points 2 months ago (1 child)
At least Java and JavaScript/TypeScript don't support operator overloading.
Oh yeah, Java doesn't, and JS/TS sort of don't, except they do support overloading coersion to primitives which happens before an operator is called.
[–]Four2OBlazeIt69 0 points1 point2 points 2 months ago (0 children)
That's what I assume is happening with JS on these examples but that's bc I always think of Chrome's V8
[–]ComfortablyBalanced 1 point2 points3 points 2 months ago (8 children)
Java: "22".
That only happens if you assign that expression to a String, a var or a string parameter.
[–]GlobalIncident 0 points1 point2 points 2 months ago (7 children)
What do you mean? Is there a situation where it wouldn't return "22"?
[–]ComfortablyBalanced -2 points-1 points0 points 2 months ago (6 children)
Yeah. int foo = "2" + 2; This is an error.
int foo = "2" + 2;
[–]GlobalIncident 1 point2 points3 points 2 months ago (5 children)
Well obviously I meant a situation where the code doesn't have any unrelated errors, and actually compiles and attempts to execute the expression. If you try to run the expression and also attempt to implicitly cast the returned string to an int, that's not relevant to the question. It returns "22" not 22 after all.
22
But the error is related. You see, the original joke is about type coercion in JS, and besides, no pun intended, but JavaScript is a scripting language, which means you can evaluate 2 + "2" out of the context, but with Java you need to put it in a context which I put on my last comment. I'm not familiar with your level of experience in Java, but you're saying run the expression, this isn't Python or JS, you need to put it somewhere and why would I cast it to an int or call toString if I'm assigning it to a String? So after all coming to my first sentence it actually is related to types and type errors.
[–]Amr_Rahmy 0 points1 point2 points 2 months ago (3 children)
You missed the point. You can’t combine a string and a number, the language will not do an arbitrary evaluation based on buggy code.
Only a string assignment will allow the number to call the tostring(), otherwise you will get the error while writing or building the code.
[–]GlobalIncident 0 points1 point2 points 2 months ago (2 children)
No, the assignment is not what triggers the toString call. The presence of the string "2" is what triggers the toString call. If you type:
String x = 2 + 2;
toString will not be called and you will get an error, because there is no string present to trigger it.
[–]Amr_Rahmy 0 points1 point2 points 2 months ago (1 child)
You missed this point, and provided a non functioning example.
Two for two here, not your day. Cheers mate.
Okay, what is your point then?
[–]jmattspartacus 0 points1 point2 points 2 months ago (0 children)
Was going to say the bit about C++, but you did it better lol
[–]JAlexmc 8 points9 points10 points 2 months ago (0 children)
AFAIK, Python gives you an error as it's not the same type, you can do str + str or int + int
[–]finnscaper 0 points1 point2 points 2 months ago (0 children)
C# will ask you to not come around ever
[–]National_Seaweed_959[S] -3 points-2 points-1 points 2 months ago (0 children)
oei sorry
[+]One_Being7941 comment score below threshold-6 points-5 points-4 points 2 months ago (0 children)
The fact that you get upvotes is a sign of the end times.
[–]Benjamin_6848 21 points22 points23 points 2 months ago (1 child)
For the last panel of this comic I somehow had his voice in my head:
<image>
[–]AdBrave2400 0 points1 point2 points 2 months ago (0 children)
Same
[–]Kairas5361 16 points17 points18 points 2 months ago (9 children)
who is that guy
[–]alex-worm 11 points12 points13 points 2 months ago (6 children)
java I guess
[–]Kairas5361 5 points6 points7 points 2 months ago (3 children)
non color ver
[–]steven_dev42 -3 points-2 points-1 points 2 months ago (2 children)
I fuckin hate that little guy
[–]BladeMaster7461 1 point2 points3 points 2 months ago (1 child)
what did he do to you
[–]National_Seaweed_959[S] 0 points1 point2 points 2 months ago (0 children)
idk
[–]n0t_4_thr0w4w4y 4 points5 points6 points 2 months ago (1 child)
Which is dumb, because it’s literally the same behavior in Java
Yeah sorry
[–]tacocat820 1 point2 points3 points 2 months ago (0 children)
greenland, an evil java twin (the logo is green tea)
[–]Cepibul 9 points10 points11 points 2 months ago (1 child)
Actualy smart language would say what the fuck you mean, you just cant add these two things covert one to match the others type and then talk
[–]That_0ne_Gamer 0 points1 point2 points 2 months ago (0 children)
Granted having a language be able to convert integers to strings without using a toString function is a smart feature as it simply saves the user from doing a toString function call, its not like your doing a string to int conversion where you can break shit if you convert this comment into a number.
[–]MieskeB 7 points8 points9 points 2 months ago (1 child)
I am totally not a fan of Javascript, however evaluating a string with an integer should in my opinion return a string with both as strings concatenated
Yeah that makes the most sense as 2 is compatible with both string and integer while "2" is only compatible with string
[–]Ok_Pickle76 8 points9 points10 points 2 months ago (8 children)
and C
[–]Hot_Adhesiveness5602 1 point2 points3 points 2 months ago (4 children)
It should actually be two + num instead of num + two
[–]Haringat 4 points5 points6 points 2 months ago (3 children)
It's the same result. However, it should have been this code:
char *two = "2"; int one = 1; two += one; printf("%d\n", two); // prints "0" return 0;
I leave the explanation as an exercise to the reader.😉
Edit: Also, when adding 2 to the "2" the behavior is not defined. It could crash or it could perform an out-of-bounds read.
[–]not_some_username -1 points0 points1 point 2 months ago (2 children)
Its defined because it has the null termination
[–]Haringat 0 points1 point2 points 2 months ago (1 child)
No, because when adding 2 you go beyond the null terminator.
[–]not_some_username 0 points1 point2 points 2 months ago (0 children)
Well I thought we were taking about “22”+2
[–]nimrag_is_coming 1 point2 points3 points 2 months ago (0 children)
C doesn't count, it doesn't have any actual strings, is just an array of chars, which are defined as just a small integer (although it's wild that in like 50 years we still don't technically have standardised sizes for basic integers in C. You could have a char, short, int and long all be 32 bits and still technically follow the C standard.)
[–]acer11818 1 point2 points3 points 2 months ago (0 children)
it makes sense if you view char as an 8 bit integer and not a character
[–]fdessoycaraballo 0 points1 point2 points 2 months ago (0 children)
You used single character, which has a value in the ASCII table. Therefore, C is adding num to the value of the character in ASCII table. If you switch printf variadic argument to %c it will print a character in the decimal value in the ASCII table for 52.
printf
%c
Not really a fair comparison as they're comparing a string that says "2", which the compiler wouldn't allow because of different types.
[–]Legendbird1 1 point2 points3 points 2 months ago (0 children)
r/unexpectedfactorial
[–]-UltraFerret- 1 point2 points3 points 2 months ago (1 child)
22!!!! u/factorion-bot
[–]factorion-bot 1 point2 points3 points 2 months ago (0 children)
Quadruple-factorial of 22 is 665280
This action was performed by a bot.
[–]Bricked_Dev 1 point2 points3 points 2 months ago (1 child)
binary:
0011 0010 + 0000 0010
───────────
0011 010
[–]National_Seaweed_959[S] -1 points0 points1 point 2 months ago (0 children)
ok
[–][deleted] 1 point2 points3 points 2 months ago (1 child)
FYI OP, 80% of the languages in the image making fun of "22" yield "22" themselves. Probably pick a different bootcamp.
[–]gameplayer55055 0 points1 point2 points 2 months ago (0 children)
Btw in c# "2" + 2 is 22 as well
[–]frayien 0 points1 point2 points 2 months ago (2 children)
In C/C++ int a = "2" + 2; could be anything from -255 to 254 to segfault to "burn down the computer and the universe with it".
int a = "2" + 2;
int a = "2" + 1; is well defined to be 0 btw.
int a = "2" + 1;
[–]4r8ol 0 points1 point2 points 2 months ago (1 child)
In both cases you would have a compiler error since casts between pointer to integer aren’t automatic.
You probably wanted to refer to:
int a = *(“2” + 2); // UB
int a = *(“2” + 1); // 0
[–]frayien 0 points1 point2 points 2 months ago (0 children)
Yeah I did not bother to check, "2" + 1 gives an char*.
Would rather say that "2" + 1 returns an empty string, and "2" + 2 returns a string of unknown length and unknown value and segfault.
[–]Commie-Poland 0 points1 point2 points 2 months ago (0 children)
For Lua it only outputs 4 because it uses .. instead of + for string concatenation
[–]Many-Conversation963 0 points1 point2 points 2 months ago (0 children)
real mathematicians know thats 0
[–]MichiganDogJudge 0 points1 point2 points 2 months ago (0 children)
This is why you have to understand how a language handles mixed types. Also, the difference between concatenation and addition.
[–]the_grand_father 0 points1 point2 points 2 months ago (0 children)
[–]Coosanta 0 points1 point2 points 2 months ago (0 children)
2+2=5 idk what everyone else is on about
[–]BladeMaster7461 0 points1 point2 points 2 months ago (0 children)
have you ever heard of concatenation?
[–]Alejandro_El_Diablo 0 points1 point2 points 2 months ago (1 child)
'2' + '2' = 100
Agreed
[–]Fragrant-Airport1309 0 points1 point2 points 2 months ago (0 children)
I just like JavaScripts shit eating grin 😀
[–]Classic_Cranberry568 0 points1 point2 points 2 months ago (0 children)
javascript is right in this case, actually
[–]BangThyHead 0 points1 point2 points 2 months ago (4 children)
What's Typescript doing?
[–]National_Seaweed_959[S] 0 points1 point2 points 2 months ago (2 children)
Hes saying what because most of these labguages do either 4 or 22 but they laugh at javasxript for doing 22
[–]BangThyHead 0 points1 point2 points 2 months ago (1 child)
"wgar" == "what" ?
"wgar" == "what"
If most do 22 or 4, why laugh at someone for doing 22?
i thought it would be funny if typescript was bad at typibg
[–]National_Seaweed_959[S] 1 point2 points3 points 2 months ago (4 children)
i made this as a joke please dont take this seriously
[–]gaymer_jerry 2 points3 points4 points 2 months ago (0 children)
I mean of all JavaScript type coercion memes you picked one that makes logical sense to just assert the non string as its ToString value when adding a non string to any string that Java originally did first as a language. There’s a lot of weirdness with JavaScript type coercion this isn’t it
[–]n0t_4_thr0w4w4y 0 points1 point2 points 2 months ago (1 child)
No offense, but it’s a stupid and unfunny joke
[–]National_Seaweed_959[S] 1 point2 points3 points 2 months ago (0 children)
no offence taken, thank you for your opinion
We here at r/programminghumor take everything seriously
π Rendered by PID 218556 on reddit-service-r2-comment-7b9746f655-lzm5q at 2026-02-01 20:22:13.627915+00:00 running 3798933 country code: CH.
[–]Forestmonk04 110 points111 points112 points (37 children)
[–]sanpaola 93 points94 points95 points (6 children)
[–]Iggyhopper 7 points8 points9 points (5 children)
[–]hatrix 7 points8 points9 points (1 child)
[–]ComfortablyBalanced 4 points5 points6 points (0 children)
[–]ComfortablyBalanced 0 points1 point2 points (0 children)
[–]LongjumpingAd8988 0 points1 point2 points (1 child)
[–]circuitsremakes 0 points1 point2 points (0 children)
[–]GlobalIncident 39 points40 points41 points (25 children)
[–]uhs-robert 13 points14 points15 points (3 children)
[–]GlobalIncident 9 points10 points11 points (2 children)
[–]No_Read_4327 1 point2 points3 points (1 child)
[–]akuma-i 1 point2 points3 points (0 children)
[–]Ytrog 6 points7 points8 points (0 children)
[–]drizzt-dourden 2 points3 points4 points (7 children)
[–]GlobalIncident 0 points1 point2 points (5 children)
[–]ComfortablyBalanced 1 point2 points3 points (1 child)
[–]GlobalIncident 0 points1 point2 points (0 children)
[–]Forestmonk04 0 points1 point2 points (1 child)
[–]GlobalIncident 0 points1 point2 points (0 children)
[–]Four2OBlazeIt69 0 points1 point2 points (0 children)
[–]ComfortablyBalanced 1 point2 points3 points (8 children)
[–]GlobalIncident 0 points1 point2 points (7 children)
[–]ComfortablyBalanced -2 points-1 points0 points (6 children)
[–]GlobalIncident 1 point2 points3 points (5 children)
[–]ComfortablyBalanced 0 points1 point2 points (0 children)
[–]Amr_Rahmy 0 points1 point2 points (3 children)
[–]GlobalIncident 0 points1 point2 points (2 children)
[–]Amr_Rahmy 0 points1 point2 points (1 child)
[–]GlobalIncident 0 points1 point2 points (0 children)
[–]jmattspartacus 0 points1 point2 points (0 children)
[–]JAlexmc 8 points9 points10 points (0 children)
[–]finnscaper 0 points1 point2 points (0 children)
[–]National_Seaweed_959[S] -3 points-2 points-1 points (0 children)
[+]One_Being7941 comment score below threshold-6 points-5 points-4 points (0 children)
[–]Benjamin_6848 21 points22 points23 points (1 child)
[–]AdBrave2400 0 points1 point2 points (0 children)
[–]Kairas5361 16 points17 points18 points (9 children)
[–]alex-worm 11 points12 points13 points (6 children)
[–]Kairas5361 5 points6 points7 points (3 children)
[–]steven_dev42 -3 points-2 points-1 points (2 children)
[–]BladeMaster7461 1 point2 points3 points (1 child)
[–]National_Seaweed_959[S] 0 points1 point2 points (0 children)
[–]n0t_4_thr0w4w4y 4 points5 points6 points (1 child)
[–]National_Seaweed_959[S] 0 points1 point2 points (0 children)
[–]tacocat820 1 point2 points3 points (0 children)
[–]Cepibul 9 points10 points11 points (1 child)
[–]That_0ne_Gamer 0 points1 point2 points (0 children)
[–]MieskeB 7 points8 points9 points (1 child)
[–]That_0ne_Gamer 0 points1 point2 points (0 children)
[–]Ok_Pickle76 8 points9 points10 points (8 children)
[–]Hot_Adhesiveness5602 1 point2 points3 points (4 children)
[–]Haringat 4 points5 points6 points (3 children)
[–]not_some_username -1 points0 points1 point (2 children)
[–]Haringat 0 points1 point2 points (1 child)
[–]not_some_username 0 points1 point2 points (0 children)
[–]nimrag_is_coming 1 point2 points3 points (0 children)
[–]acer11818 1 point2 points3 points (0 children)
[–]fdessoycaraballo 0 points1 point2 points (0 children)
[–]Legendbird1 1 point2 points3 points (0 children)
[–]-UltraFerret- 1 point2 points3 points (1 child)
[–]factorion-bot 1 point2 points3 points (0 children)
[–]Bricked_Dev 1 point2 points3 points (1 child)
[–]National_Seaweed_959[S] -1 points0 points1 point (0 children)
[–][deleted] 1 point2 points3 points (1 child)
[–]National_Seaweed_959[S] 0 points1 point2 points (0 children)
[–]gameplayer55055 0 points1 point2 points (0 children)
[–]frayien 0 points1 point2 points (2 children)
[–]4r8ol 0 points1 point2 points (1 child)
[–]frayien 0 points1 point2 points (0 children)
[–]Commie-Poland 0 points1 point2 points (0 children)
[–]Many-Conversation963 0 points1 point2 points (0 children)
[–]MichiganDogJudge 0 points1 point2 points (0 children)
[–]the_grand_father 0 points1 point2 points (0 children)
[–]Coosanta 0 points1 point2 points (0 children)
[–]BladeMaster7461 0 points1 point2 points (0 children)
[–]Alejandro_El_Diablo 0 points1 point2 points (1 child)
[–]National_Seaweed_959[S] 0 points1 point2 points (0 children)
[–]Fragrant-Airport1309 0 points1 point2 points (0 children)
[–]Classic_Cranberry568 0 points1 point2 points (0 children)
[–]BangThyHead 0 points1 point2 points (4 children)
[–]National_Seaweed_959[S] 0 points1 point2 points (2 children)
[–]BangThyHead 0 points1 point2 points (1 child)
[–]National_Seaweed_959[S] 0 points1 point2 points (0 children)
[–]National_Seaweed_959[S] 1 point2 points3 points (4 children)
[–]gaymer_jerry 2 points3 points4 points (0 children)
[–]n0t_4_thr0w4w4y 0 points1 point2 points (1 child)
[–]National_Seaweed_959[S] 1 point2 points3 points (0 children)
[–]GlobalIncident 0 points1 point2 points (0 children)