![]() |
OT: Ocaml?
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. |
Re: OT: Ocaml?
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 |
Re: OT: Ocaml?
Quoth Paul Rubin <http://phr.cx@NOSPAM.invalid>:
| Arne Koewing <ark@gmx.net> 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@drizzle.com |
Re: OT: Ocaml?
Paul Rubin <http://phr.cx@nospam.invalid> wrote:
: Arne Koewing <ark@gmx.net> 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! |
Re: OT: Ocaml?
In article <7xk795xde6.fsf_-_@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@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.) |
Re: OT: Ocaml?
Donn Cave <donn@u.washington.edu> 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 |
Re: OT: Ocaml?
In article <7h3wud0zihr.fsf@pc150.maths.bris.ac.uk>,
Michael Hudson <mwh@python.net> wrote: > Donn Cave <donn@u.washington.edu> 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@u.washington.edu |
| All times are GMT. The time now is 04:38 AM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.