this post was submitted on 02 Nov 2023
1409 points (98.6% liked)

Programmer Humor

32588 readers
974 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] marcos@lemmy.world 4 points 1 year ago (2 children)

That kind of code usually is written on a restricted dialect of C.

C is not a language that allows for that kind of safety practice even on the fully-featured version.

[–] Duralf@lemmy.world 3 points 1 year ago

Even in C this is possible. Just wrap the float or whatever in a struct and all implicit conversions will be gone.

[–] jbrains@sh.itjust.works 1 points 1 year ago (1 children)

Indeed, this is a time for naming conventions that communicate the details that the type system can't clarify. This leads to the long names that senior programmers make fun of. Don't listen to them; let them laugh then make this kind of mistake.

[–] marcos@lemmy.world 1 points 1 year ago (1 children)

This leads to the long names that senior programmers make fun of.

Hum... The notation that I've seen people making fun of is one where the long names encode the exact same information that C types can handle for you and nothing else. But YMMV.

Anyway, I don't think any naming convention can save you after somebody goes over your entire codebase converting things without care for the semantics. If you are lucky, it's one of the lazy people that do that, and you will "only" have to revise tens of thousands of lines to fix it. If you are unlucky, the same person will helpfully adjust the names for you too.

[–] jbrains@sh.itjust.works 1 points 1 year ago

Yes, any programmer who doesn't care will do damage, but when I see durationInMilliseconds, I think more about what the int means than when I see merely "duration". I don't know how to help the people who read that and ignore it.

The story of the 125 mph knuckleball might help.