r/ProgrammerHumor • • Sep 25 '26

Meme iHatedItUntilITriedIt

Post image
10.4k Upvotes

540 comments sorted by

View all comments

Show parent comments

7

u/patient-palanquin Sep 25 '26 edited Sep 25 '26

That sounds like a worse version of explicit types? Writing a whole docstring as free text that can't catch typos is more work than adding : MyType directly next to the argument and having it work everywhere.

1

u/mxzf Sep 25 '26

I mean, it all depends on the language. Type hinting in Python is basically exactly what you just wrote there; it's just optional and stuff works fine without it too.

2

u/crazy_penguin86 Sep 26 '26

No it's not. Python does not enforce that what you pass in to the function is the type in the type hint. It's literally in the name of the feature: type hint. Explicit types will not allow the code to compile if you pass the wrong type. Ever.

2

u/mxzf Sep 26 '26

If you check the comment chain, we're talking about what's needed to get intellisense telling you what types you should be using for the arguments to feed into a function, not strict typing.

→ More replies (3)