Getting started

Adam Taylor ataylor at ucsd.edu
Thu Sep 26 15:28:29 EDT 2002


> My read of page 5 is he equates his internal use of "weakly checked" 
> with "weakly typed" and further suggest that the latter term is commonly 
> used "in the literature," which it does seem to be.

This sounds like the same thing as I said, or damn close.  Am I
missing something?

> I think your read of Cardelli overall is correct -- that Python, like 
> Lisp, would be classified as "untyped" because it has no static type 
> system.  

Yes.  It seems to me that Table 1 in Cardelli:

          Typed   Untyped
Safe      ML      LISP
Unsafe    C       Assembler

Might be better like this:

          Statically typed   Dynamically typed    Untyped
Safe      ML                 LISP
Unsafe    C                                       Assembler

(Python would also be in the (Safe,Dynamically typed) position.)

Although safety and strongly-checked are not the same thing, this
table is also correct:

                      Statically typed   Dynamically typed   Untyped
Strongly checked      ML                 LISP
Weakly checked        C                                      Assembler

> A literal reading furthermore defines "weakly typed" only in 
> terms of static checking.

I don't understand what you mean by this.  Cardelli never uses the
term "weakly typed" himself, he only uses it that one time, to say
that it's the term most people use for the concept that he prefers to
call "weakly checked".

> Interestingly, a google search on the term revealed that about 25% of 
> the meaningful hits equated "weakly typed" and "dynamically typed" (the 
> latter of which is what Cardelli calls "untyped").  The other 75% 
> generally characterized strong vs. weak type systems in terms of "type 
> safety", i.e., a mechanism for preventing  "type errors," regardless of 
> whether the checking is done statically or dynamically.  [The list of 
> references appears in a prior post to this thread.]

So 75% of people, when they talk about strongly-typed vs. weakly-typed
languages, are refering to the strongly-checked vs. weakly-checked
axis in the table above, whereas 25% of people are refering to the
statically-typed vs. dynamically-typed vs. untyped axis.  These
numbers (75% and 25%) seem far enough from 100% and 0% that everyone
would be better off not using the terms "strongly typed" and "weakly
typed", and using "strongly checked", "weakly checked", "statically
typed", "dynamically typed", or "untyped", as appropriate.  Or at
least when people start talking about "strongly typed" vs "weakly
typed" languages, that first thing to get straight is which axis
they're talking about.

Adam

-----
"James J. Besemer" <jb at cascade-sys.com> wrote in message news:<mailman.1032982114.4627.python-list at python.org>...
> Adam Taylor wrote:
> 
> > This last is available at:
> > http://research.microsoft.com/Users/luca/Papers/TypeSystems.pdf 
> 
> I believe your interpretation is accurate for the most part.
> 
> > Cardelli doesn't use the term "weakly typed" himself, but on page 5 he
> > seems to be say that "weakly typed" is the commonly used term for what
> > he calls "weakly checked".  C is weakly checked, in his terminology, and
> > that's why it's unsafe. 
> 
> 
> My read of page 5 is he equates his internal use of "weakly checked" 
> with "weakly typed" and further suggest that the latter term is commonly 
> used "in the literature," which it does seem to be.
> 
> > But people on this thread seem to be using "weakly typed" to mean
> > roughly the same thing as Cardelli's "untyped".  Which is fine, and
> > pretty close to Cardelli's terminology.  But clearly the terms "untyped"
> > (=="weakly typed" on this thread) and "weakly checked" (=="weakly typed"
> > in common usage) are very different things. 
> 
> 
> Well, some people here use the term casually and incorrectly, as a 
> measure of quality of a language's object model, which I am sure you'll 
> agree is completely inconsistent with most uses of the term, including 
> Cardelli's.
> 
> Interestingly, a google search on the term revealed that about 25% of 
> the meaningful hits equated "weakly typed" and "dynamically typed" (the 
> latter of which is what Cardelli calls "untyped").  The other 75% 
> generally characterized strong vs. weak type systems in terms of "type 
> safety", i.e., a mechanism for preventing  "type errors," regardless of 
> whether the checking is done statically or dynamically.  [The list of 
> references appears in a prior post to this thread.]
> 
> I think your read of Cardelli overall is correct -- that Python, like 
> Lisp, would be classified as "untyped" because it has no static type 
> system.  A literal reading furthermore defines "weakly typed" only in 
> terms of static checking.
> 
> However, I submit that his use is inconsistent with the more common use 
> of the term.  Too, I think this is actually a minor oversight in 
> Cardelli's paper.  His focus overall was static systems and I think he 
> simply didn't give enough consideration to dynamically typed languages. 
>  E.g., he says "untyped" languages such as Lisp can be "safe" but he 
> defines "weakly typed" only in terms of languages that do static type 
> checking.  I would argue that in the first place he misclasifies Lisp as 
> "untyped".  I suspect he took the naive view of Lisp, in which 
> everything is a list, when in fact a rather wide variety of "objects" 
> actually exist in a typical, mature Lisp system.  Of course, Python and 
> Smalltalk are better examples, in that they both have robust object type 
> systems and are in principle very secure from a type checking sense. 
>  (Of course, there are probably things you can do with the compiler and 
> debug class objects that violate type safety, making them both unsafe in 
> general.)
> 
> The primary distinction between safe and unsafe, strong and weak type 
> systems revolves around the notion of whether or not "type errors" can 
> be prevented by the type system.  The distinction between typed and 
> untyped is less interesting, except to use "untyped" as a way to 
> eliminate a class of languages from further discussion.  Within typed, 
> there should be two sub-classes, based on whether type checking is 
> primarily static or dynamic.  This is more interesting and useful, and 
> is consistent with "the literature" as far as I can determine.  
> 
> I furthermore have a conjecture that much of Cardelli's work on 
> "judgments" would apply equally well to static and to dynamic systems. 
>  The important criterion is that the type system be secure and that the 
> total collection of function x arguments definitions be unambiguous (at 
> least during the sequence of computation of interest).  Whether the 
> checks take place at compile time or at runtime I don't think materially 
> affects his theories.  But I could be overlooking something in this regard.
> 
> In any case, my own use of the term "weakly typed" and associated terms 
> (strongly typed, type safety, etc.) in this thread have been consistent 
> with "the literature" (though slightly inconsistent with Cardelli), in 
> that I class Python to be "strongly typed" using "dynamic checking".   
> That seems to be the consensus here.  Only confusion has been about 
> "weakly typed," and hopefully we're close to exhausting that topic..
> 
> --jb



More information about the Python-list mailing list