caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Chad Perrin <perrin@apotheon.com>
To: skaller <skaller@users.sourceforge.net>
Cc: Chad Perrin <perrin@apotheon.com>, caml-list@yquem.inria.fr
Subject: Re: strong/weak typing terminology (was Re: [Caml-list]	Scripting in ocaml)
Date: Fri, 22 Dec 2006 21:11:22 -0700	[thread overview]
Message-ID: <20061223041121.GA31700@apotheon.com> (raw)
In-Reply-To: <1166845703.7448.172.camel@rosella.wigram>

On Sat, Dec 23, 2006 at 02:48:23PM +1100, skaller wrote:
> On Fri, 2006-12-22 at 13:17 -0700, Chad Perrin wrote:
> 
> > This all seems rather simple to me:
> > 
> > It's type-safe if you cannot get type errors without subverting the type
> > system.
> 
> You are missing something. There's no such thing as a 'type error'
> at run time in a statically typed language. At run time object values
> are just bit strings, they don't HAVE any types -- and even that
> is an abstraction (really you just have registers and machine
> code .. not even really bit strings).

That's not quite true.  A "type error" is what happens when an operation
is performed on a value of a type different from the operation's type.
For instance, integer addition on a float or string, or concatenation on
an integer or float, is a type error in most languages.  Statically
typed languages are commonly thought to avoid such type errors at
runtime almost tautologically, but play with casts and pointers in some
dangerous ways in C/C++ and you may quickly learn that is not the case.


> 
> Python has a static type system. Did you know? Everything has
> type 'object'.

That's a pretty weird interpretation of the Python type system -- and
it's categorically false, because there are many things in Python that
are not objects.  You might be able to make such a claim for Ruby, even
though I would consider even that to be a dubious claim due to the other
type-related behavior of the language.  In fact, objects have types.
That's sorta the point of objects, from a certain perspective: defining
types to extend your type system in a manner that makes it possible to
achieve certain benefits in coding such as reusability and modularity.


> 
> So in fact Python is quite type safe, and statically so.
> Big deal. The type system isn't expressive enough for that
> to mean anything!
> 
> Similarly, Ocaml is NOT type safe because array bounds can
> be violated at run time. This is because the type system
> is not expressive enough to capture the array bound as
> part of the type.

I don't know OCaml quite well enough to say this with authority, but at
a guess I'd say that's not a type error.  It's an error, but not a type
error, because it does not involve applying an operation to a value of a
given type (or similarly mismatch types).  It's more akin to a buffer
overrun than a type error.

Also, this directly contradicts your own earlier definition of "type
safety", because OCaml is pretty clearly a statically typed language.


> 
> So saying a language is type-safe is meaningless unless
> you also say how expressive the type system is: either
> way the program isn't safe, and the choice of typing is
> often dictated by what can be statically checked, rather
> than what NEEDS to be checked. So 'type safe' is a fairly
> vague concept in this sense.
> 
> It really comes down to "I think Ocaml is a better programming
> language for my purpose than C++".

So much for language theory.  I guess it's all balderdash, then.

By the way, I wrote a longish email (I didn't think it was *THAT* long,
but apparently it was) earlier today that never made it through to the
list.  I can only guess that it must be in moderation because of its
length.  It gets into some depth on the subject of defining type system
characteristics, and might be worth a read if it ever appears.

-- 
CCD CopyWrite Chad Perrin [ http://ccd.apotheon.org ]
"A script is what you give the actors.  A program
is what you give the audience." - Larry Wall


  reply	other threads:[~2006-12-23  4:11 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-12-21  3:41 Scripting in ocaml Denis Bueno
2006-12-21  4:34 ` [Caml-list] " Erik de Castro Lopo
2006-12-21  7:22   ` skaller
2006-12-21  9:12     ` Till Varoquaux
2006-12-21  9:18     ` Chad Perrin
2006-12-21 10:29       ` skaller
2006-12-21 20:21         ` Chad Perrin
2006-12-21 13:30     ` Serge Aleynikov
2006-12-21 13:52       ` skaller
2006-12-21 14:59         ` Serge Aleynikov
2006-12-21 20:25           ` Chad Perrin
2006-12-21 20:41             ` Daniel Bünzli
2006-12-21 22:16               ` Chad Perrin
2006-12-22 12:21                 ` strong/weak typing terminology (was Re: [Caml-list] Scripting in ocaml) Daniel Bünzli
2006-12-22 16:51                   ` Tom
2006-12-22 17:34                     ` Daniel Bünzli
2006-12-22 18:16                     ` skaller
2006-12-22 18:47                       ` Daniel Bünzli
2006-12-22 19:42                         ` skaller
2006-12-22 20:03                           ` David Brown
2006-12-22 20:17                             ` Chad Perrin
2006-12-23  3:48                               ` skaller
2006-12-23  4:11                                 ` Chad Perrin [this message]
2006-12-22 20:19                           ` Chad Perrin
2006-12-23 12:58                           ` Daniel Bünzli
2006-12-23 16:06                             ` Chad Perrin
2006-12-23 21:50                               ` Tom
2006-12-26  6:10                                 ` Chad Perrin
2006-12-22 20:14                   ` Chad Perrin
2006-12-21 21:11             ` [Caml-list] Scripting in ocaml Serge Aleynikov
2006-12-21 21:27               ` Philippe Wang
2006-12-21 22:06                 ` Serge Aleynikov
2006-12-22 12:35                 ` Jon Harrop
2006-12-21 22:19               ` Chad Perrin
2006-12-22 12:37                 ` Jon Harrop
2006-12-22 18:52                   ` Chad Perrin
2006-12-22  2:51               ` skaller
2006-12-22 15:20                 ` Jon Harrop
2006-12-22 11:32               ` Jon Harrop
2006-12-23 18:50           ` Jon Harrop
2006-12-24  0:15             ` Serge Aleynikov
2006-12-24  3:30             ` skaller
2006-12-21 14:59 ` Richard Jones
2006-12-21 20:27   ` Chad Perrin
2006-12-21 23:35   ` Martin Jambon
2006-12-26 17:14 ` Aleksey Nogin
2006-12-26 23:36   ` Ian Zimmerman
2006-12-27 18:25     ` Aleksey Nogin
2006-12-27 18:39       ` Richard Jones
2006-12-27 19:20         ` Aleksey Nogin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20061223041121.GA31700@apotheon.com \
    --to=perrin@apotheon.com \
    --cc=caml-list@yquem.inria.fr \
    --cc=skaller@users.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).