Article View: comp.lang.functional
Article #1108Re: Why such poor recursive behaviour?
From: Kjetil S. Matheussen
Date: Thu, 31 Jul 2008 11:50
Date: Thu, 31 Jul 2008 11:50
82 lines
3669 bytes
3669 bytes
On Thu, 31 Jul 2008, Kjetil S. Matheussen wrote: > On Thu, 31 Jul 2008, namekuseijin wrote: > > > I wonder why most functional programming languages fail so badly at > > what should be one of their primary main strengths: recursive > > functions. > > > > In the well-known benchmarking game called "The computer game > > shootout", most such languages fail miserably in the face of blazing > > fast imperative code during the benchmarking of recursive functions > > such as ackermann or fibonacci: > > > > http://shootout.alioth.debian.org/gp4/benchmark.php?test=recursive&lang=all > > > > The best is clean, only 1.6 slower than gcc C. > > > > The chart: > > 1.6 Clean > > 3.2 OCaml (just behind Fortran and Java!) > > 3.3 F# (running in mono) > > 3.4 SML on MLton (just after FreeBasic!) > > 3.4 Haskell GHC (just after Java on gcj! almost a tie-in) > > 3.6 CL on SBCL (almost as good as compiled lazy static Haskell) > > 3.7 Scheme on Chicken (just after sbcl) > > 4.0 SML/NJ (just after C# on mono) > > 4.6 Scheme on Ikarus (just after Java -client!) > > 8.1 Scheme PLT (just after Fortran, again) > > > > Well, that's about it. > > > > Well, Stalin scheme is not on the list. My results: > > * GCC: > kjetil@ttleush ~/c $ time ./recursive.gcc_run 11 > Ack(3,11): 16381 > Fib(38.0): 63245986.0 > Tak(30,20,10): 11 > Fib(3): 3 > Tak(3.0,2.0,1.0): 2.0 > > real 0m2.112s > user 0m2.021s > sys 0m0.002s > Options: /usr/bin/gcc -pipe -Wall -O3 -fomit-frame-pointer -march=athlon-xp recursivec.c -o recursive.gcc_run gcc version: gcc (GCC) 4.2.4 (Gentoo 4.2.4 p1.0) > > * Stalin 0.11: > kjetil@ttleush ~/c $ time ./recursive 11 > Ack(3,11): 16381 > Fib(3.7999999523162841796875e1.0): 6.32459926605224609375e7.0 > Tak(30,20,10): 11 > Fib(3): 3 > Tak(3.0,2.0,1.0): 2.0.0 Don't bother about the not quite accurate printing of numbers, the calculations themself are correct with the same input and output values as the C version. > > real 0m1.725s > user 0m1.635s > sys 0m0.003s > > > Which means that Stalin scheme is about 22% faster than C > for this particular benchmark, and stalin scheme is a > dynamic typed functional language. Well, the types are dynamic unless stalin can't infere the types, which it obviously could in this example. :-)
Technical Details
Message-ID:
<Pine.LNX.4.58.0807311346480.25184@notam02.uio.no>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!uio.no!nntp.uio.no!notam02.uio.no!kjetismReferences:
<525fb940-a88e-4276-bd80-86b0b178a08a@m3g2000hsc.googlegroups.com> <Pine.LNX.4.58.0807311242130.25184@notam02.uio.no>Show Full Headers
Complete Article Headers
X-Google-Thread: 107f24,904ab2e1d637ae0f X-Google-Thread: ff861,904ab2e1d637ae0f X-Google-Thread: 10707f,904ab2e1d637ae0f X-Google-Thread: 103d24,904ab2e1d637ae0f X-Google-Thread: f4fd2,904ab2e1d637ae0f X-Google-Attributes: gid107f24,gidff861,gid10707f,gid103d24,gidf4fd2,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!uio.no!nntp.uio.no!notam02.uio.no!kjetism From: "Kjetil S. Matheussen" <k.s.matheussen@notam02.no> Newsgroups: comp.lang.functional,fa.caml,fa.haskell,comp.lang.scheme,comp.lang.lisp Subject: Re: Why such poor recursive behaviour? Date: Thu, 31 Jul 2008 13:50:50 +0200 Organization: University of Oslo, Norway Lines: 84 Message-ID: <Pine.LNX.4.58.0807311346480.25184@notam02.uio.no> References: <525fb940-a88e-4276-bd80-86b0b178a08a@m3g2000hsc.googlegroups.com> <Pine.LNX.4.58.0807311242130.25184@notam02.uio.no> NNTP-Posting-Host: notam02.uio.no Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Trace: readme.uio.no 1217505051 11896 129.240.197.34 (31 Jul 2008 11:50:51 GMT) X-Complaints-To: abuse@uio.no NNTP-Posting-Date: Thu, 31 Jul 2008 11:50:51 +0000 (UTC) X-X-Sender: kjetism@notam02.uio.no In-Reply-To: <Pine.LNX.4.58.0807311242130.25184@notam02.uio.no>