Re: What does TYPE SAFE mean?

"Douglas Lewit [email protected] [ocaml_beginners]" <[email protected]> Sun, 14 Feb 2016 01:08:35 -0600
Newsgroups gmane.comp.lang.ocaml.beginners
Message-ID <CAM0XMJTf552EKhVc56W9FnPANaGuODH+Z4eNQ+DgopRZUGnb7g@mail.gmail.com>
So my guess is that if a language is very "type safe" then most errors
should be caught at compile time and thus there should be very few runtime
errors?  Supposedly the problem with Python, Ruby, Perl, Matlab,
Mathematica, Maple and other dynamic languages is that because of how these
languages are set up there is a greater risk of unexpected runtime errors.
Is that correct?  Or did I just get lost down a rabbit hole?

I really enjoy how Ocaml is used to generate recursive functions that act
on lists.  This of course is not really unique to Ocaml, but working with
Ocaml has really helped me to appreciate the power of recursion.  I'm
guessing that recursion is unavoidable and extremely important in any
functional language, whether it's Ocaml or Scala or Haskell or F# or
anything else.  ( I believe that Wolfram Mathematica contains some
programming constructs that are of a functional nature as well.  Maple and
Matlab however are mostly imperative. )


On Sat, Feb 13, 2016 at 9:15 AM, Hendrik Boom [email protected]
[ocaml_beginners] <[email protected]> wrote:

>
>
> On Sat, Feb 13, 2016 at 01:01:31AM -0600, Douglas Lewit [email protected]
> [ocaml_beginners] wrote:
> > What do people mean when they say that Ocaml is a "type safe" language?
>
> To put it very informally, it means that every variable and expression
> has a type (such as int, or int->int etc.) and that during execution,
> you are guaranteed that the values of these variables and expressions
> are indeed values of the correct types.
>
> The compiler will prevent anything violating these constraints from
> getting through to execution. Though occasionally, as a real-world
> compromise, there will have to be run-time checks. And, occasionally,
> oe must escape to code not written on OCaml, and then the OCaml
> compiler cannot ensure type-correctness.
>
> -- hendrik
> 
>