6 ms·
What I have seen happened on badly engineered large projects is people blaming it on dynamic typing because there is no documentation and no structural integrit
by dkarl 14y ago
What I have seen happened on badly engineered large projects is people blaming it on dynamic typing because there is no documentation and no structural integrity in the project.
This can be a problem in static languages with good type inference, too. When reading code in older static languages like C++, you'll find a bunch of variables and types declared, but powerful and concise languages such as Scala have much less use for intermediate variables, and type inference means that intermediate variables are almost never declared with a type. Field types and method return types often aren't declared either. I don't know if this is a good thing because it forces you to read a lot of code, or if it's a bad thing because it forces you to read many unrelated bits of code when you're trying to get something simple done.
- eru 14y agoIn theory, your IDE/editor should cooperate with the compiler and display the inferred types for you, if you choose so.
- dkarl 14y agoYeah... in theory. When it comes to Scala, Intellij is still getting there, and I haven't tried other options recently.
- spitfire 14y agoThat's because C and C++ are not static languages. Only people who leaned C and C++ first think they are.
- josephlord 14y agoThey are statically typed but only weakly typed (casts, void etc.) as is Java. Python is dynamically typed but again weakly. ML is strongly and dynamically typed. Anything that treats anything as a string or automatically casts from strings fills me with terror for general programming.
- abdulhaq 14y agoNo, python is strongly typed.
- masklinn 14y agoYou should avoid using those words, it merely marks you as somebody without a clue. I'm guessing your grandparent is already lost so there's no point in warning him.
- prodigal_erik 14y agoC and C++ are weakly typed because you can do things like int x = 42; printf("%c\n", *(char *) &x); that is, access the underlying bits which represent a value as if they were of some completely different type. The results are deliberately not standardized and vary with your machine. Python doesn't provide any way to do this; at worst you get a TypeError for a conversion that isn't implemented, or AttributeError for a slot that an object doesn't have. Implicitly parsing strings to produce numbers isn't weak typing, merely reckless and prone to mistakes. Weak typing can corrupt the state of your program so severely that even correct code begins to malfunction.
- masklinn 14y ago> C and C++ are weakly typed This, in and of itself, means absolutely nothing. And neither does: > Implicitly parsing strings to produce numbers isn't weak typing There is no such thing as a widely accepted, let alone formal, definition for a strong/weak axis, every other guy out there has his own personal definition. What the bloody hell is the point of words for which no two persons share the same definition? No point. None at all. See comment above, it merely marks you as a guy without a clue.
- gizmo686 14y agoBut, python is strongly typed, it just isn't dynamically typed. For example, javascript is a weakly typed language, because things such as "a"+1, and Math.floor("a") are all valid; while they would result in a type error in python. What makes python seem weakly typed to many people is its implicit variable shadowing. So when you do a="hello", a is a str, and can only be used where a str is expected. However, python lets you do: >a="hello" >a=1 at which point a is shadowed to an int. Dynamic typing has some (not all) of the problems weak typing has, but they are not the same thing