caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: skaller <skaller@users.sourceforge.net>
To: Christophe Raffalli <Christophe.Raffalli@univ-savoie.fr>
Cc: kirillkh <kirillkh@gmail.com>, oleg@pobox.com, caml-list@inria.fr
Subject: Unsoundness is essential
Date: Thu, 04 Oct 2007 08:50:10 +1000	[thread overview]
Message-ID: <1191451810.7218.86.camel@rosella.wigram> (raw)
In-Reply-To: <4703FDEF.7030900@univ-savoie.fr>

On Wed, 2007-10-03 at 22:39 +0200, Christophe Raffalli wrote:

> So the story is by saying (wrongly) that it is too heavy to anottate
> arrow types with exceptions,
> making the arrow type a ternary type construct, ML is missing a lot ...

To be bold I propose type theorists have got it totally wrong.

Goedel's theorem says that any type system strong enough to
describe integer programming is necessarily unsound.

All advanced programming languages have unsound type systems
of necessity. Some falsely claim soundness by denying the
expression of certain type information (eg array bounds 
or the type of integers excluding zero).

I want an unsound type system! It much better than the useless
but 'sound' type system of Python, in which the type inference
engine decides all values have type Object and proves
in vacuuo that all programs are type-safe, only to do the 
dependent type checks at run time anyhow -- a cheat known
as dynamic typing.

It is better to admit from the start that type systems
can and MUST be unsound, and allow programmers to write
known correct programs with expressive typing which no type 
system could type check, than to turn programmers off by 
rejecting their valid code.

The cost is some invalid code will be accepted, but there
is no help for it: the type system has to be unsound
or it is of no practical use at all (Ok, I exaggerate,
predicate calculus is complete and useful .. algebraic
typing is the equivalent).

In particular, the ability to write proper type annotations
such as

	divide: int * (int - {0}) -> int

and fail to reject programs which violate the typing is an
essential and useful feature. Later, some programs may
be properly rejected early instead of late when some
smart type theorist extends the capabilities of the compiler,
or the programmer learns how to re-express the typing so
the existing algorithms catch more faults.

Languages like Ocaml make significant advances in type checking
capability, but users and theorists incorrectly laugh at the weak
and unsound type system of C. In fact, the idea of C is the right
one. We know the type system is unsound. It is essential. It is the
very reason C lives on. Newer compilers have better error detection,
in the meantime C doesn't stop you writing your code. C does this
right: you can use a cast to override the type checks OR you can
simply exploit the unsoundness directly. The latter is preferable
because later versions of the compiler may be smart enough to
catch real errors which the casts would always defeat.

It's time to turn type theory on its head. Forget about whether
the typing is sound, give me EXPRESSION first and worry about
checking second. Accept Goedel: the unsoundness is *essential*
and thus must not be an excuse for failure to express. Let me
write:

	divide: int * (int - {0}) -> int

and I may catch a bug using the human brain, or later
the compiler may be improved and catch more bugs automatically.
The fact it will never catch all these bugs is irrelevant 
because unsoundness is an essential requirement of 
expressive type systems. Stop CHEATING by refusing to allow
me to write types you can't check -- because this forces
ME as the programmer to cheat on the type annotations:

	divide: int * int -> int
	hd : 'a list -> 'a



-- 
John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net


  reply	other threads:[~2007-10-03 22:50 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-03  8:35 Locally-polymorphic exceptions [was: folding over a file] oleg
2007-10-03 11:27 ` kirillkh
2007-10-03 11:48   ` [Caml-list] " Daniel de Rauglaudre
2007-10-03 12:19     ` kirillkh
2007-10-03 12:32       ` Daniel de Rauglaudre
2007-10-03 14:34         ` kirillkh
2007-10-03 20:39   ` Christophe Raffalli
2007-10-03 22:50     ` skaller [this message]
2007-10-03 23:13       ` [Caml-list] Unsoundness is essential Jacques Carette
2007-10-04  1:24         ` skaller
2007-10-04 11:26           ` David Allsopp
2007-10-04 12:45             ` Vincent Hanquez
2007-10-04 15:07               ` skaller
2007-10-03 23:13       ` Vincent Aravantinos
2007-10-04  1:49         ` skaller
2007-10-03 23:28       ` Joshua D. Guttman
2007-10-04  1:52         ` skaller
2007-10-04  2:35           ` Brian Hurt
2007-10-04  7:46           ` Christophe Raffalli
2007-10-04  8:56             ` Arnaud Spiwack
2007-10-04 14:49               ` skaller
2007-10-04 15:00                 ` Harrison, John R
2007-10-04 15:29                 ` Andrej Bauer
2007-10-04 16:25                   ` skaller
2007-10-04 18:17                     ` Arnaud Spiwack
2007-10-04 20:54                       ` skaller
2007-10-04 22:24                         ` Arnaud Spiwack
2007-10-04 16:37                   ` skaller
2007-10-04 18:59                     ` Christophe Raffalli
2007-10-04 15:04               ` Andrej Bauer
2007-10-04 15:57                 ` Christophe Raffalli
2007-10-04 16:03                 ` skaller
2007-10-04 20:02                   ` Ken Rose
2007-10-04 21:00                     ` skaller
2007-10-04 15:31       ` Lukasz Stafiniak
2007-10-04 17:56       ` rossberg
2007-10-04 19:56         ` skaller
2007-10-04 21:07           ` rossberg
2007-10-04 22:23             ` skaller
2007-10-05  2:48               ` Bárður Árantsson
2007-10-04  2:16   ` Locally-polymorphic exceptions [was: folding over a file] oleg

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=1191451810.7218.86.camel@rosella.wigram \
    --to=skaller@users.sourceforge.net \
    --cc=Christophe.Raffalli@univ-savoie.fr \
    --cc=caml-list@inria.fr \
    --cc=kirillkh@gmail.com \
    --cc=oleg@pobox.com \
    /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).