Rich wrote:

>I have no formal programming background - so my experience won't be the case
>with the majority of the people on this list.
>
>I spent 2.5 months reading and re-reading the OCaml OReilly book... and
>finally I 'understood' when you're supposed to use either a semi-colon,
>double semi-colon, or nothing at the end of a line of OCaml code. Once I had
>that breakthrough, I could 'think' OCaml. Ever since then I've been amazed
>at how quick I can write very simple programs. The problem is that I mostly
>write multi-user server apps, and that isn't so 'quick' to do in OCaml -
>Ruby OTOH is ofcourse very quick to write almost anything you want.
>
>Remember - OCaml is based on Lambda Calculus... which I really don't know
>that much about, just that there's only three things in LC... a function
>that accepts one argument, an argument, and the application of that single
>argument to a single function... or somethign like that... SO... thinking in
>OCaml is _nothing_ and i mean _nothing_ like thinking in C, or Java, or
>Ruby, or Perl.
>
>Here's a snippet of code from a 2 user socket server that does polling over
>the connections... (yes, I know, no comments, and should have been expanded
>at ';;'s. Remember - I'm not saying I'm good at this, I just get the job
>done. ;-))
>
>START CODE
>let p=(int_of_string Sys.argv.(2));;let myAddr=(Unix.inet_addr_of_string
>(Sys.argv.(1)));;
>let sockaddr=Unix.ADDR_INET(myAddr, p);;let sock=(Unix.socket Unix.PF_INET
>Unix.SOCK_STREAM 0);;
>Unix.bind sock sockaddr;;Unix.listen sock 2;;
>let (s,scaller)=Unix.accept sock;;let sOut=Unix.out_channel_of_descr s;;let
>sIn=Unix.in_channel_of_descr s;;
>let (t,scaller)=Unix.accept sock;;let tOut=Unix.out_channel_of_descr t;;let
>tIn=Unix.in_channel_of_descr t;;
>output_string sOut "Connected\000";;flush sOut;;output_string tOut
>"Connected\000";;flush tOut;;
>let this=ref ([s;s],[s;s],[s;s]);;
>let sH=ref (String.create 1024);;let tH=ref (String.create 1024);;
>sH:="";;tH:="";;
>let sF=ref 0;;let tF=ref 0;;
>let rS m= (if((!tF)=0) then (tH:=input_line sIn;tF:=1;print_string
>"|s|";flush stdout));;
>let rT m= (if((!sF)=0) then (sH:=input_line tIn;sF:=1;print_string
>"|t|";flush stdout));;
>let wS m=if((!sF)=1) then (output_string sOut (!sH ^ "\000");flush
>sOut;sH:="";sF:=0;print_string "-s-";flush stdout);;
>let wT m=if((!tF)=1) then (output_string tOut (!tH ^ "\000");flush
>tOut;tH:="";tF:=0;print_string "-t-";flush stdout);;
>while true do
> try (
>  print_string ".";
>  flush stdout;
>  this:=Unix.select [s;t] [s;t] [s;t] (-.1.0);
>  match !this with _,_,[w] -> (print_endline "error";exit 0)
>   | [w],[],_ -> (if(w=s) then (rS w) else (rT w))
>   | [],[w],_ -> (if(w=s) then (wS w) else (wT w))
>   | [w],[x],_ -> (if(w=s) then (rS w) else (rT w);if(x=s) then (wS x) else
>(wT x);)
>   | [w;x],[],_ -> (if(w=s) then (rS w;rT x) else (rT w;rS x))
>   | [],[w;x],_ -> (if(w=s) then (wS w;wT x) else (wT w;wS x))
>   | [w],[x;y],_ -> (if(w=s) then (rS w) else (rT w);if(x=s) then (wS x;wT
>y) else (wT x;wS y))
>   | [w;x],[y],_ -> (if(w=s) then (rS w;rT x) else (rT w;rS x);if(y=s) then
>(wS y) else (wT y))
>   | [w;x],[y;z],_ -> (if(w=s) then (rS w;rT x) else (rT w;rS x);if(y=s)
>then (wS y;wT z) else (wT y;wS z))
>   | _,_,_ -> ()
> ) with End_of_file -> (print_endline "exiting";exit 0)
>done;;
>END CODE
>
>OCaml native code is ~better~ than C - see the language shootout to
>understand what I mean.
>
>OCaml bytecode has all the benefits of Java - plus none of the failings
>(development time is shorter by far - my OCaml skill compared to my
>comparably skilled Java oriented brother).
>
>OCaml toplevel is just like IRB, there are some quirks, but it's great for
>testing a quick snippet of code before you end up using it.
>
>OCaml is wonderfully easy to compile to a 'native' exe (I had to distribute
>the cygwin.dll with it) or 'close-to-crossplatform' bytecode (I think some
>libraries didn't exist for certain platforms, but my memory is hazy on that
>point), and super easy to run in a toplevel interpreter.
>
>The bad points - exactly the same as Ruby. Next to no corporate backing
>(think Sun's marketing pocketbook), next to no 'real-world' uses even though
>they also have a 'these-are-the-real-world-uses' page just like Ruby.
>
>There is one drawback that hurt me alot - and it might have just been me...
>I was very offended by the nuby mailing list responses I recieved... that
>list is not for nubies. You've been warned. :-)
>
>That's my simple opinion.
>
>When people ask what languages I like most, I say Ruby first, OCaml a very
>close second - and no... I really have no clue how to write C or Java... and
>I really don't ever want to learn ;-).
>  
>

I love Ruby, but in defence of C++ I have to say the there is nothing 
quite like the C++ template feature.  Metaprogramming is really 
interesting.  Doing factorial at no run-time cost (all at compile time), 
compile time parser generators, and such.  I'm currently working on a 
template lib that allows the end user to create/genterate Alife 
simulators (with behavior and rules they define) with one (mammoth) 
typedef.

Michael