OT: Ocaml?

Donn Cave donn at u.washington.edu
Mon Aug 25 13:25:42 EDT 2003


In article <7xk795xde6.fsf_-_ at ruckus.brouhaha.com>,
 Paul Rubin <http://phr.cx@NOSPAM.invalid> wrote:

> Anyone here use OCAML?  How do you like it?  Is it a language a
> Pythonista can learn to love?  From what little I've seen, it looks
> interesting, but I haven't actually tried installing or using it yet.

I think typically, people who like Python tend to say they
like Haskell more often than Objective CAML.  Haskell is
more similar in one very superficial respect - its layout
notation is like Python's indented notation - but it's
basically much farther from Python in terms of fundamental
notions about programming.  So it's different in interesting
ways.  Haskell is pretty, on a couple of different levels.
Ocaml is by comparison efficient, portable, fast, predictable,
but I have to say Objective CAML is one of the ugliest languages
I ever saw - regrettable syntax, baroque core language, awkward
support for basic data types like strings and numbers.  (So for
me it's worth making a distinction between ocaml, which I think
is brilliant, and Objective CAML the sorry language it implements.)

Incidentally, a few years back someone got fairly far along on
implementing Python (or something like it) from scratch in
Objective CAML.

   Donn Cave, donn at u.washington.edu

(What about that syntax complaint - just my inflexible esthetic
 taste, maybe?  Consider this, you decide:

    let jump d v = begin
         match d with
           UP -> begin
               output_string stdout "Jump up\n";
               match v with
                 0 -> nonjump ()
               | _ -> jumpup v
             end
         | DOWN -> begin
               output_string stdout "Jump down\n";
               match v with
                 0 -> nonjump ()
               | _ -> jumpdown v
             end;
         output_string stdout "done jumping\n"
       end
    ;;
    jump UP 3

Would you expect "done jumping"?  Objective CAML's syntax for
a procedural block is expressions separated by ";", optionally
enclosed in "begin"/"end" or parentheses.  The DOWN branch
starts with a begin/end block, but it's utterly ambiguous
whether the semicolon that follows that block starts a new
expression in the DOWN branch, or in the function block.
The compiler actually does the former.  Because begin/end is
optional for blocks, in practice you have to put it around
single expressions like match UP/DOWN here, and that's annoying
and counter-intuitive.)




More information about the Python-list mailing list