caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Oliver Bandel <oliver@first.in-berlin.de>
To: caml-list@inria.fr
Subject: Re: [Caml-list] OCaml troll on Slashdot
Date: Wed, 16 Mar 2005 01:18:19 +0100	[thread overview]
Message-ID: <20050316001819.GB347@first.in-berlin.de> (raw)
In-Reply-To: <172f01077499b3d417604d0ad31f2bdb@cs.unm.edu>

On Tue, Mar 15, 2005 at 04:07:37PM -0700, William D.Neumann wrote:
> On Mar 15, 2005, at 3:12 PM, Yoann Padioleau wrote:
> 
> >>To which, I'd assume the majority response would be, "So?"
> >
> >So some of his arguments are right. You make object "So?" but
> >we could continue a long moment that way.
> 
> Perhaps, perhaps not.  His point seems to be that programming in a 
> "functional style"[1] is inherently slower than an imperative style 
> because a list or a map have different performance characteristics than 
> do arrays.  To which the only response is along the lines of "True.  


Well, I tested the program with the original values for
columnSize and numRows as well as differet values.
I did not used the values that are mentioned in the posting
(7x3), because I had not too much time.

But with

  let columnSize = 5;;
  and with
  let numRows = 7;;

(look at the ";;" it seems he had used it in the toplevel... :))

and ocamlprof I got stuff like that:




================================================
(* checks if each cell in center colum is covered by an empty cell *)
let rec isCovered c1 c2 c3 =
  (* 2650588 *) let 
          memoized_isCovered = memoize3 isCovered_table isCovered 
  in 
  match (c1, c2, c3) with
   (* if center runs out of cells first, we are covered *)
        | (_, [], _) -> (* 501290 *) true
   (* if others run out first, we are not covered *)
        | ([], _, _) -> (* 0 *) false
        | (_, _, []) -> (* 0 *) false
   (* Empty followed by Planted in center colum
      skip this cell and next cell *)
        | ( (_::(_::rest1)), (Empty::(Planted::rest2)), (_::(_::rest3)) ) -> 
                (* 553730 *) true && ( isCovered rest1 rest2 rest3 )

        | ( (Empty::rest1), (_::rest2), (_::rest3) ) -> 
                (* 837698 *) true && ( isCovered rest1 rest2 rest3 )

        | ( (_::rest1), (_::rest2), (Empty::rest3) ) -> 
                  (* 291720 *) true && ( isCovered rest1 rest2 rest3 )

   (* Empty followed by Empty in center
      This cell is covered, but don't skip next cell *)
        | ( (_::rest1), (Empty::rest2), (_::rest3) ) -> 
                (* 297530 *) true && ( isCovered rest1 rest2 rest3 )
   (* this cell is covered by next cell *)
        | ( (_::rest1), (Planted::(Empty::rest2)), (_::rest3) ) -> 
                (* 99282 *) true && ( isCovered rest1 (Empty::rest2) rest3 )

   (* default:  we reach this if our current cell is not covered *)
        | (_, _, _) -> (* 69338 *) false;;
================================================


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!

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....

...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. :->

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. :)


Ciao,
   Oliver



  parent reply	other threads:[~2005-03-16  0:18 UTC|newest]

Thread overview: 71+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-03-15  1:29 Karl Zilles
2005-03-15  8:32 ` [Caml-list] " Oliver Bandel
2005-03-15  8:45   ` Michael Vanier
2005-03-15  8:59     ` Jon Harrop
2005-03-15 20:17       ` Yoann Padioleau
2005-03-15 20:36         ` Jon Harrop
2005-03-15 21:03           ` padiolea
2005-03-15 21:40             ` William D.Neumann
2005-03-15 22:12               ` Yoann Padioleau
2005-03-15 23:07                 ` William D.Neumann
2005-03-15 23:39                   ` Jon Harrop
2005-03-15 23:54                     ` Thomas Fischbacher
2005-03-16  0:03                   ` Christopher Dutchyn
2005-03-16  0:18                   ` Oliver Bandel [this message]
2005-03-16  1:05                     ` Yoann Padioleau
2005-03-16  2:55                       ` Oliver Bandel
2005-03-16 11:23                         ` Thomas Fischbacher
2005-03-16 23:41                           ` Oliver Bandel
2005-03-16 13:33                         ` Yoann Padioleau
2005-03-16 23:59                           ` Oliver Bandel
2005-03-16  3:01                     ` Jon Harrop
2005-03-16 13:10                       ` Yoann Padioleau
2005-03-16 13:41                         ` Jacques Garrigue
2005-03-16 14:14                           ` Yoann Padioleau
2005-03-17  0:27                             ` Oliver Bandel
2005-03-16 17:43                           ` brogoff
2005-03-16 19:51                             ` Jon Harrop
2005-03-17  3:35                               ` brogoff
2005-03-17  3:48                                 ` Yaron Minsky
2005-03-17 10:16                                   ` Jon Harrop
2005-03-17 10:47                                     ` Oliver Bandel
2005-03-17 18:06                                     ` brogoff
2005-03-17 19:15                                       ` Marcin 'Qrczak' Kowalczyk
2005-03-18 17:46                                         ` brogoff
2005-03-18 18:44                                           ` Marcin 'Qrczak' Kowalczyk
2005-03-17 21:31                                       ` Oliver Bandel
2005-03-17  9:45                                 ` Christian Szegedy
2005-03-17 10:31                                 ` Jon Harrop
2005-03-17 11:11                                   ` Ville-Pertti Keinonen
2005-03-17 11:31                               ` tail-recursion vs. no tail-recursion in list functions sebastian.egner
2005-03-17 21:41                                 ` [Caml-list] " Oliver Bandel
2005-03-18  0:04                                   ` David Brown
2005-03-18  0:06                                   ` Karl Zilles
2005-03-18  1:13                                 ` Jacques Garrigue
2005-03-17  0:21                             ` [Caml-list] OCaml troll on Slashdot Oliver Bandel
2005-03-17  1:05                             ` Jacques Garrigue
2005-03-17 17:32                             ` Jason Hickey
2005-03-17 19:06                               ` Marcin 'Qrczak' Kowalczyk
2005-03-17  0:14                           ` Oliver Bandel
2005-03-16  1:38             ` Jacques Garrigue
2005-03-31 11:42         ` Paul Argentoff
2005-03-31 11:41       ` Paul Argentoff
2005-03-15 20:06   ` Yoann Padioleau
2005-03-15  9:25 ` Richard Jones
2005-03-15 10:08   ` YANG Shouxun
2005-03-15 20:02     ` Yoann Padioleau
2005-03-15 22:33       ` Richard Jones
2005-03-16  1:33       ` YANG Shouxun
2005-03-15 10:34   ` padiolea
2005-03-15 10:52     ` Diego Olivier Fernandez Pons
2005-03-15 14:12     ` Eijiro Sumii
2005-03-15 15:25       ` Christophe TROESTLER
2005-03-15 18:05         ` Thomas Fischbacher
2005-03-15 18:26           ` Kip Macy
2005-03-16  0:32             ` Oliver Bandel
2005-03-16 11:26             ` David Fox
2005-03-15 18:55         ` Christopher A. Watford
2005-03-15 19:56           ` Jon Harrop
2005-03-16  0:35             ` Oliver Bandel
2005-03-16  0:34           ` Oliver Bandel
2005-03-18  6:04 Harrison, John R

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20050316001819.GB347@first.in-berlin.de \
    --to=oliver@first.in-berlin.de \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).