Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Is there any study that shows that typing in Python improves code quality and reduce runtime issues?




> Ughm, is there any study that shows that guardrails and lights on bridges reduce fatalities?

> Akshually, are there any studies showing that cars riding 30 km/h kill less people than cars that ride 80 km/h?


I think there are both of those.

Newsflash: not everything good has a study about it

Well, it's just a documentation suggestion for user. Having for me about same value as if it was written in pydoc. I'd really love to see such study as well

Agree, we already had a solution documenting types in docstring.

In my case they just add noise when reading code and make it more difficult to review


it has been consensus for decades at this point.

That's equivalent to asking if there are benefits of static typing.

Specifically, it's like asking if there are any studies that demonstrate benefits of static typing. Are there?

Not quite, static typing is used at runtime, python type annotations are not

> Not quite, static typing is used at runtime, python type annotations are not

No, static typing is usually used AOT (most frequently at compile time), not usually at runtime (types may or may not exist at runtime; they don't in Haskell, for instance.)

Python type checking is also AOT, but (unlike where it is inextricably tied to compilation because types are not only checked but used for code generation) it is optional to actually do that step.

Python type annotations exist and are sometimes used at runtime, but not usually at that point for type checking in the usual sense.


> > Not quite, static typing is used at runtime, python type annotations are not

> No, static typing is usually used AOT (most frequently at compile time), not usually at runtime (types may or may not exist at runtime; they don't in Haskell, for instance.)

In fact, Haskell then allows you to add back in runtime types using Typeable!

https://hackage.haskell.org/package/base-4.21.0.0/docs/Data-...


tools like dataclasses and pydantic would like to have a word...

> static typing is used at runtime

Educate yourself before making such claims.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: