5 ms·
OP is not saying that type checking is useful. They’re saying that it’s not as useful.
by KyeRussell 4y ago
OP is not saying that type checking is useful. They’re saying that it’s not as useful.
- phailhaus 4y agoWhat about Python's data model makes typechecking less useful? You still need to know how data flows through your application. You can either document it in your types, or require your engineers to hold all that information in their heads/recapitulate it every time they want to refactor code. That has nothing to do with the language's data model.
- ReflectedImage 4y ago[flagged]
- phailhaus 4y agoCitation heavily, heavily needed. Dynamic typing means that none of your code can be statically checked, which means that correctness relies on the exhaustiveness on your tests. It should be obvious that this would allow you to introduce more bugs, not fewer. Every program involves passing around data. When you need to change that data in a dynamic untyped language, you have no option but to manually test your whole system to make sure that you nailed all the spots. Compare that to a language like TypeScript. If I need to refactor my code, I update the type and the static typechecker immediately tells me all the spots I need to fix. I don't have to hunt for them, I don't have to run it 100x trying to hit every edge case. And JavaScript is still dynamic, it doesn't stop me from writing concise code. This isn't theoretical. I literally just worked on changing something from a dict to an object in Python, and it was a pain. Thankfully most spots were documented with type hints, but even then I ran into many runtime errors that could have been caught statically.
- ReflectedImage 4y ago[flagged]
- deleted 4y ago[deleted]
- deleted 4y ago[deleted]
- phailhaus 4y ago> No citation is needed, it's fairly obvious to any experienced Python programmer. So you can't even explain it, despite claiming to be experienced. Why should I listen to you? Your whole response is just you saying "First off, you're wrong. Second off, I'm right." Here's a very simple example: I want to change a dict to a class. In untyped Python, how do you make sure that you make this change safely without introducing new bugs into your application?
- ReflectedImage 4y agoHere's a citation if it makes you happy: https://games.greggman.com/game/dynamic-typing-static-typing/ https://games.greggman.com/game/dynamic-typing-static-typing... 2% of bugs can be caught via static typing. For your very simple example, your IDE can do that!
- phailhaus 4y agoHere is a study that show Python is more bug-prone and that TypeScript is far more reliable: https://danluu.com/empirical-pl/ https://danluu.com/empirical-pl/ That source shows why language studies are so difficult, and why it is hard to draw conclusions. For example, your study doesn't count KeyErrors or NoneType exceptions as type errors, but those count as well. There are other considerations: you're only looking at released projects which might have a ton of tests to balance the fact that they're dynamic. But there is absolutely no way you can say "dynamic languages are less buggy". There's no data for that. > For your very simple example, your IDE can do that! No it can't. An IDE doesn't help at all here, because it doesn't know where you passed around that dict, and where it was created. There's no type hints. That dict is now a class, and you have to go find where else you used it. If you don't use any type hints in Python, how would you find all those cases? You have to hunt for it yourself, grok the entire codebase (which you may not have worked in for a while), and then run it a ton of times to make sure you caught every edge case. Refactoring in Python is very time consuming and dangerous compared to typed languages.
- aragilar 4y agoThere are numerous static analysis tools for Python that predate type annotations, the biggest of which are pylint and pyflakes.
- bayesian_horse 4y agoThere is almost no evidence type safety helps at all. Anecdotally, I don't find I have bugs in Python that could be caught by typesystems easily.