Python is DOOMED! Again!

Steven D'Aprano steve+comp.lang.python at
Thu Jan 29 16:56:45 CET 2015

random832 at wrote:

> On Wed, Jan 28, 2015, at 13:16, Mark Lawrence wrote:
>> C and C++ are weakly and statically typed languages.
> "strong typing" has no meaning at all, and "weak typing" means "anything
> I don't like".

I see you've been reading Chris Smith's essay on typing :-)

I think his essay is excellent, but his claim that strong and weak typing is
a meaningless distinction is excessive.

> The fact that you can add an int and a float, or that you can use any
> object as a boolean, would make python weakly typed in some people's
> eyes.

I think they would be wrong. Well, mostly wrong. But a little bit right.

We should agree that there is no universal, hard distinction between strong
and weak typing. But the names already suggest that -- there is no dividing
line between strong and weak. But we can certainly *rank* languages by
degrees of strength according to some standard, and if we agree on the
standard, we should agree on the rankings.

Even if we don't agree on a standard, we can surely agree on the two extreme
cases. Let's call them Foo and Bar language. They're both typed languages.

Foo language has no automatic coercions at all. Every type is utterly
distinct. The only way to convert a value of one type to another is with an
explicit XtoY function. Surely we can agree that Foo is a *very strongly
typed* language? (Perhaps even too strong?)

Bar language, on the other hand, tries extremely hard to ensure that every
type is automatically able to be coerced into every other type. The
coercion might not do what you expect, but it will do *something*:

{'a': 100, 'b': 300} + 5.0
=> 7.0

[1, 2, 3] + "hello"
=> [1, 2, 3, 'h', 'e', 'l', 'l', 'o']

"hello" + [1, 2, 3]
=> "hello[1, 2, 3]"

Bar will never give you a TypeError. I think we can agree that Bar is a
*very weakly typed* language.

There are degrees of strength, and I think that Python comes closer to the
Foo end than the Bar end. There are few automatic coercions, and most of
those are in the numeric tower according to the usual mathematical rules.


More information about the Python-list mailing list