Are the critiques in "All the things I hate about Python" valid?

Michael Torrie torriem at gmail.com
Sun Feb 18 10:44:39 EST 2018


On 02/18/2018 05:45 AM, Anders Wegge Keller wrote:
> På Sun, 18 Feb 2018 07:34:03 -0500
> Richard Damon <Richard at Damon-Family.org> skrev:
> 
>> Python is much stronger typed than PHP, because in PHP you can do things 
>> like 1 + '2' and get 3, as string values will naturally convert 
>> themselves to numbers, Python won't do this. Yes Python will freely 
>> convert between numeric types, but I wouldn't say that Python claims to 
>> be a language that focuses on numerics.
> 
>  Type coercion is not the same as weak typing. Let me stress that the
> difference between languages having 1 + 1.23 as a valid construct and
> languages having 1 + '1.23' as a valid construct, is merely a design
> descision. PHP is fully aware that a string and an integer have different
> types, and makes a implicit cast, rather than throw an error. 

And indeed language design decisions bring about weak or strong typing.
So it's not a stretch at all to say Python has strongly typed objects.
It does. Once created, objects are what they are; they cannot be changed
into different objects without creating a new object.

As for numeric coercion, Python could have made numeric types stronger
and dropped all coercion. Maybe it should have.  But it appears to
generally follow the same coercion patters as other commonly-used static
type languages like C.  In this we can agree that Python's typing was
weakened, but so also is C.

It's interesting to see C++ move to become more like a dynamically-typed
language like Python.  I recently saw a talk about how C++ inheritance
is not as good as we all thought it was.  Why should it matter what an
object inherits from, if it supports the interface we desire? (Duck
typing, essentially).  So there's now a rather complicated C++17 idiom
for wrapping objects with special interfaces so that we can make a list
that contains different types (just like python!) that happen to all
support the same method signature.  Anyway, was interesting.



More information about the Python-list mailing list