Remix.run Logo
sails01 6 days ago

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

kurtis_reed 5 days ago | parent | next [-]

Newsflash: not everything good has a study about it

wiseowise 5 days ago | parent | prev | next [-]

> 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?

dllthomas 5 days ago | parent [-]

I think there are both of those.

bmitc 6 days ago | parent | prev | next [-]

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

pansa2 6 days ago | parent | next [-]

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

sails01 6 days ago | parent | prev [-]

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

dragonwriter 5 days ago | parent | next [-]

> 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.

tome 5 days ago | parent [-]

> > 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-...

amethyst 6 days ago | parent | prev | next [-]

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

wiseowise 5 days ago | parent | prev [-]

> static typing is used at runtime

Educate yourself before making such claims.

hexo 6 days ago | parent | prev | next [-]

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

sails01 6 days ago | parent [-]

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

solarkraft 5 days ago | parent | prev [-]

it has been consensus for decades at this point.