4 ms·
There are actually some really good points here. I was bracing myself for the typical anti-dynamic-typing article that merely confuses dynamic typing and weak t
by mistercow 15y ago
There are actually some really good points here. I was bracing myself for the typical anti-dynamic-typing article that merely confuses dynamic typing and weak typing, but no, these are good points.
I will say, however, that weak typing can be used to overcome the first complaint. For example, in Python, if you were to do apply a function that resulted in integer overflow, you would get an automatic conversion to long integers. (The actual example doesn't really apply in this case, since to make that function work at all in Python, you'd have to to make `n` a float, which would fix the problem anyway).
Edit: And yes, I know that Python is a strongly typed language, but implicit conversion to long integers is still an example of weak typing.
- mindslight 15y ago> implicit conversion to long integers is still an example of weak typing No, it's an example of a properly defined integer type. Letting "integers" silently overflow is weak typing. If you explicitly want wraparound arithmetic (by proving bounds for performance or wanting implicit modulo), then explicitly specify int16/int32/int64.
- mistercow 15y ago> Letting "integers" silently overflow is weak typing. "Weak typing" is a broad concept, but that's not one of the ideas that it covers. In any case, Python's conversion of integers to long integers is not transparent. It is an actual change to a different type, which is an example of weak typing.
- kstrauser 15y agoPython never converts an int to a long. Instead, it may return a long from the result of an operation on an int if that result wouldn't find in an int.
- quatrevingts 15y agoThe term "weak typing" does not really mean anything and confuses a lot of discussions about programming languages. Here you are clearly talking about implicit conversions, but weak typing is also used to refer to completely unrelated things like casts in C (which can be unsound). Python having both "strong" and "weak" typing illustrates this: these terms are ill-defined. Edit: mindslight's comment adds another possible interpretation of "weak typing" (integers which overflow), further illustrating my point.