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

The bad practice is treating a dynamically typed language as if it was a statically typed language.

There are shorter more concise ways to write your programs if you are not using static typing.

If you are not writing your Python programs in the Pythonic way then you are not really using Python correctly and you do not get most of the benefits of the language.

Unit tests exist for catching bugs in Python. Type hints are for documentation not for ensuring code correctness.

Yes, there are libraries that take advantage of type hints, through they could of used other annonations and it's valid to use type hints along with those libraries.

But as soon as you are attempting to prove your program doesn't have bugs via typing rather than unit testing. You have gone wrong.

Typed Python is far more bug prone, why? Because structuring your Python code to support typing means writing considerably more lines of code.

It not the type hints themselves but it's the way you will structure your program at a high level to support them.

The more lines of code the more bugs it has. Bugs are well known to be proportion to the number of lines of source code regardless of language used or whether the language is typed or not.



> Typed Python is far more bug prone, why? Because structuring your Python code to support typing means writing considerably more lines of code.

That does not bear out in practice. In my experience, bugs have almost nothing to do with LoC. A short bit of complex, I/O heavy code with lots of state is going to be way more bug prone, and far harder to unit test correctly, than 10x the LoC of purely functional, well-typed, stateless code.

Mutation, parallelism, IO, and complex state space are the four horsemen of the bugpocalypse.

But in fact, I find functional, well-typed, properly abstracted code ends up with less LoC in the codebase, because it's more reusable and composes well.




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

Search: