From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Delivered-To: caml-list@yquem.inria.fr Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id E4349BC32 for ; Wed, 16 Mar 2005 02:05:48 +0100 (CET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j2G15mKE005813 for ; Wed, 16 Mar 2005 02:05:48 +0100 Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id CAA30560 for ; Wed, 16 Mar 2005 02:05:47 +0100 (MET) Received: from ryxa.irisa.fr (ryxa.irisa.fr [131.254.50.45]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j2G15le7005810 for ; Wed, 16 Mar 2005 02:05:47 +0100 Received: (from pad@localhost) by ryxa.irisa.fr (8.11.6/8.11.6) id j2G15hU02953; Wed, 16 Mar 2005 02:05:43 +0100 X-Authentication-Warning: ryxa.irisa.fr: pad set sender to padiolea@irisa.fr using -f Sender: pad@ryxa.irisa.fr To: Oliver Bandel Cc: caml-list@inria.fr Subject: Re: [Caml-list] OCaml troll on Slashdot References: <42363A86.6010309@1969.ws> <200503150859.55997.jon@ffconsultancy.com> <200503152036.45894.jon@ffconsultancy.com> <32977.131.254.50.45.1110920621.squirrel@mail.irisa.fr> <172f01077499b3d417604d0ad31f2bdb@cs.unm.edu> <20050316001819.GB347@first.in-berlin.de> From: Yoann Padioleau Date: 16 Mar 2005 02:05:43 +0100 In-Reply-To: <20050316001819.GB347@first.in-berlin.de> Message-ID: User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Miltered: at nez-perce with ID 4237866C.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 4237866B.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 ocaml:01 irisa:01 oliver:01 bandel:01 oliver:01 in-berlin:01 toplevel:01 toplevel:01 recursive:01 rec:01 recursive:01 imho:01 imho:01 associative:01 X-Spam-Checker-Version: SpamAssassin 3.0.2 (2004-11-16) on yquem.inria.fr X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.2 X-Spam-Level: Oliver Bandel writes: > But with > > let columnSize = 5;; > and with > let numRows = 7;; > > (look at the ";;" it seems he had used it in the toplevel... :)) And ? First, I dont think it is a good idea to make fun of people who try to use caml. Second, many people I know still put ";;" cos they were taught that way (at the very beginning with caml-light I think you were forced to put those ";;", it became optional later, and habits are hard to change for many people :) ) Third, doing stuff at the toplevel is a good idea. > which does not really looks tail recursive. > > Called more than 2 * 10^6 times... > > And many other examples... > > > e.g. this one: > > (* applies a list of functions to an argument *) > let rec applyFunctionList functions argument = > (* 267386 *) match functions with > | [] -> (* 9782 *) [] > | f::rest -> (* 257604 *) (f argument)::(applyFunctionList rest argument);; > > "only" called 267386 times, but when looking how the arguments > are used: also applyFunctionList is not tail recursive... > ...and even if called less than 10^6 times... it's a function that > creates a list in a non-tailrec way. > > IMHO this is the reason, why the program performs so badly! IMHO the reason it was slow is because it used associative list (instead of Map) for associative access, and list of list (instead of array) for storing the grid. I am not sure that making the function tail-recursive would have been the big hit in this example. I often transform my functions to make them tail-recursive because of stack overflow pb, not that much because of speed pbs (and many functions in the standard library are not tail-recursive, such as map) > > Ths stuff of tail recursion - even if it took a while > until I got it - was one of the first things on this list, > that people told me that it is necessary.... I am not sure it is the first optimisation trick to give to a fresh ocaml programmer. This tail-recursion stuff is one of the thing I hate the most with fp because it forces you to change your code to adapt to the machine whereas it should be the inverse. I don't understand why the compiler don't do himself those transformations. Why is it so hard to take a non-tail-recursive-function and make it a tail-recursive-one ? > > ...but as a *real* C++ programmer it seems it is not necessary to learn... > ...and better use the energy to tell all people how badly OCaml > performs! > > Well... he performs badly in code-writing. :-> We all :) Each time I look at the code of someone else I find it awful, and each time a guy look at my code he has the same reaction. > > If he had read this mailing list, he wouls have seen that HE > (better: the code he wrote) is/was the problem, not OCaml itself. :) If he had read this mailing list he would surely have stopped ocaml forever, and this is not a compliment for the ocaml community. Nevertheless, he has a little bit of a troll :) He should have post his experience to the caml-list, to get a chance to improve his code, instead of going directly to slashdot. > > > Ciao, > Oliver > > > _______________________________________________ > Caml-list mailing list. Subscription management: > http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list > Archives: http://caml.inria.fr > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs > -- Yoann Padioleau, INSA de Rennes, France www.irisa.fr/prive/padiolea/ Opinions expressed here are only mine. Je n'écris qu'à titre personnel. **____ Get Free. Be Smart. Simply use Linux and Free Software. ____**