Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Need advice for a mobile application server
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: skaller <skaller@o...>
Subject: Re: [Caml-list] Need advice for a mobile application server
On Thu, 2003-11-20 at 05:03, Eray Ozkural wrote:
> Hello there,
> 
> I am looking to consider ocaml for writing a multi-threaded application server 
> which involves data structures of medium complexity (to be specific geometric 
> structures). Do you think ocaml is a good bet for this purpose, or should I 
> stick with C++? (in which I know how to write SMP code :)
> 
> Will it be easy and efficient for me to implement imperative data structures 
> which should be locked on update ops, but will not need such on queries (yes, 
> I know it sounds naughty but it should be possible)? Or are there well known 
> obstacles to performing such feats using our beloved ocaml?

Executive Summary [for lazy reader ..]: Use Ocaml.

I have written some multi-threaded client/server and peer2peer
Caml code for simulating a telephone network. For this purpose
I used module Event which is very good (once you get
the hang of it ..)

To create servers I modified the source code
of the Ocaml client/server function Unix.establish_server.
This function creates processes rather than threads,
and so I had to adapt it to threads which is quite easy.

My code was all native code using Posix threads,
it ran on both Linux and Solaris BUT be warned
that at least at that time (several years ago now)
Linux cannot create threads, only processes,
and consequently all threads are detached.
In the case of an error, the main thread can die
but the other threads can keep running ..
[this doesn't happen on Solaris and violates Posix,
I don't know whether this is fixed yet in Linux ..
in any case it has nothing to do with the choice
of Ocaml ..]

As usual I think Ocaml is superior *especially*
for complex tasks where abstractions with strong
guarrantees are highly desirable for reasoning
about software.

The only caveat I know of is that Ocaml
sometimes uses global locks (the gc can't
run concurrently with allocations etc)
and if you create C bindings for Ocaml you
have to be careful to make sure you manage
the exclusion correctly or you might end 
up with a deadlock.


-------------------
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