this post was submitted on 05 Aug 2025
88 points (97.8% liked)

Programmer Humor

25649 readers
1896 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
 

That's it. That's the meme.

you are viewing a single comment's thread
view the rest of the comments
[โ€“] squaresinger@lemmy.world 1 points 2 days ago (1 children)

Other languages handle that easily:

Implicit cast from number to string, explicit parsing in the other direction.

For comparisons as number, parse the string to a number and compare two numbers.

The main point of the implicit cast from number to string is to concattenate number to string, e.g. print("testValue: " + testValue).

Another option (e.g. taken by Python) is to acknowledge that there's no pure 1:n mapping in any direction between string and number, so any conversion between those two needs to be done explicitly. That's probably the most correct implementation, but it makes string concattenation annoying. But then again, f-strings and similar techniques make that problem pretty much obsolete.

[โ€“] Tetragrade@leminal.space 1 points 2 days ago

Yeah I mean it's definitely possible to write a mostly sensible string-number equality function that only breaks in edge-cases, but at this point it's all kinda vibes-based mush, and the real question is like... Why would you want to do that? What are you really trying to achieve?

The most likely case is that it's a novice that doesn't understand what they're doing and the Python setup you describe does a better job at setting up guardrails.

I don't really see the connection to concatenation, that's kind of its own thing.