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.8 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 85A7CBB84 for ; Thu, 14 Aug 2008 16:01:42 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AkkCAPbXo0hKfSwdjmdsb2JhbACRQT4BAQEBCQMKBw8FnQGGeAECgx0 X-IronPort-AV: E=Sophos;i="4.32,210,1217800800"; d="scan'208";a="15993376" Received: from yx-out-2324.google.com ([74.125.44.29]) by mail3-smtp-sop.national.inria.fr with ESMTP; 14 Aug 2008 16:01:38 +0200 Received: by yx-out-2324.google.com with SMTP id 3so333451yxj.3 for ; Thu, 14 Aug 2008 07:01:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:reply-to:to:subject:date :user-agent:cc:references:in-reply-to:content-type :content-transfer-encoding:content-disposition:message-id; bh=tqZSK7QCbdEfH3Eaa78UvET2yUxVviyLsFDKRvcIdhQ=; b=qZwMdt5BsCD1wSMvpDdO+KYvmpNsWhm+GNd7xE1bUpr2EbD99jCqi3hQO+4fOsckCe SA5b2aIKfHI+6TNtZtjfwvT0JtBTDpyV2+dKjWINWINIi+eRqmmLY4rY2hO2PtzYSdTP HMXIYXlTcVHk5ouzDnTx3LYNU5a+8BLA0M96M= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:reply-to:to:subject:date:user-agent:cc:references:in-reply-to :content-type:content-transfer-encoding:content-disposition :message-id; b=tJm3eR5uNt0TcSOHDl/ydO/Xf9JY3CUOf4Tna78hbClz/35A7jJAM5a9M97aKKYVXx pixjKz+f+a2RGDQBU41W/0dTllhSXr18nLvkRhoCDOcvyRBdYi3RLCHvG/qIPt1rLoLf B9XusbEDsLDQZQ9lQAwHFOL0uPykNm0IU/1Kw= Received: by 10.115.88.1 with SMTP id q1mr1160908wal.122.1218722496727; Thu, 14 Aug 2008 07:01:36 -0700 (PDT) Received: from lawn-143-215-204-204.lawn.gatech.edu ( [143.215.204.204]) by mx.google.com with ESMTPS id 5sm2195567yxt.1.2008.08.14.07.01.35 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 14 Aug 2008 07:01:36 -0700 (PDT) From: Peng Zang Reply-To: peng.zang@gmail.com To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Haskell vs OCaml Date: Thu, 14 Aug 2008 10:01:32 -0400 User-Agent: KMail/1.9.7 Cc: "blue storm" , "circ ular" References: <527cf6bc0808140450w3182b14n60764d3862b9080f@mail.gmail.com> <200808140928.40626.peng.zang@gmail.com> In-Reply-To: <200808140928.40626.peng.zang@gmail.com> Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200808141001.34705.peng.zang@gmail.com> X-Spam: no; 0.00; haskell:01 ocaml:01 hash:01 ocaml:01 haskell:01 monads:01 compiler:01 prototyping:01 recursive:01 verbose:01 peng:98 peng:98 wrote:01 stack:01 dynamically:01 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Thursday 14 August 2008 09:28:34 am Peng Zang wrote: > OCaml let's you write however you think about it. Haskell makes you think > about it in *the haskell* way. Sometimes this is good because it forces > you to do certain things. Othertimes it just gets in your way. > > > Peng Haha, I have some free time. So, let me explain more about why sometimes it's good that Haskell makes you do things in a certain way. One is that Haskell forces your program into two parts. Parts that contain side-effects (in monads) and the part that is pure. This is great because the compiler can now do some optimizations not available when you don't know if your code is pure. This is also good because side-effects can be confusing and difficult to maintain over time. By putting all the side effects in a box, you can compartmentalize it away. For lots of changes you only have to consider the pure stuff which is easier to think about (no worries about state, no worries about the right order of doing things, program in a declarative fashion). The downside is you have to put all the side-effect stuff in a corner and box it off. This can be a little odd because it may make you organize your code in a counterintuitive way. Also it makes side-effect creep very obvious (when you realize "oops, that needs to be in a monad too... and that... and that ... crap"). You really have to sit down and think about the design before you do anything. Haskell is definitely a first-on-paper, then-in-code type of language. This can be good because for complex stuff you probably want to think about the design ahead of time anyways. Haskell forces this discpline on you. On the other hand, if you like to do rapid prototyping type of approach and live on the edge a bit, it can be a bummer. A similar argument follows for lazy (non-strict) evaluation as well. Allows some really cool stuff (eg. infinite lists) and optimizations (eg. deforestation). But has significant overhead (eg. you have to make a thunk for everything, if you're going to evaluate it anyways, all that work to make the thunk is wasted) and it's hard to reason about speed and memory performance (eg. it looks like a tail recursive function that uses constant stack space but because the accumulator is thunked, you end up creating O(N) thunks). Anyways, I think Haskell has some really cool ideas and I like it. It definitely expands the mind. But OCaml is my go-to-swiss-army-knife of languages. It used to be C but that was too low level for me and library support was crap (this was before Boost). Then it was Java but it was waay to verbose and you couldn't even return a tuple without creating a class for it first. Then it was Lisp, but it's dynamically typed and I got tired of finding bugs from 3 years ago. Now days it's OCaml. Maybe one day it'll be something else, but in the mean time, I'm enjoying it. Peng -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.7 (GNU/Linux) iD8DBQFIpDq+fIRcEFL/JewRAv3eAJ9L3W43Qfn2bFpLpUiyRt4Dn1dt6gCeNvew 8w6kCN5AKcGJH8WYzJPyKVM= =6HsO -----END PGP SIGNATURE-----