Article View: comp.lang.functional
Article #1106Re: Why such poor recursive behaviour?
From: Kjetil S. Matheussen
Date: Thu, 31 Jul 2008 10:50
Date: Thu, 31 Jul 2008 10:50
74 lines
3681 bytes
3681 bytes
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 * 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 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. Source: http://www.notam02.no/~kjetism/recursive.scm Compile with stalin -On -no-clone-size-limit -Ob -Om -Or -Ot -copt -O3 -copt -fomit-frame-pointer -copt -march=athlon-xp -dC -dh -architecture IA32-align-double -copt -malign-double -copt -freg-struct-return -d0 -d1 -d5 -d6 -k recursive.scm (most of these options probably don't make any difference regarding execution speed, I just tried various things to see if it improved, and kept most that didn't make a difference)
Technical Details
Message-ID:
<Pine.LNX.4.58.0807311242130.25184@notam02.uio.no>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!feeder.erje.net!eweka.nl!lightspeed.eweka.nl!npeer.de.kpn-eurorings.net!npeer-ng1.kpn.DE!uio.no!nntp.uio.no!notam02.uio.no!kjetismReferences:
<525fb940-a88e-4276-bd80-86b0b178a08a@m3g2000hsc.googlegroups.com>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!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!feeder.erje.net!eweka.nl!lightspeed.eweka.nl!npeer.de.kpn-eurorings.net!npeer-ng1.kpn.DE!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 12:50:22 +0200 Organization: University of Oslo, Norway Lines: 75 Message-ID: <Pine.LNX.4.58.0807311242130.25184@notam02.uio.no> References: <525fb940-a88e-4276-bd80-86b0b178a08a@m3g2000hsc.googlegroups.com> NNTP-Posting-Host: notam02.uio.no Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Trace: readme.uio.no 1217501423 8542 129.240.197.34 (31 Jul 2008 10:50:23 GMT) X-Complaints-To: abuse@uio.no NNTP-Posting-Date: Thu, 31 Jul 2008 10:50:23 +0000 (UTC) X-X-Sender: kjetism@notam02.uio.no In-Reply-To: <525fb940-a88e-4276-bd80-86b0b178a08a@m3g2000hsc.googlegroups.com>