On Wed, Aug 16, 2006 at 03:27:20PM +0000, Tuomo Valkonen wrote: > On 2006-08-16, Joerg van den Hoff <[EMAIL PROTECTED]> wrote: > > I followed the thread concerning gcc, ld, C and their shortcomings: I > > recently stumbled over OCaml as a fast, compiled language which seems > > not so strictly/exclusively functional as Haskell. any opinions > > concerning that language? > > Well, I'm not very familiar with it (never having written anything > in *ML), but not being pure loses some sexyness points wrt. Haskell > (and Clean, which is too poorly supported, however). Despite this, > from what little I've seen, the OO support is quite ugly, as is all > the impure stuff. For IO, Haskell's IO Monad and the uniqueness types > of Clean are much nicer and more theoretically sound. Clean's uniqueness > types seem... cleaner... than monads for mutable data in particular, but > monads, on the other hand, are a much more general recipe for various > domain-specific languages (the parsec parser combinator library is a > great example), as one I like to view the IO monad. OCaml seems to have > rather good performance, though, close to that of C in many benchmarks. > It might, infact, be the best alternative for C, but it's not a very > sexy language, compromising functional purity for imperative features, > that are not very neatly done either. At least that's my impression; > as I said, I'm not very familiar with it.
I've written a couple of sizeable OCaml projects. I think your impressions are largely on target: it's a very practical language, but probably not the sexiest one out there. The OO support is not terribly pretty, but I wouldn't hold this against the language; rather than using objects, it seems that most OCaml coders prefer to work with the powerful module system that offers similar capabilities with a more ML-ish flavor. Looking at things from a purely pragmatic viewpoint, the availability of imperative features is a big win. There are many algorithms that are most clearly expressed in a simple loop, and IO is very straightforward. Also, if you really need good performance from a critical chunk of code, switching to imperative operations on mutable data structures can get you there rather quickly (the OCaml code on the Programming Language Shootout is rather embarrassingly imperative, for this reason). My verdict: a very good general purpose language. Paul
