Version française
Home     About     Download     Resources     Contact us    
Browse thread
OCaml troll on Slashdot
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Yoann Padioleau <padiolea@i...>
Subject: Re: [Caml-list] OCaml troll on Slashdot
Oliver Bandel <oliver@first.in-berlin.de> 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.   ____**