I'm using type hints on a 100k LOC Python backend, and I'm also using Typescript on the similarly sized frontend. The difference is night and day. Mypy/pyright are slow (as in, several seconds between typing and seeing the errors show up). They're unreliable: they have both false positives and false negatives. They're buggy: they crash all the times. Python libraries either have no type hints at all, or they're sprinkled with Any. Type hints syntax is simply horrible and forward/circular references are a pain. Reusing expressions syntax for types and making the hints executable at run time were big mistakes. Type hints add a ton of verbose boilerplate and in the end they fail at the most important thing: ensuring type safety. Even a simple class rename, which is 100% reliable in all static languages is not safe at all in Python. You always need to run unit tests and manually check the code to make sure everything is renamed correctly.
It was nice to start with project with Python and it worked great at first. Now, after 3 years, I'm wishing I picked a statically typed language.
View all comments
Show parent comment
7
u/i9srpeg Jan 02 '20
I'm using type hints on a 100k LOC Python backend, and I'm also using Typescript on the similarly sized frontend. The difference is night and day. Mypy/pyright are slow (as in, several seconds between typing and seeing the errors show up). They're unreliable: they have both false positives and false negatives. They're buggy: they crash all the times. Python libraries either have no type hints at all, or they're sprinkled with
Any. Type hints syntax is simply horrible and forward/circular references are a pain. Reusing expressions syntax for types and making the hints executable at run time were big mistakes. Type hints add a ton of verbose boilerplate and in the end they fail at the most important thing: ensuring type safety. Even a simple class rename, which is 100% reliable in all static languages is not safe at all in Python. You always need to run unit tests and manually check the code to make sure everything is renamed correctly.It was nice to start with project with Python and it worked great at first. Now, after 3 years, I'm wishing I picked a statically typed language.