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

Programmer Humor

23919 readers
1080 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
[–] capybara@lemm.ee 32 points 3 days 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.

[–] Jankatarch@lemmy.world 31 points 3 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.

[–] capybara@lemm.ee 7 points 3 days 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.

[–] random8847@lemmy.world 8 points 2 days ago (1 children)

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

[–] capybara@lemm.ee -4 points 2 days ago

Use typescript

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