[Python-ideas] [Wild Idea] Static Ducks

Mike Meyer mwm-keyword-python.b4bdba at mired.org
Fri Sep 25 02:52:31 CEST 2009

On Thu, 24 Sep 2009 20:06:22 -0400
Gerald Britton <gerald.britton at gmail.com> wrote:

> I think that the idea that there is a continuum from weak typing to
> strong typing is useful.

I think it's fundamentally broken, at least as badly as the notion of
a political spectrum from liberal to conservative. The problem with
both of those is that there's more than one axis involved. Just as
people can have a liberal position on one issue while having a
conservative position on another, languages can have some features
that give them "weak typing" and others that give them "strong

This is different from the "large" vs. "small" distinction previously
mentioned, because size can be measured on a single axis, with the
large/small distinction depending on the context.

> At the weak end, the compiler lets you do anything with anything
> without any declarations.  At the strong end, you have to declare
> everything and explicitly code all type conversions.

See, you've just pointed out two axis: If declarations are optional
because the language does type inferencing, but the language does *no*
implicit conversion (ala at least some ML variants), is the typing
strong or weak?

Likewise, if I have to declare everything, but the language pretty
much lets me do anything with anything and will "fix" it (I think it
was Waterloo's PL/I that did this....), which end is it at?

What about if I have to declare everything, but not provide type
information, and you can do anything to anything (BCPL)?

By invoking the compiler, you actually referenced yet another type of
typing: checking done by the compiler is conventionally known as
"static" typing; checking done at run time is "dynamic" typing. This
one, at least, has a clearcut definition. But it's not really related
to strong .vs. weak.

Finally, Python is usually considered strongly - but dynamically -
because it doesn't do many implicit conversions. Perl is also
dynamically typed, but normally usually considered weekly typed,
because it does *lots* of implicit conversion.

But - Python will implicitly convert *anything* to a bool. Perl won't
do that. Now, which one is strongly typed again?

Axis so far: declarations: yes/no/optional. Variables have types:
(yes/no/optional). Implicit conversion: yes/no, with a different
answer possible for every operand and tuple of operators types in the

> It's probably possible to devise some sort of metric to be able to
> place a given language on the weak-strong scale.

I don't think it's possible, because your scale is really a space.

> Where would Python fall?  Probably towards the weak end.  Is that bad?  No way!

Like I said, it's usually considered to be near the strong end,
because it does few implicit conversion. When compared to other
dynamically typed languages, it's *definitely* towards the strong
end. But dynamic typing by it's very nature includes things that make
typing look weak (types are tied to objects, not variables; no
declarations), so people may be tempted to tag it as weakly typed
because of those.

Mike Meyer <mwm at mired.org>		http://www.mired.org/consulting.html
Independent Network/Unix/Perforce consultant, email for more information.

O< ascii ribbon campaign - stop html mail - www.asciiribbon.org

More information about the Python-ideas mailing list