Browse thread
stl?
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Brian Hurt <bhurt@s...> |
| Subject: | Re: [Caml-list] stl? |
On Tue, 3 Mar 2009, Jon Harrop wrote: > Functors give > you the same capability in OCaml but they are rarely used precisely because > the functionality is not very useful. I think I disagree with this. I think functors aren't used very much in Ocaml because: 1) They're a big, scary name, and 2) They're slightly less efficient. The biggest difference between Haskell and Ocaml that I see is simply the difference between attitudes of the two communities. The Ocaml community is like "Don't use functors- they disable inlining and cost you six whole clock cycles on a function call! They're evil, I tell you!" Meanwhile, the Haskell community is like "I used typeclasses all over my application, and the performance didn't completely suck- woot! Type classes rule!" This is a broad generalization, and not completely accurate- but on the whole, the ocaml community is much more focused on (clock cycle) efficiency, while the Haskell community is much more focused on abstraction and programmer-cycle efficiency. The type classes comparison isn't even an analogy- it's a precise relationship. Anywhere you might be thinking, in Ocaml, "this would be a nice place to use a type class", use a functor. You want operator overloading in Ocaml? You got it: use a functor. If this causes you a knee jerk reaction about performance, ask yourself this: do you know how type classes are implemented in Haskell, and what their performance hit there is? Now, imagine programming haskell where typeclasses are only used in a very places- Ord, Eq, Monad. No Num. No Monoid. No Show. That's Ocaml. Not that it has to be. Having actually used Haskell for a while, I think I actually like functors better than type classes. But that's a rant for a different venue. The big difference is that Haskell programmers use type classes, and the Ocaml programmers don't use Functors (very often, if at all). Brian