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: Daniel_Bünzli <daniel.buenzli@e...>
Subject: strong/weak typing terminology (was Re: [Caml-list] Scripting in ocaml)

Le 21 déc. 06 à 23:16, Chad Perrin a écrit :

> I mean that it doesn't allow you to go around doing in-place type
> changes willy-nilly the way something like C does.

(Well in fact you can with Obj.magic, but that's not my point)

The problem is that this weak/strong terminology is hopelessly  
confused (see [1],[2]). Since there is no clear unique definition of  
strong/weak typing I think this terminology should be avoided. I tend  
to favour the definitions you can find in the introduction of this  
book [3] which are imho less confusing.

Basically the author distinguishes on one hand between statically and  
dynamically typed languages, and on the other hand, between safe and  
unsafe languages.

Static and dynamic type checking refers to whether type checks are  
respectively performed at compilation or run time.

Safety is broadly defined as follows :

"A safe language is one that protects its own abstractions. Every  
high-level language provides abstractions of machine services. Safety  
refers to the language's ability to guarantee the integrity of these  
abstractions and of higher-level abstractions introduced by the  
programmer using the definitional facilities of the language"

Later he gives the following chart

        |Statically checked       | Dynamically checked
-------------------------------------------------
safe   | ML, Haskell, Java, etc. | Lisp, Scheme, Perl, Postscript, etc
unsafe | C, C++, etc.            |

Subsequently he adds :

"Language safety is seldom absolute. Safe languages often offer  
programmers "escape hatches", such as foreign function calls to code  
written in other, possibly unsafe, languages. Indeed such escape  
hataches are sometimes provided in a controlled from within the  
language itself--Obj.magic in Ocaml, ... "

These are just definitions. But it is hard to argue when words do not  
have a common meaning between arguers. I just think these definitions  
make it simpler to have a common understanding of what we are talking  
about.

Best,

Daniel

[1] <http://en.wikipedia.org/wiki/Strong_typing>
[2] <http://www.artima.com/intv/strongweak.html>
[3] <http://www.cis.upenn.edu/~bcpierce/tapl/>