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: Chad Perrin <perrin@a...>
Subject: Re: [Caml-list] Scripting in ocaml
On Thu, Dec 21, 2006 at 09:29:15PM +1100, skaller wrote:
> On Thu, 2006-12-21 at 02:18 -0700, Chad Perrin wrote:
> > On Thu, Dec 21, 2006 at 06:22:36PM +1100, skaller wrote:
>  
> > > The big problem using Ocaml (bytecode) for scripting
> > > is probably the ugly dynamic loading support, and 
> > > for long running systems, the lack of unloading support.
> > > (plus the syntax which isn't really well suited to small
> > > scale scripting applications).
> > 
> > Actually, I find that static typing is the biggest problem I have with
> > administration script writing in OCaml.  It can be great for bigger
> > projects where dynamic typing doesn't always scale (as you mentioned),
> > but for something under thirty lines of code (to pick a number out of
> > thin air) the syntax requirements imposed by static typing and the
> > semantic gymnastics that must sometimes be done (string_of_int, et
> > cetera) can get in the way a bit.
> 
> If you examine your
> scripting code I'm going to bet you find that most variables
> actually have a single statically known type!

Actually, I typically don't even use variables in small OCaml scripts.
I occasionally use "let n =", but don't find need to do the reference
thing very often when the body of code is kept small.

The most common problem I have with static typing getting in the way is
having to decide on either multiple print statements or constructing a
string from several different data types to use a single print
statement.  Where something like that takes one short line of code in
the dynamically typed languages I'm used to using, it can be half my
code when doing something similar in an OCaml script.

Plus, y'know, list handling is easier for me in Perl or UCBLogo, with
the former providing better general purpose text processing capability
and the latter having an attractive prefix notation functional syntax
(among other benefits).  Neither compiles to persistent executable
native binaries, though, which (combined with its high level syntax and
several other means of running OCaml code) is really my main reason for
liking OCaml.

-- 
CCD CopyWrite Chad Perrin [ http://ccd.apotheon.org ]
print substr("Just another Perl hacker", 0, -2);