Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Q: safe language
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Nicolas Cannasse <warplayer@f...>
Subject: Re: [Caml-list] Q: safe language
> I heard Ocaml is "safe" language.
>
> Some questions about "safe" language:
> - Is it necessary for a safe language to have a type system?
> - Isn't Lisp a safe language?

Depends what you're calling "safe"...

Any language having garbage collection prevents the user from having "access
violations" errors ( such as in C :  (*NULL)++ ). Then, other errors will
always be detected either at run-time ( with often an exception mechanism )
or at compile time.

Lisp is a dynamicly typed language, so will perform all type checks at
run-time, resulting a very simple way of writing things but most of the (not
syntax) errors will be detected by the user at run-time. This kind of
language require rought testing of the programs from the user ( keep in mind
that a runtime error is taking at least 10 more time to find/fix than a
compile-time one )

Then comes strongly types languages. Theses need "types" and will only
accept compiling programs where functions are applied to the good typed
parameters. Perhaps more work is needed by the programmer, but most of Lisp
run-time errors are now detected at compile-time, resulting a "more safe"
binary.

OCaml is far better than that, but it does "type inference" for you. That
is, it automaticly deduce variables & functions types from the context in
which they are used. So you can write programs with almost the same freedom
as Lisp ( without type anotations ) but with a compile-time errors-detection
:-)

Nicolas Cannasse

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners