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=1.9 required=5.0 tests=AWL,DNS_FROM_RFC_POST, SPF_NEUTRAL autolearn=disabled version=3.1.3 Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id AD28ABB84 for ; Fri, 15 Aug 2008 04:09:32 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AnABAN+BpEhA6ba4lGdsb2JhbACRQj4BAQEBCQMKBxEDnCiGdwEC X-IronPort-AV: E=Sophos;i="4.32,212,1217800800"; d="scan'208";a="16006592" Received: from nf-out-0910.google.com ([64.233.182.184]) by mail3-smtp-sop.national.inria.fr with ESMTP; 15 Aug 2008 04:09:32 +0200 Received: by nf-out-0910.google.com with SMTP id b11so463827nfh.13 for ; Thu, 14 Aug 2008 19:09:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:cc:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references; bh=UoQ2H1Sef3WNn/gGxOGE+sEmra6knFGngbfsBpvvRcM=; b=J7U0CSjB6BmgRbdtlNuXn0PYJur000NzaPjgFIdgW1xI9yyCkFsA4e6Svp+xCPjTSv +QNBrQJ1wb4v888X0gBBCFZvecvBOx0ogzUDMbRNjAdDMrVlQBz9jtAA6ZIaaTM5h6io MMR/CnOCiRwAFSXimhK8Du/WT9q/NLCHxoUSY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references; b=QWXJkxcuJLrmusj4NeWv9cEj6N0ifs6L2ztAkUu0RI0oM6yjFEDHlOOLNGT+MG4iP1 waoos8zg3TlwEFiXjZD8tZ7vhAN83RYG8RniQd48abMVnTnDDwW/ieVlyoUcV5q94oIn jz3DgQI8USyRFBxSR5VoxyBHrKnT4hoF0kvyM= Received: by 10.210.43.10 with SMTP id q10mr2313896ebq.161.1218766171696; Thu, 14 Aug 2008 19:09:31 -0700 (PDT) Received: by 10.210.72.8 with HTTP; Thu, 14 Aug 2008 19:09:31 -0700 (PDT) Message-ID: <527cf6bc0808141909u2db8c8es11586228e6e26ca4@mail.gmail.com> Date: Fri, 15 Aug 2008 04:09:31 +0200 From: "blue storm" To: peng.zang@gmail.com Subject: Re: [Caml-list] Haskell vs OCaml Cc: caml-list@yquem.inria.fr, "circ ular" In-Reply-To: <200808141001.34705.peng.zang@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <527cf6bc0808140450w3182b14n60764d3862b9080f@mail.gmail.com> <200808140928.40626.peng.zang@gmail.com> <200808141001.34705.peng.zang@gmail.com> X-Spam: no; 0.00; haskell:01 ocaml:01 haskell:01 monads:01 monads:01 compiler:01 inference:01 compiler:01 inference:01 ocaml:01 saner:01 explicitely:01 librairies:01 haskell's:01 high-level:01 > One is that Haskell forces your program into two parts. Parts that contain > side-effects (in monads) and the part that is pure. You can actually do quite a bit more, using different monads to compartementalize different aspects of your code. You will, by the way, have noticed that Haskellers tend to put everything in the IO monad (when a separate monad would make more sense) because mixing monads is difficult. > This is great because > the compiler can now do some optimizations not available when you don't know > if your code is pure. I suppose you could get the same benefits with a "purity inference" compiler pass, the same way haskell compilers a "strictness inference". > it makes side-effect creep very obvious (when you realize "oops, that needs > to be in a monad too... and that... and that ... crap"). unsafePerformIO to the rescue ! I generally agree with the interest of pure programming in some part of the language. It is, however, not all as rosy as you say (i've seen people argue that the "side-effect creep" related to monads cause composability problems) because they are hard issue (monads mixing for example) wich have not been quite resolved yet. Haskell is interesting because of that experimental taste, but i totally agree it "sometimes gets in your way". > A similar argument follows for lazy (non-strict) evaluation as well. Allows > some really cool stuff (eg. infinite lists) and optimizations (eg. > deforestation). Explicit lazy evaluation (as in OCaml) can give you the same cool stuff, with a saner standard (strict evaluation) and, in my opinion, increased comprehensibility (by explicitely highlighting the part that rely on lazy evaluation). Both library and syntaxic support of lazy values in OCaml could be better that they are now, but they is work going on (we even have *several* lazy lists librairies these day). > That's true, but I think Haskell's point of view is to stop that completely. > They want to remove optimization of code and put it into the hands of the > compiler. The ideal is to say to the programmer: "don't worry about > performance and optimization, just write correct code. The compiler will > figure out the rest". I strongly disagree on that point. You just can't rely on anything that optimizes "as much as possible" when you don't know precisely what it does. The idea to "not worry about performance" is, in my opinion, wrong because you'll always have specific cases wich are not correctly optimized (see for example the posts on the performance of high-level automatic differentiation stuff that went on the Haskell planet a month ago or so). The usual programmer should not need to know about subtle and implementation-specific stuff (whereas the requirement of understanding tail-recursion is commonly accepted among OCaml programmers), but trying to optimize every naive code into something efficient is a dangerous dream.