in reply to Perl 6: Static/Dynamic Strong/Weak Type Systems

I still think Dominus said it best (quoted below). And I appreciate the research he did into this question.

Message-ID: <20010623153305.20460.qmail@plover.com>
To: clpm@lists.eyrie.org
Subject: Re: Perl *is* strongly typed (was Re: Perl description) 
Date: Sat, 23 Jun 2001 11:33:05 -0400
From: Mark-Jason Dominus <mjd@plover.com>
Newsgroups: comp.lang.perl.moderated

. . .
...a type system that only has three or four types in it was a very weak type system indeed. Fortran IV (1966) has more types than that, and I don't think many people would claim that Fortran was a strongly typed language; my previous message showed that AWK has similar checks, and I have never known anyone to make the claim that AWK is a strongly typed language.

My argument wasn't that Perl isn't strongly typed, because I don't pretend to know what that means. Let me say that again: I don't know what it means for a language to be 'strongly typed'. I'm not arguing with you because I think you're wrong and I think Perl is not a strongly typed language. I do not know what 'strongly typed language' means. (I did some research, and it didn't help; see below.)

All I said was that if Perl is considered strongly typed, then I don't think the concept is useful or meaningful, because *every* language is strongly typed. It appears from your argument above that you would consider AWK and Fortran IV to be strongly typed languages also. That may be a logically consistent position to take, but it does not seem to be a very useful one. My original message asked Randal to produce an example of a language that is *not* strongly typed, and I don't think you can do that---if you're going to rule out examples like AWK, that doesn't leave you with very much to work with. (I guess you could bring up assembly language. But that would be a silly evasion.)

From a brief survey of web documents about strong typing, it appears that the description 'strongly typed language' does *not* have any useful or agreed-upon meaning. The confusion is not simply about where to draw a line on a linear scale of type granularity or degree of error checking or anything like that; it's not that some people think a strongly-typed language needs fifty types and others think it needs only thirty. There appears to be a fundamental confusion about the basic meaning of the term 'strongly typed language'. In a couple of hours, I found eight different and incompatible definitions of 'strongly typed language':

  1. A language is strongly typed if type annotations are associated with variable names, rather than with values. If types are attached to values, it is weakly typed.

  2. A language is strongly typed if it has compile-time checks for type constraint violations. If checking is deferred to run time, it is weakly typed.

  3. A language is strongly typed if it has compile- or run-time checks for type constraint violations. If no checking is done, it is weakly typed.

  4. A language is strongly typed if conversions between different types are forbidden. If such conversions are allowed, it is weakly typed.

  5. A language is strongly typed if conversions between different types must be indicated explicitly. If implicit conversions are performed, it is weakly typed.

  6. A language is strongly typed if there is no language-level way to disable or evade the type system. If there are casts or other type-evasive mechansisms, it is weakly typed.

  7. A language is strongly typed if it has a complex, fine-grained type system with compound types. If it has only a few types, or only scalar types, it is weakly typed.

  8. A language is strongly typed if the type of its data objects is fixed and does not vary over the lifetime of the object. If the type of a datum can change, the language is weakly typed.

Some of these are contradictory; some are merely orthogonal. Many came from class notes for undergraduate CS courses. Not all of these instructors and experts can be mistaken. The only sensible conclusion is that there is no agreement about what it means to be a strongly typed language.

Examples are no help here:

I found several pages that asserted that C is a strongly-typed language.
I found several pages that asserted that C is a weakly-typed language.

I found several pages that asserted that C++ is a strongly-typed language.
I found several pages that asserted that C++ is a weakly-typed language.

I found several pages that asserted that Lisp is a strongly-typed language.
I found several pages that asserted that Lisp is a weakly-typed language.

I found several pages that asserted that Perl is a strongly-typed language.
I found several pages that asserted that Perl is a weakly-typed language.

. . .

original message by MJD ⇒(Google groups)

We're building the house of the future together.
  • Comment on Re: Perl 6: Static/Dynamic Strong/Weak Type Systems