2 ms·
I don't think there are generally agreed upon definitions of strong vs. weak, but I think a useful definition is about changing the type _while referring to the
by uv-depression 3y ago
I don't think there are generally agreed upon definitions of strong vs. weak, but I think a useful definition is about changing the type _while referring to the same data_ as weakness. In your Python example there, I think we can say it's dynamically + strongly typed because you're assigning the name `a` to three different objects with different types, not changing the interpretation of any actual data in memory. C would be statically + weakly typed, because you can cast the same exact data to whatever type by using `void*`. Rust is static + strong, and I can't really think of a dynamic + weak language. Probably that would be a nightmare to work in.
- dunefox 3y ago> I can't really think of a dynamic + weak language. Javascript comes to mind. https://www.destroyallsoftware.com/talks/wat https://www.destroyallsoftware.com/talks/wat
- tgv 3y agoYou're right, there are none. The link from the GP shows several. > changing the type _while referring to the same data_ as weakness Python performs arithmetic and comparison on ints mixed with floats. In other languages, you have to cast those first. It does array subscription on a string. You could even see an expression like 3 * "x" as a type change. > I can't really think of a dynamic + weak language It depends on what you call a type, I guess. Is [1, 2] a different type than ["a", "b"]? You can't tell in Python, because there is no type declaration. That makes comparison with polymorphism moot. You can think that the type of b in a + b must be "whatever a's plus operator accepts", but I wouldn't call one or two sanity checks before adding strong typing.