this post was submitted on 04 Jun 2025
1020 points (98.6% liked)

Programmer Humor

23844 readers
1947 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 2 years ago
MODERATORS
 
top 50 comments
sorted by: hot top controversial new old
[–] [email protected] 2 points 1 day ago* (last edited 1 day ago)

javascript is to web developers what powerpoint is to sales people

[–] [email protected] 27 points 2 days ago (2 children)

Imagine doing math with strings and then blaming the language not yourself

[–] [email protected] 43 points 2 days ago (1 children)

The risk is when it happens unintentionally. The language is bad for hiding such errors by being overly 'helpful' in assuming intent.

[–] [email protected] 6 points 2 days ago (2 children)

Sure, but at this point it's your own fault if you don't use Typescript to keep these issues from happening.

[–] [email protected] 23 points 2 days ago (1 children)

"Use a different language" is a common defense of javascript, but kind of a weird one.

[–] [email protected] 5 points 2 days ago (1 children)

Not really, considering Typescript only adds static types to JS. It's not a different language, it's an extension.

[–] [email protected] 6 points 1 day ago (1 children)

Since it needs to be compiled to JavaScript in order to be used, I kind of consider it a different language. Yes, it's a strict superset of JavaScript, but that makes it different.

load more comments (1 replies)
[–] [email protected] 9 points 2 days ago (3 children)

So, just don’t use JavaScript?

[–] [email protected] 8 points 1 day ago (2 children)

That's also my understanding: "Javascript is great because you can use other languages and then transpile them to JS."

[–] [email protected] 3 points 1 day ago

Oh man machine language is so good, literally the best actually

load more comments (1 replies)
load more comments (2 replies)
[–] [email protected] 16 points 2 days ago

The problem is consistency.

[–] [email protected] 14 points 2 days ago* (last edited 2 days ago) (1 children)

Javascript is a dogshit language that everyone is stuck with. The best that we can hope for is the likes of typescript take the edge off of it. Even though it's like smearing marzipan over a turd. At least it's ok if you don't take a deep bite.

[–] [email protected] 6 points 1 day ago

JS should have never leaved the Browser side. Now you can use this thing for Backend and is just awful

[–] [email protected] 205 points 3 days ago* (last edited 3 days ago) (17 children)

This is too stupid so I had to check.

Fuck me.

[–] [email protected] 113 points 3 days ago* (last edited 3 days ago) (3 children)

Hm, playing devil's advocate, I think it is because the minus has not been defined as a string operation (e.g. it could pop the last char), so it defaults to the mathematical operation and converts both inputs into ints.

The first is assumed to be a concat because one of the parcels is a string...

It's just doing a lot of stuff for you that it shouldn't be in first place 🤭

[–] [email protected] 40 points 3 days ago (8 children)

Yup. It's completely inconsistent in its interpretation of the + operator.

load more comments (8 replies)
[–] [email protected] 12 points 2 days ago (1 children)

Yeah, this looks dumb on the surface, but you've got bigger problems if you're trying to do math with strings

[–] [email protected] 4 points 1 day ago

Better than doing physics with strings

load more comments (1 replies)
[–] [email protected] 38 points 2 days ago

From all the Javascript quiks this is the least stupid and the most obvious.

[–] [email protected] 30 points 2 days ago (2 children)
[–] [email protected] 35 points 2 days ago (3 children)
load more comments (1 replies)
load more comments (14 replies)
[–] [email protected] 20 points 2 days ago (6 children)
[–] [email protected] 2 points 1 day ago

so plus coerces into string if not number, was that so hard?

[–] [email protected] 8 points 2 days ago

Oh wow, that's upsetting

load more comments (4 replies)
[–] [email protected] 31 points 2 days ago (1 children)

To start off... Using arithmetic operators on strings in combination with integers is a pure skill issue. Let's disregard this.

If you were to use + where one part is a string, it's natural to assume a string appending is desired since + is commonly used as a function for this. On the other hand, - is never used for any string operation. Therefore, it's safe to assume that it relates to actual artihmetics and any strings should therefore be converted to numerical values.

This is an issue with untyped languages. If you don't like it, use typescript. End of story.

[–] [email protected] 32 points 2 days ago (11 children)

Instead of trying to make it work, javascript could just say "error." Being untyped doesn't mean you can't have error messages.

load more comments (11 replies)
[–] [email protected] 5 points 1 day ago (3 children)
[–] [email protected] 28 points 1 day ago (1 children)
[–] [email protected] 6 points 1 day ago (1 children)

This here is my absolute favorits way to diss someone. Send the a wikipeda link and bam!

[–] [email protected] 2 points 1 day ago

It does to some degree.

  • "11" is string, 1 is an int, because strings can be added (+) convert int to string and combine: "11"+"1" = "111"
  • "11" is string, 1 is an int, because strings cant be subtracted (-) convert string to int and combine: 11-1 = 10

I'm not into JS so I don't know how it takes priority. ints can be added too, so I guess its basing it on the first variable which is compatible with the operator: in the first case string, in the second case int.

If this is how it works, it makes sense. But imo its a case of the designers being preoccupied with whether or not they could, they didn't stop to think if they should.

[–] [email protected] 8 points 1 day ago

.... It does?

[–] [email protected] 63 points 3 days ago (1 children)

[object Object][object Object]

load more comments (1 replies)
[–] [email protected] 43 points 3 days ago (8 children)

People that try to do mathematical operations with strings blaming the programming language that had a stated design goal to do its best and try to keep running scripts that make no sense because they realized it would be used by people that have no idea what they are doing. Clearly they were right.

[–] [email protected] 37 points 3 days ago (3 children)

the programming language that had a stated design goal to do its best and try to keep running scripts that make no sense...

...itself makes no sense. It is wrong and bad that Javascript was ever designed that way in the first place.

load more comments (3 replies)
load more comments (7 replies)
[–] [email protected] 10 points 2 days ago
[–] [email protected] 4 points 2 days ago

If you're consciously and intentionally using JavaScript like that, I don't want to be friends with you.

[–] [email protected] 22 points 2 days ago (4 children)

If you mix types like that, it's your own fault

[–] [email protected] 35 points 2 days ago (20 children)

BS. A language shouldn't have operators that allow non sensical operations like string concatenation when one operand is not a string.

load more comments (20 replies)
load more comments (3 replies)
[–] [email protected] 12 points 2 days ago

Heck, I need to learn some new languages apparently. Here I was expecting an angry "CS0029 cannot implicitly convert type 'string' to 'int'!

load more comments
view more: next ›