Von Rossum on Strong vs. Weak Typing

Since this is something of a permathread on this list I though this would be of interest:

Strong versus Weak Typing
A Conversation with Guido van Rossum, Part V
by Bill Venners with Frank Sommers
February 10, 2003

http://www.artima.com/intv/strongweak.html

James Britt
http://www.jamesbritt.com
http://www.rubyxml.com
http://www.ruby-doc.org

Interesting, although he doesn’t seem to know the difference between
strong and static typing, as evidenced by:

The container problem is one issue. It's difficult in a language
without generics to write a container implementation that isn't
limited to a particular type. And all the strong typing goes out
the door the moment you say, "Well, we're just going to write a
container of Objects, and you'll have to cast them back to
whatever type they really are once you start using them." That
means you have even more finger typing, because of all those
casts. And you don't have the helpful support of the type system
while you're inside your container implementation.

That’s static typing, not strong typing. Static typing means a symbol
(or variable) is tied to a type. Strong typing means something
requires a particular type. The difference is sometimes subtle, but
important.

More misunderstanding:

Guido van Rossum: Well, they have to, because it is a strongly
typed language, and you can’t do certain things with strong typing
otherwise.

Weak typing is not really a fair description of what’s going on in
Python. It’s really runtime typing because every object is labeled
with a type.

Actually it’s somewhat of a shame that there’s this constant
confusion, especially by “prominent” members of the community, who
hurt matters. He implies here that strong typing is limiting, when
he means static typing instead. Strong typing actually gives you
more flexibility.

Common Lisp is a great example of something that has strong, dynamic
typing. (Actually the strong bit is optional, but then, so are most
things in Lisp. :wink:

Also, ruby can do strong, dynamic typing with my strongtyping module (on the RAA). ;-)

I know this is a hot topic, and I’m not going to push the matter one
way or the other. You can write code either way you like. Being able
to do both should be seen as a sign of great flexibility in a language.
I don’t like to see the misconceptions and confusion as in the above
quotes, though.

···

On Thu, 13 Feb 2003 10:10:44 +0900 jbritt@ruby-doc.org wrote:

Since this is something of a permathread on this list I though this
would be of interest:

Strong versus Weak Typing
A Conversation with Guido van Rossum, Part V
by Bill Venners with Frank Sommers
February 10, 2003

artima - Strong versus Weak Typing

Ryan Pavlik rpav@users.sf.net

“I distinctly remember dancing on your grave.” - 8BT

“I use Mailman and qmail, both are implemented in python”

Huh? Since when is qmail implemented in python?

Sam

Quoteing jbritt@ruby-doc.org, on Thu, Feb 13, 2003 at 10:10:44AM +0900:

···

Since this is something of a permathread on this list I though this would be of interest:

Strong versus Weak Typing
A Conversation with Guido van Rossum, Part V
by Bill Venners with Frank Sommers
February 10, 2003

artima - Strong versus Weak Typing

James Britt
http://www.jamesbritt.com
http://www.rubyxml.com
http://www.ruby-doc.org

It is interesting and consistent with Python’s design that Guido von
Rossum speaks in terms of writing and testing functions and nowhere
mentions methods.

On the issue of typing (as in type of object) as I understand Ruby:

  1. Ruby is strongly-typed, meaning that if an object receives a method
    that it cannot respond to, it will generate a type error if the method
    belongs to a built-in class, or a method missing error otherwise.

  2. Ruby is dynamically typed, meaning that variables (references to
    objects) are not typed and type is checked when a method is applied to
    the object.

  3. The future of Ruby will de-emphasize the term type and instead look
    at whether an object responds to method calls.

  4. Also, as I understand the concept of type, at least in the context
    of Ruby, it is really talking about class. The type of an object being
    defined by the methods it responds to means that the type is described
    by the class, because the class includes the collection of methods that
    can be used on the object.

  5. Note that the traditional primitive types (string, array, numeric)
    are classes in Ruby, and can be extended in a program. I’m also trying
    to say that with types = classes typing can be stronger than what just
    providing primitive types provides.

Please feel free to correct the above if you think I’ve gotten it wrong
:wink:

Interesting, although he doesn’t seem to know the difference between
strong and static typing, as evidenced by:

This point came up rather quickly on the xml-dev list [0], which is where I first saw mention of the interview, and where the
discussion is on the question:

“Is the strong/weak/runtime typing argument over XML any different from
that debate in programming languages.”

There’s also some interesting debate on whether Guido indeed misunderstands, or misstated, the difference between strong and static
typing

James

[0] xml-dev - RE: [xml-dev] Strong versus (weak|runtime) typing

Nope. And it’s pretty awful regarding MIME (to begin with).
After trying to find out whether Ruby ML/MA software is around,
I’m sticking to Sympa/MHonArc in the mean time.

But that’s Perl.

···

On Tue, Feb 25, 2003 at 02:08:03PM +0900, Sam Roberts wrote:

“I use Mailman and qmail, both are implemented in python”
Huh? Since when is qmail implemented in python?


---- WBR, Michael Shigorin mike@altlinux.ru
------ Linux.Kiev http://www.linux.kiev.ua/

> 1. Ruby is strongly-typed, meaning that if an object receives a method > that it cannot respond to, it will generate a type error if the method > belongs to a built-in class, or a method missing error otherwise.

This isn’t strong typing by any definition I’ve heard… ruby isn’t
strongly typed by default. That is, there aren’t places where it
cares about the type (class) of an object, only what it responds to.
There are certain exceptions of course.

> 3. The future of Ruby will de-emphasize the term type and instead look > at whether an object responds to method calls.

I think this de-emphasis already exists. Personally I don’t care for
it, but as long as it doesn’t get any closer to prototype OOP than it
already is, I’ll continue to be happy. :wink:

···

On Thu, 13 Feb 2003 12:10:18 +0900 Mark Wilson mwilson13@cox.net wrote:


Ryan Pavlik rpav@users.sf.net

“I distinctly remember dancing on your grave.” - 8BT

Hi,

  1. Ruby is strongly-typed, meaning that if an object receives a method
    that it cannot respond to, it will generate a type error if the method
    belongs to a built-in class, or a method missing error otherwise.

This isn’t strong typing by any definition I’ve heard… ruby isn’t
strongly typed by default. That is, there aren’t places where it
cares about the type (class) of an object, only what it responds to.
There are certain exceptions of course.

Hmm, by my definition, strong typing means that every data has its own
type, without exception. Weak typing is that type can be mixed and
changed very easily. Dynamic typing is that types of expressions
(including variables) are determined at run time, whereas static
typing is that every expression (and variable) has its type determined
at compile time. Under these definitions:

Ruby: strong dynamic typed language
Java: strong static typed language
AWK: weak dynamic typed language
C: weak(?) static typed language.
Perl: weak part static, part dynamic typed language

						matz.
···

In message “Re: von Rossum on Strong vs. Weak Typing” on 03/02/13, Ryan Pavlik rpav@nwlink.com writes:

Thu, 13 Feb 2003 13:15:42 +0900, Yukihiro Matsumoto matz@ruby-lang.org pisze:

Ruby: strong dynamic typed language
Java: strong static typed language

I would not call Java strongly typed
because you must cast all over the place
(http://www.pragmaticprogrammer.com/cgi-local/pragprog?JavaIsUntyped).

For a stronyly statically typed languages, look at Haskell or OCaml.
There you almost never must escape the type system because they are
more expressive.

···


__("< Marcin Kowalczyk
__/ qrczak@knm.org.pl
^^ http://qrnik.knm.org.pl/~qrczak/

Hmm, by my definition, strong typing means that every data has its own
type, without exception. Weak typing is that type can be mixed and
changed very easily. Dynamic typing is that types of expressions
(including variables) are determined at run time, whereas static
typing is that every expression (and variable) has its type determined
at compile time. Under these definitions:

Ruby: strong dynamic typed language
Java: strong static typed language
AWK: weak dynamic typed language
C: weak(?) static typed language.
^^^^
because of coercions (?)

···

On Thu, Feb 13, 2003 at 01:15:42PM +0900, Yukihiro Matsumoto wrote:

Perl: weak part static, part dynamic typed language


_ _

__ __ | | ___ _ __ ___ __ _ _ __
'_ \ / | __/ __| '_ _ \ / ` | ’ \
) | (| | |
__ \ | | | | | (| | | | |
.__/ _,
|_|/| || ||_,|| |_|
Running Debian GNU/Linux Sid (unstable)
batsman dot geo at yahoo dot com

Stupid nick highlighting
Whenever someone starts with “stupid” it highlights the nick. Hmm.
#Debian

OCaml is a statically typed language with type inferencing. It seems to
be a cross between weak and strong typing.

Paul

···

On Fri, Feb 14, 2003 at 07:27:10PM +0900, Marcin ‘Qrczak’ Kowalczyk wrote:

For a stronyly statically typed languages, look at Haskell or OCaml.
There you almost never must escape the type system because they are
more expressive.

Marcin ‘Qrczak’ Kowalczyk wrote:

Thu, 13 Feb 2003 13:15:42 +0900, Yukihiro Matsumoto matz@ruby-lang.org pisze:

Ruby: strong dynamic typed language
Java: strong static typed language

I would not call Java strongly typed
because you must cast all over the place
(http://www.pragmaticprogrammer.com/cgi-local/pragprog?JavaIsUntyped).

A Java cast is different from a C cast. A Java cast is an assertion,
which the runtime can check and throw a ClassCastException if false. In
C, a cast always succeeds, whether it really makes sense or not.

The “Java Is Untyped” program points more toward dynamic typing than
strong typing.

···


Frank Mitchell
frankm@bayarea.net

Please avoid sending me Word or PowerPoint attachments.
See We Can Put an End to Word Attachments - GNU Project - Free Software Foundation

Hi,

···

In message “Re: von Rossum on Strong vs. Weak Typing” on 03/02/13, Mauricio Fernández batsman.geo@yahoo.com writes:

C: weak(?) static typed language.
^^^^
because of coercions (?)

Because of cast and union.

						matz.

Paul Brannan pbrannan@atdesk.com writes:

···

On Fri, Feb 14, 2003 at 07:27:10PM +0900, Marcin ‘Qrczak’ Kowalczyk wrote:

For a stronyly statically typed languages, look at Haskell or
OCaml. There you almost never must escape the type system because
they are more expressive.

OCaml is a statically typed language with type inferencing. It
seems to be a cross between weak and strong typing.

Type inferencing doesn’t mean the types aren’t fully checked at
compile time. Weak typing implies a bit of run time type checking,
which OCaml doesn’t do.


matt

OCaml is a statically typed language with type inferencing. It seems to
be a cross between weak and strong typing.

The languages like ML/Haskell/OCaml are strongly typed - and that type
is statically checked. Strong/weak doesn’t have anything to do with
paremetric polymorphism (AFAIK). It’s more of a `different’ typing.
Curry vs. Church - see Lambda Calculi w/ Types, by Henk Barendregt.

~Me!

Also because when you get down to it, everything is just a number. :wink:

···

On Fri, 14 Feb 2003 10:07:25 +0900 matz@ruby-lang.org (Yukihiro Matsumoto) wrote:

Hi,

In message “Re: von Rossum on Strong vs. Weak Typing”

C: weak(?) static typed language.
^^^^
because of coercions (?)

Because of cast and union.


Ryan Pavlik rpav@users.sf.net

“Oh for the love of evil, not this again.” - 8BT

C is weakly typed, but it does not do run-time type checking.

Paul

···

On Sat, Feb 15, 2003 at 01:05:19AM +0900, Matt Armstrong wrote:

Type inferencing doesn’t mean the types aren’t fully checked at
compile time. Weak typing implies a bit of run time type checking,
which OCaml doesn’t do.

Sat, 15 Feb 2003 04:18:57 +0900, Paul Brannan pbrannan@atdesk.com pisze:

Type inferencing doesn’t mean the types aren’t fully checked at
compile time. Weak typing implies a bit of run time type checking,
which OCaml doesn’t do.

C is weakly typed, but it does not do run-time type checking.

For me “weakly typed” means that either there is no well-defined
and interesting concept of the type of each object, or it exists but
in practice it too often lies.

The first case applies to C and C++ (where a piece of memory can be
viewed as several types at once - via inheritance or casts or unions
or working with the representation of objects). It also applies
(differently) to languages like Unix shell, Tcl, BCPL, and to some
extent Perl, where the meaning of an object is different depending
on operations used with it.

The second case is a bit more strongly typed and applies to Java, C#
and perhaps other languages with static but inexpressive type systems.
In these langages even if an object has a particular dynamic type,
the static type of a variable used to access it is often different.

In a strongly typed language the question “what is the type of the
given object” has a precise, meaningful answer. In a weakly typed
language the answer is “it depends what do you mean by type” or “it
depends how do you view it” or “it’s a string/word/object/scalar/table,
like everything else”.

Weak typing is fine for simple, domain-specific languages.

Between weakly and strongly typed languages are languages where types
are well-defined but there is only a fixed set of them. So instead
of making your own types you assign new meanings to builtin types.
Erlang is an example.

···


__("< Marcin Kowalczyk
__/ qrczak@knm.org.pl
^^ Blog człowieka poczciwego.

You’re not getting down far enough. It’s all just bits, man! :slight_smile:

···

At 10:22 AM +0900 2/14/03, Ryan Pavlik wrote:

On Fri, 14 Feb 2003 10:07:25 +0900 >matz@ruby-lang.org (Yukihiro Matsumoto) wrote:

Hi,

In message “Re: von Rossum on Strong vs. Weak Typing”

C: weak(?) static typed language.
^^^^
because of coercions (?)

Because of cast and union.

Also because when you get down to it, everything is just a number. :wink:


Dan

--------------------------------------“it’s like this”-------------------
Dan Sugalski even samurai
dan@sidhe.org have teddy bears and even
teddy bears get drunk

I dunno, C lives outside the set of languages that really care about
strong or weak typing. If you really need to find its place in the
dichotomy, it’s a strongly typed language that lets you lie to it.
(That it only really has three types is a separate issue, of
course…)

···

At 4:18 AM +0900 2/15/03, Paul Brannan wrote:

On Sat, Feb 15, 2003 at 01:05:19AM +0900, Matt Armstrong wrote:

Type inferencing doesn’t mean the types aren’t fully checked at
compile time. Weak typing implies a bit of run time type checking,
which OCaml doesn’t do.

C is weakly typed, but it does not do run-time type checking.


Dan

--------------------------------------“it’s like this”-------------------
Dan Sugalski even samurai
dan@sidhe.org have teddy bears and even
teddy bears get drunk