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

Programmer Humor

24391 readers
586 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
 
you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 32 points 2 weeks ago (12 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] 31 points 2 weeks 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.

[–] [email protected] 7 points 2 weeks ago (9 children)

This is fair enough from an idealistic view. In practice, you don't want your entire website to shit itself because of a potentially insignificant error.

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

I'd rather have my website shit itself than have silent difficult to find errors.

[–] [email protected] -4 points 2 weeks ago

Use typescript

load more comments (7 replies)
load more comments (8 replies)
load more comments (8 replies)