mfurr changed the topic of #ocaml to: OCaml 3.08.2 available! | Archive of Caml Weekly News: http://sardes.inrialpes.fr/~aschmitt/cwn/ | A free book: http://cristal.inria.fr/~remy/cours/appsem/ | Mailing List: http://caml.inria.fr/bin/wilma/caml-list/ | Cookbook: http://pleac.sourceforge.net/
bigboote has quit [Read error: 110 (Connection timed out)]
jourdechance has quit ["Leaving"]
monochrom has quit ["Few people understand "understanding"."]
smkl_ has joined #ocaml
smt has joined #ocaml
mfurr has quit ["Client Exiting"]
<smt> I just wrote my second OCaml program, and what else could it be than one that prints fibonacci numbers. even the bytecode version ran really fast, but when compiled to native code it ran faster than exactly the same program written in C (and compiled with -O2)
<smt> does OCaml optimize the recursion somehow? does it even remove it completely?
<grirgz> look to the asm code :p
<smt> not gonna do that :)
<smt> 19308 lines of asm :P
<grirgz> ouatch !
<det> smt, O'caml optimizes tail recursion
<grirgz> just for a fibonacci function ?
<det> smt, I think the labels in the asm correspond to the function
<smt> det, hmm... but IIRC gcc should do that as well with -O2, no?
<det> It is very hard to do tail call optmization in C
<det> but for some simple cases, GCC will do it
<smt> fibonacci should be simple enough...
<det> what defintion?
<smt> what you mean?
<det> The naive implementation is not tail recursive AFAIK
<smt> if (n < 2) return 1; return fib(n-1) + fib(n-2);
<det> Is your implementation short, can you paste it (less than 4 lines or so)
<det> That is not tail recursive
<smt> and the ocaml version: if n < 2 then 1 else fib(n-1) + fib(n-2);;
<det> yeah, that is the naive implementation
<smt> yup, the school book version :)
<det> O'caml can't optimize the recursion away
<smt> hmm... how come it's faster than the C version? need to put less stuff in stack then?
<det> tail recursion (A special case of a tail call) is when the last thing you do is call yourself
<det> in that example the last thing being done is (ignoring the decieving infix syntax) +
<smt> hmm.. ah, indeed, the last thing I do here is sum up
<smt> yeah
<smt> anyway, I use the same (poor) algorithm in the C and O'caml versions
<det> I am not familiar witht he implementation of O'caml
<det> But I guess that is just something it excells at
<smt> nice :)
<det> I am sure C will be happy to tear apart O'caml in many other examples :)
<smt> of course. I was just wondering what it optimizes here
<det> Nothing
xqw has joined #ocaml
<det> smt, compare the asm
<smt> I'm not _that_ interested in it that I'd look at gcc optimized asm, which is a mess
<smt> I'll rather spend the time learning more O'caml
<det> It would certainly taken less time than you spent here :)
<smt> bah :)
cmeme has quit [Read error: 54 (Connection reset by peer)]
<mlh> C would use more stack, no?
cognominal has quit [Read error: 60 (Operation timed out)]
<smt> and at the ocaml "about the program" is this: NOT ACCEPTED: Program not recursive.
<det> ugh, I just tried to do C-x 2 in firefox
<smt> however, when I look at the asm of the ocaml version it looks like the recursion is still there
<smt> too much emacs for you
<det> I think that is from an older version of O'caml
<det> erm, old version of the O'caml fibo entry
<det> "The OCaml fibonacci entry is incorrect. It uses an iterative loop to
<det> compute the fibonacci numbers, while the test requires the usual naive
<det> recursive approach. It is pretty clear that something is wrong from
<det> looking at the timing table, which shows OCaml as 30 times faster than
<det> the next best language."
<smt> ah, so they've fixed the ocaml version but forgot the old remark there
<det> It seems
humasect has quit [Read error: 60 (Operation timed out)]
CosmicRay has joined #ocaml
smkl_ has quit [Read error: 110 (Connection timed out)]
cmeme has joined #ocaml
smkl_ has joined #ocaml
CosmicRay has quit ["Client exiting"]
anyone has joined #ocaml
<det> anyone, You are a often sought after person
<det> anyone, people are constantly joining to ask if "Anyone is here"
<anyone> my intention to play with them.
mfurr has joined #ocaml
cjohnson has quit [Read error: 104 (Connection reset by peer)]
smkl_ has quit [Read error: 110 (Connection timed out)]
mlh has quit [Client Quit]
mfurr has quit ["sleep"]
zzorn has joined #ocaml
smkl_ has joined #ocaml
anyone has quit ["Few people understand understanding."]
__DL__ has joined #ocaml
grirgz_ has joined #ocaml
a-zwei has joined #ocaml
grirgz has quit [Read error: 104 (Connection reset by peer)]
a-zwei has left #ocaml []
a-zwei has joined #ocaml
Msandin has joined #ocaml
Submarine has joined #ocaml
a-zwei has quit [Read error: 104 (Connection reset by peer)]
a-zwei has joined #ocaml
a-zwei has quit [Client Quit]
humasect has joined #ocaml
vezenchio has quit ["We learn from history that we learn nothing from history"]
vezenchio has joined #ocaml
pango has quit [Remote closed the connection]
solarwind has quit ["leaving"]
pango has joined #ocaml
<vincenz> lol
* vincenz smacks det
Submarine has quit ["Leaving"]
<shrimpx> heh
Submarine has joined #ocaml
smkl_ has quit [Read error: 110 (Connection timed out)]
mlh has joined #ocaml
Submarine has quit ["Leaving"]
Banana has quit [Read error: 60 (Operation timed out)]
smkl_ has joined #ocaml
Submarine has joined #ocaml
mlh has quit [Client Quit]
cjohnson has joined #ocaml
smkl_ has quit [Read error: 60 (Operation timed out)]
_JusSx_ has joined #ocaml
_JusSx_ has quit ["leaving"]
vezenchio has quit ["We learn from history that we learn nothing from history"]
vodka-goo has joined #ocaml
grirgz_ is now known as grirgz
smimou has joined #ocaml
smkl_ has joined #ocaml
mfurr has joined #ocaml
CosmicRay has joined #ocaml
cognominal has joined #ocaml
Yorick has joined #ocaml
a-zwei has joined #ocaml
mattam has joined #ocaml
cognominal has quit [Read error: 60 (Operation timed out)]
smkl_ has quit [Read error: 110 (Connection timed out)]
cognominal has joined #ocaml
zzorn is now known as zzorn_afk
slashvar[lri] has quit [Remote closed the connection]
slashvar[lri] has joined #ocaml
mfurr has quit [Remote closed the connection]
Msandin has quit [Read error: 110 (Connection timed out)]
smkl_ has joined #ocaml
_fab has quit [Remote closed the connection]
Yorick has left #ocaml []
Snark has joined #ocaml
mrvn_ has joined #ocaml
Submarine has quit ["Leaving"]
xerox has quit [Read error: 104 (Connection reset by peer)]
mrvn has quit [Read error: 110 (Connection timed out)]
smkl_ has quit [Read error: 110 (Connection timed out)]
pango has quit ["Leaving"]
Submarine has joined #ocaml
cognominal has quit [Read error: 60 (Operation timed out)]
xol has joined #ocaml
cjohnson has quit [Read error: 60 (Operation timed out)]
cognominal has joined #ocaml
_fab has joined #ocaml
smkl_ has joined #ocaml
cognominal has quit [Read error: 54 (Connection reset by peer)]
cognominal has joined #ocaml
grirgz has quit [Read error: 104 (Connection reset by peer)]
cognominal has quit [Read error: 54 (Connection reset by peer)]
cognominal has joined #ocaml
Snark has quit ["Leaving"]
Zaius has joined #ocaml
smkl_ has quit [Read error: 110 (Connection timed out)]
smimram has joined #ocaml
smimou has quit [Read error: 113 (No route to host)]
Zaius has quit ["Miranda IM! Smaller, Faster, Easier. http://miranda-im.org"]
picard has quit ["Leaving"]
smimou has joined #ocaml
monochrom has joined #ocaml
smimram has quit [Read error: 113 (No route to host)]
xol has quit [Read error: 104 (Connection reset by peer)]
Submarine has quit ["Leaving"]
smkl_ has joined #ocaml
gim_ has joined #ocaml
mrpingoo has joined #ocaml
pingouin has joined #ocaml
vodka-goo has quit [Read error: 60 (Operation timed out)]
gim has quit [Read error: 60 (Operation timed out)]
Smerdyakov has quit [Read error: 110 (Connection timed out)]
gim_ has quit [Read error: 113 (No route to host)]
gim_ has joined #ocaml
mrpingoo has quit [Read error: 110 (Connection timed out)]
pingouin is now known as vodka-goo
zzorn_afk has quit ["They are coming to take me away, ha ha"]
__DL__ has quit [Remote closed the connection]
CosmicRay has quit ["Client exiting"]
KrispyKringle has quit ["Changing server"]
KrispyKringle has joined #ocaml
mlh has joined #ocaml
Banana has joined #ocaml
mattam has quit ["zZz"]
smkl_ has quit [Read error: 60 (Operation timed out)]
vincenz has quit ["leaving"]