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: Jon Harrop <jon@f...>
Subject: Re: [Caml-list] Scripting in ocaml
On Thursday 21 December 2006 14:59, Serge Aleynikov wrote:
> OCaml has static typing but doesn't provide an actual location of code
> in exceptions.  Is it because it was hard or intentional?

F# uses .NET exceptions. They do provide such information but they are so slow 
that you must painstakingly avoid any use of exceptions in performance 
critical code, boxing and unrolling manually if necessary. This is in stark 
contrast to OCaml's lightning fast exceptions that are used as the basis of 
optimisations.

> > I guess the arguments for static typing and scalability are
> > well known. So the reasoning part is clear: we infer larger
> > programs without dynamic typing are harder to get right.
>
> I agree with your statements applicable to imperative/OO dynamicly typed
> languages.  However if a dynamic language is functional, this makes it
> possible to provide run-time static analysis to identify type related
> bugs and unreachable code.  An example of this is the Dyalizer tool for
> Erlang.

What do you mean by "run-time static analysis"? Surely if something is 
analysed at run-time then it cannot be static by definition?

> In this case running such a tool after compilation reveals the same
> problems that a compile-level static checker would do, but allows for
> run-time code reloading, more safe term serialization/deserialization,
> and safer cross-language integration.  Needless to say, this benefits
> comes at price of efficiency, but there are many cases when these
> features out-weight a reasonable performance loss that can be regained
> by parallelizing computations.

Then it might be worthwhile for F#, which supports concurrency.

> > Sorry, I wasn't clear. I meant to refer to dynamic loading in Ocaml,
> > not in general. Exactly why that is I don't know. Perhaps the
> > interaction of the static typing and dynamic loading is not
> > easy because it is not well understood how to make it so,
> > in Ocaml, and perhaps in general (without losing type safety)
>
> I believe that introducing strict typing in the language might help in
> bridging static typing and dynamic loading.  Strict typing would allow
> to do run-time type verification and type-specific guard checks.
> Though, this would no longer be Ocaml as we know it today.  ;-)

You could add run-time type information to OCaml and check it at boundaries, 
like marshalling. However, you'd want to optimise it away whenever possible, 
if not for performance reasons then to conserve memory.

-- 
Dr Jon D Harrop, Flying Frog Consultancy Ltd.
Objective CAML for Scientists
http://www.ffconsultancy.com/products/ocaml_for_scientists