From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.1 required=5.0 tests=AWL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id AEABFBBC4 for ; Wed, 4 Mar 2009 01:12:04 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApECAKdVrUnYi40JmWdsb2JhbACBTpM6AQEBAQEICwoHEcIChAgG X-IronPort-AV: E=Sophos;i="4.38,297,1233529200"; d="scan'208";a="22004514" Received: from mail-out9.nyct.net (HELO mail.nyct.net) ([216.139.141.9]) by mail2-smtp-roc.national.inria.fr with ESMTP; 04 Mar 2009 01:12:03 +0100 Received: from beast.local (pool-96-250-132-59.nycmny.east.verizon.net [96.250.132.59]) (authenticated bits=0) by mail.nyct.net (8.14.2/8.14.1) with ESMTP id n240BwpZ037525 (version=TLSv1/SSLv3 cipher=DHE-DSS-AES256-SHA bits=256 verify=NO); Tue, 3 Mar 2009 19:12:00 -0500 (EST) (envelope-from bhurt@spnz.org) Date: Tue, 3 Mar 2009 19:11:32 -0500 (EST) From: Brian Hurt X-X-Sender: bhurt@beast To: Jon Harrop Cc: caml-list@yquem.inria.fr Subject: Re: [Caml-list] stl? In-Reply-To: <200903032342.39527.jon@ffconsultancy.com> Message-ID: References: <91a2ba3e0903031340wcdc976cp52522eb35f7ccb73@mail.gmail.com> <200903032342.39527.jon@ffconsultancy.com> User-Agent: Alpine 2.00 (DEB 1167 2008-08-23) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Spam: no; 0.00; stl:01 functors:01 ocaml:01 functors:01 ocaml:01 haskell:01 inlining:01 haskell:01 abstraction:01 functor:01 overloading:01 functor:01 ord:01 wrote:01 caml-list:01 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