Article View: comp.lang.functional
Article #1122Re: Why such poor recursive behaviour?
From: Vend
Date: Mon, 04 Aug 2008 21:54
Date: Mon, 04 Aug 2008 21:54
74 lines
4049 bytes
4049 bytes
On 31 Lug, 12:50, "Kjetil S. Matheussen" <k.s.matheus...@notam02.no> 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&la... > > > 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 Can you post the parts of C code generated by Stalin that are faster than the hand-coded C, please? > 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:
<0e9341d2-4b23-4c12-9636-93aa6a17c09e@m36g2000hse.googlegroups.com>Path:
arc1-ca.pugleaf.net!g2news2.google.com!postnews.google.com!m36g2000hse.googlegroups.com!not-for-mailReferences:
<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!g2news2.google.com!postnews.google.com!m36g2000hse.googlegroups.com!not-for-mail From: Vend <vend82@virgilio.it> Newsgroups: comp.lang.functional,fa.caml,fa.haskell,comp.lang.scheme,comp.lang.lisp Subject: Re: Why such poor recursive behaviour? Date: Mon, 4 Aug 2008 14:54:16 -0700 (PDT) Organization: http://groups.google.com Lines: 75 Message-ID: <0e9341d2-4b23-4c12-9636-93aa6a17c09e@m36g2000hse.googlegroups.com> References: <525fb940-a88e-4276-bd80-86b0b178a08a@m3g2000hsc.googlegroups.com> <Pine.LNX.4.58.0807311242130.25184@notam02.uio.no> NNTP-Posting-Host: 87.6.168.172 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: posting.google.com 1217886856 5166 127.0.0.1 (4 Aug 2008 21:54:16 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Mon, 4 Aug 2008 21:54:16 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: m36g2000hse.googlegroups.com; posting-host=87.6.168.172; posting-account=no4jRwoAAADHjiy7leKH93A_GaYruAJ3 User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; it; rv:1.8.1.16) Gecko/20080702 Firefox/2.0.0.16,gzip(gfe),gzip(gfe)