3 ms·
This still produces a runtime error, to make code maintainable you want to be able to check the types without having to run the program. The type annotations he
by takeda 6y ago
This still produces a runtime error, to make code maintainable you want to be able to check the types without having to run the program. The type annotations help with that, they allow to spot bugs in the code and make an IDE to correctly refactor code and provide autocomplete.
- ed25519FUUU 6y agoType checks don’t actually enforce anything though, and as far as I can tell don’t even produce a warning in vscode unless everything is typed (a typed var fed into a typed function signature).
- takeda 6y agoCorrect, the annotations in python don't enforce anything, although there are packages that make them produce errors, but again, those errors are at runtime. You can run mypy which will list problems. Also PyCharm understands the annotations and does all the things I mentioned it do: proper autocomplete, proper refactoring functionality and highlighting errors
- kerkeslager 6y ago> This still produces a runtime error, to make code maintainable you want to be able to check the types without having to run the program. I strongly disagree. There are plenty of ways to write maintainable code. Static types can help, but it's quite possible to write maintainable code in dynamically typed languages. And, for the record, running unit tests doesn't require me to run the whole program. And, even if I never explicitly test types (assert isinstance(foo, str) is an antipattern anyway), behavioral tests of my code will turn up most type errors. The obsession with checking types at compile time rather than 30 seconds later while running the unit tests doesn't serve anyone.