3 ms·
If Python had static typing though, wouldn't that have introduced a compile time error instead of a runtime error? At the least it would alert you to all the pl
by seanwilson 9y ago
If Python had static typing though, wouldn't that have introduced a compile time error instead of a runtime error? At the least it would alert you to all the places you had to make the decision instead of waiting for a runtime crash.
- tyingq 9y agoIntroducing a new type to a statically typed language still requires that decision point. The compiler can't know what was string and now should be byte. So there wouldn't be errors, other than maybe for types you're passing into 3rd party libraries that changed themselves from 2 to 3. Yes, it would help after that decision. And as mentioned, the byte "backported (sort of)" to 2.x acts and works differently than the byte in 3.x. So there actually 3 types in play, plus bytearray too.
- seanwilson 9y agoYeah, I'm not saying static typing would make the decision for you but it would let you know every line in your code where the decision had to be made instead of having to rely on runtime crashes or debugging weird behaviour. The latter is really horrible as well as it's hard to pinpoint where the problem originates from and you sometimes have to delve into the innards of libraries you're using to understand what's going on. I just think it's a good example of how strong static typing makes refactoring large projects significantly easier compared to strong dynamic typing. Getting everyone to move from Python 2 to 3 is basically a massive refactoring task.