🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.functional
Article #1110

Re: Why such poor recursive behaviour?

#1110
From: Abdulaziz Ghuloum
Date: Thu, 31 Jul 2008 15:54
69 lines
4185 bytes
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.
>
> I know in the grand scheme of things, such timings are not that bad,
> not orders of magnitude slower like some of the dynamic scripting
> stinkers in the bottom, specially in the face of such classy and easy
> syntax and semantics adding to programmer productivity.  Still, kind
> of a let down, like buying a Playstation 3 and waiting for a killer
> app that never comes...
>
> Any thoughts?

Yes.  These programs not only perform recursion but also perform
small numerical computations.  Because of Scheme's numeric tower,
a system that supports bignums cannot compile these benchmarks as
fast as systems that have fixed precision numbers (all the rest?).

The benchmark program itself can be converted to use fixnum-specific
or flonum-specific operators.  This in turn gives some compiler
better chance of recovering some information regarding the size and
representation of the arguments.  For example, in the development
version of Ikarus, the run time on my machine the given benchmark
program is:

real    0m6.529s
user    0m6.386s
sys     0m0.088s

Now modifying the program to use fixnum and flonum operations when
appropriate, the run time becomes:

real    0m4.508s
user    0m4.421s
sys     0m0.077s

If you can interpolate these numbers to the ones you give in the
list above, Ikarus will be in the low 3.x range.  Note that the
program is still fully safe and still performs overflow check for
the fixnum arithmetic operations.

In short, the benchmark in Scheme measures how fast you do fixnum
and flonum computations more than how fast you do recursion.

Aziz,,,
Technical Details
Message-ID: <80d377f2-53e6-4b9b-8114-b58bd57b8199@1g2000pre.googlegroups.com>
Path: arc1-ca.pugleaf.net!g2news2.google.com!postnews.google.com!1g2000pre.googlegroups.com!not-for-mail
References: <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!g2news2.google.com!postnews.google.com!1g2000pre.googlegroups.com!not-for-mail
From: Abdulaziz Ghuloum <aghuloum@gmail.com>
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 08:54:02 -0700 (PDT)
Organization: http://groups.google.com
Lines: 69
Message-ID: <80d377f2-53e6-4b9b-8114-b58bd57b8199@1g2000pre.googlegroups.com>
References: <525fb940-a88e-4276-bd80-86b0b178a08a@m3g2000hsc.googlegroups.com>
NNTP-Posting-Host: 24.6.86.246
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
X-Trace: posting.google.com 1217519642 2559 127.0.0.1 (31 Jul 2008 15:54:02 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Thu, 31 Jul 2008 15:54:02 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: 1g2000pre.googlegroups.com; posting-host=24.6.86.246; 
 posting-account=1iYD0QoAAADLwiswTH3EQfhBeS2-jWcH
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_4_11; en) 
 AppleWebKit/525.18 (KHTML, like Gecko) Version/3.1.1 Safari/525.18,gzip(gfe),gzip(gfe)