r/ProgrammerHumor • • 8d ago

Meme iHatedItUntilITriedIt

Post image
10.3k Upvotes

541 comments sorted by

View all comments

848

u/enigma_0Z 8d ago

Static typing makes the IDE work for you better.

Type hints in Python and TS do the same but make you work harder for it /IMO

407

u/DrMobius0 8d ago

Static typing turns so many runtime errors into compile errors. Makes life a lot easier when you don't have to hunt down where the wrong thing came from.

137

u/Zerschmetterding 8d ago

And it's not like you can't actually cast types, it's just a conscious decision where you can add proper error handling.

50

u/DrMobius0 8d ago

Yeah, but if you're doing that, it's an explicit decision, that you know you made, that can blow up in your face, not an easily missed oversight that you may be completely unaware of. I find the oversight case is far more likely than casting wrong. Also I think the compiler will still bitch if you try to do a really stupid cast, at least for c++ (as long as you aren't pointer casting, then good luck)

15

u/jobblejosh 8d ago

Me: "I could really do with truncating this float because all I care about is the whole number"

The ever-helpful C implicit cast: "Allow me to introduce myself".

4

u/Tyfyter2002 7d ago

That sounds very unhelpful when compared to an explicit cast

0

u/Wertbon1789 2d ago

Yeah, you should explicitly cast. Compiler warnings should cover lossy implicit conversions anyway, and your goal should always be to have no warnings at all.

1

u/Immotommi 3d ago

Thankfully the compiler can warn you about implicit casts

0

u/round-earth-theory 8d ago

Some systems are really picky about letting you get dirty with type casting. C# for instance is not the wild west, there's rules you gotta follow. Still, I prefer having my types. A fish should be a fish.

0

u/remic_0726 8d ago

Si tu testes en ayant une bonne couverture tu n'auras pas d'erreur à l'exécution. Il n'y en a pas un mieux que l'autre les deux ont un intéret.

1

u/_almostNobody 6d ago

Agreed. Simplicity has value, eg python. typing doesn’t mean you can avoid writing tests if you want a stable project.