Version française
Home     About     Download     Resources     Contact us    
Browse thread
Scripting in ocaml
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: skaller <skaller@u...>
Subject: Re: strong/weak typing terminology (was Re: [Caml-list] Scripting in ocaml)
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).

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

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.

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++". 

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