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

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



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


There are numerous static analysis tools for Python that predate type annotations, the biggest of which are pylint and pyflakes.


[flagged]


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


Here's a citation if it makes you happy: 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!


Here is a study that show Python is more bug-prone and that TypeScript is far more reliable: 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.


[flagged]


That is the most brazenly false statement I've ever heard. "Python is superior due to dynamic typing, and also all types in Python can be statically inferred!" Wow, you should let them know that type hints was a total waste of time because you could already infer them!

I think it's clear you have a very weak understanding of this topic, and you have no interest in having a civil conversation. Good night!


You have clearly made up your mind and no matter what someone says you won't change it. Good luck learning new skills.


Well I'm showing evidence for my position and no one else is. My mind could be changed with evidence. But there isn't any as I'm correct.




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

Search: