OT: Ocaml?

Discussion in 'Python' started by Paul Rubin, Aug 23, 2003.

  1. Paul Rubin

    Paul Rubin Guest

    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.
     
    Paul Rubin, Aug 23, 2003
    #1
    1. Advertising

  2. Paul Rubin

    Graham Breed Guest

    Paul Rubin 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.


    Yes, I've been playing with it. It's a good complement to Python in
    that it's statically typed with an efficient compiler. It has an
    interactive interpreter, but there are some cases where it feels lower
    level. Like you can't do introspection to the same extent, and it
    doesn't have the magic string formatting (or rather, it must for the
    interpreter, but I don't know how to get at it).


    Graham
     
    Graham Breed, Aug 23, 2003
    #2
    1. Advertising

  3. Paul Rubin

    Donn Cave Guest

    Quoth Paul Rubin <http://>:
    | Arne Koewing <> writes:
    |>> 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.
    |> Yes and I think it's a great language, but it's a little bit harder
    |> to start learning it. (you must learn how to read the types).
    |> But you get a very 'save' language with a very efficient compiler.
    |
    | Do you find that the strict type system gets in your way like it does
    | in Java?

    I have used ocaml only casually, and Java never, but one thing
    that has worked for me is sort of a functional counterpart of
    OOP, ``partial application.''

    let multiply a b = a * b
    let double = multiply 2

    So supposing I want something like Python's file object.

    let read_file fp sz = ...
    let write_file fp data sz = ...
    let make_file_file fp =
    {
    read = read_file fp;
    write = write_file fp
    }
    let f = make_file_file (open filename) in
    let data = f.read 512
    ...

    let read_buffer buffer sz = ...

    The point being that the type system, though probably stricter
    than Java's, does allow ways to conveniently implement the same
    interface for radically different types, in this case with a
    feature that's just a basic natural part of any functional
    programming language. Maybe Java could do the same?

    Then there is a lot of stuff in Objective CAML's module system
    that directly addresses type issues, and it also has a fairly
    complicated OOP system.

    Donn Cave,
     
    Donn Cave, Aug 24, 2003
    #3
  4. Paul Rubin

    Daniel Yoo Guest

    Paul Rubin <http://> wrote:
    : Arne Koewing <> writes:
    :> > 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.
    :> Yes and I think it's a great language, but it's a little bit harder
    :> to start learning it. (you must learn how to read the types).
    :> But you get a very 'save' language with a very efficient compiler.

    : Do you find that the strict type system gets in your way like it does
    : in Java?


    Actually, not at all! Mark Jason Dominus has written a very nice page
    talking about type systems, and in particular, gushes about the
    ML/Ocaml approach. He shows how the ML type system just gets out of
    the way:

    http://perl.plover.com/yak/typing/

    Very good reading. *grin*


    Hope this helps!
     
    Daniel Yoo, Aug 24, 2003
    #4
  5. Paul Rubin

    Donn Cave Guest

    In article <>,
    Paul Rubin <http://> 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,

    (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.)
     
    Donn Cave, Aug 25, 2003
    #5
  6. Donn Cave <> writes:

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


    That was John Max Skaller, and the code is still on sf:

    http://vyper.sf.net

    If you're really curious and the anon CVS isn't working, I can stick a
    tarball somewhere.

    Cheers,
    mwh

    --
    > The conversion rate from Imperial Shitloads to Metric Shitloads is
    > to multiply by 1.07. Which you multiply is left as an exercise.

    Both.
    -- Bob McCown & Jasper Janssen, asr
     
    Michael Hudson, Aug 26, 2003
    #6
  7. Paul Rubin

    Donn Cave Guest

    In article <>,
    Michael Hudson <> wrote:
    > Donn Cave <> writes:
    >
    > > Incidentally, a few years back someone got fairly far along on
    > > implementing Python (or something like it) from scratch in
    > > Objective CAML.

    >
    > That was John Max Skaller, and the code is still on sf:
    >
    > http://vyper.sf.net
    >
    > If you're really curious and the anon CVS isn't working, I can stick a
    > tarball somewhere.


    No thanks!

    Donn Cave,
     
    Donn Cave, Aug 26, 2003
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Max Powers

    Embedding OCaml within Python

    Max Powers, Apr 28, 2004, in forum: Python
    Replies:
    5
    Views:
    570
    Bruno Desthuilliers
    May 1, 2004
  2. Bryan

    ocaml extension

    Bryan, Jun 16, 2004, in forum: Python
    Replies:
    0
    Views:
    335
    Bryan
    Jun 16, 2004
  3. Jelle Feringa // EZCT / Paris

    OCAMl a more natural extension language for python?

    Jelle Feringa // EZCT / Paris, Jan 17, 2005, in forum: Python
    Replies:
    4
    Views:
    507
  4. Gigs_

    ocaml to python

    Gigs_, Feb 19, 2007, in forum: Python
    Replies:
    2
    Views:
    517
    Laurent Pointal
    Feb 20, 2007
  5. Replies:
    0
    Views:
    500
Loading...

Share This Page