<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	
	>
<channel>
	<title>
	Comments on: More on Fibonacci. Oops, Sorry Lisp&#8230; Haskell runs it 5 times faster	</title>
	<atom:link href="https://programmingzen.com/more-on-fibonacci-oops-sorry-lisp-haskell-runs-it-5-times-faster/feed/" rel="self" type="application/rss+xml" />
	<link>https://programmingzen.com/more-on-fibonacci-oops-sorry-lisp-haskell-runs-it-5-times-faster/</link>
	<description>Meditations on programming, startups, and technology</description>
	<lastBuildDate>Wed, 13 Aug 2014 12:08:00 +0000</lastBuildDate>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>
	<item>
		<title>
		By: Austin		</title>
		<link>https://programmingzen.com/more-on-fibonacci-oops-sorry-lisp-haskell-runs-it-5-times-faster/#comment-28541</link>

		<dc:creator><![CDATA[Austin]]></dc:creator>
		<pubDate>Wed, 13 Aug 2014 12:08:00 +0000</pubDate>
		<guid isPermaLink="false">http://antoniocangiano.com/2007/11/30/more-on-fibonacci-oops-sorry-lisp-haskell-runs-it-5-times-faster/#comment-28541</guid>

					<description><![CDATA[Simplest:
f 0 a b = a
f n a b = f (n-1) b (a+b)
fibs n = f n 0 1

calculate fibs 80000 in 2 Sec.]]></description>
			<content:encoded><![CDATA[<p>Simplest:<br />
f 0 a b = a<br />
f n a b = f (n-1) b (a+b)<br />
fibs n = f n 0 1</p>
<p>calculate fibs 80000 in 2 Sec.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Muha		</title>
		<link>https://programmingzen.com/more-on-fibonacci-oops-sorry-lisp-haskell-runs-it-5-times-faster/#comment-3522</link>

		<dc:creator><![CDATA[Muha]]></dc:creator>
		<pubDate>Thu, 24 Apr 2008 18:43:26 +0000</pubDate>
		<guid isPermaLink="false">http://antoniocangiano.com/2007/11/30/more-on-fibonacci-oops-sorry-lisp-haskell-runs-it-5-times-faster/#comment-3522</guid>

					<description><![CDATA[Fastest:
&lt;br/&gt;
&lt;pre&gt;
import Control.Monad
import Text.Printf

fibs :: [Integer]
fibs = 0:1:zipWith (+) fibs (tail fibs)

fib n = fibs !! n

main = forM_ [0..45] $ \i -&#062; printf &quot;n=%d =&#062; %d\n&quot; i (fib i)
&lt;/pre&gt;]]></description>
			<content:encoded><![CDATA[<p>Fastest:<br />
</p>
<pre>
import Control.Monad
import Text.Printf

fibs :: [Integer]
fibs = 0:1:zipWith (+) fibs (tail fibs)

fib n = fibs !! n

main = forM_ [0..45] $ \i -&gt; printf "n=%d =&gt; %d\n" i (fib i)
</pre>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Isaac Gouy		</title>
		<link>https://programmingzen.com/more-on-fibonacci-oops-sorry-lisp-haskell-runs-it-5-times-faster/#comment-2182</link>

		<dc:creator><![CDATA[Isaac Gouy]]></dc:creator>
		<pubDate>Mon, 07 Jan 2008 15:37:30 +0000</pubDate>
		<guid isPermaLink="false">http://antoniocangiano.com/2007/11/30/more-on-fibonacci-oops-sorry-lisp-haskell-runs-it-5-times-faster/#comment-2182</guid>

					<description><![CDATA[Geir Aalberg wrote
&#062; this comparative test between SBCL Lisp and GHC Haskell

And note all those SBCL &quot;due to type uncertainty&quot; warnings.]]></description>
			<content:encoded><![CDATA[<p>Geir Aalberg wrote<br />
&gt; this comparative test between SBCL Lisp and GHC Haskell</p>
<p>And note all those SBCL &#8220;due to type uncertainty&#8221; warnings.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Geir Aalberg		</title>
		<link>https://programmingzen.com/more-on-fibonacci-oops-sorry-lisp-haskell-runs-it-5-times-faster/#comment-2090</link>

		<dc:creator><![CDATA[Geir Aalberg]]></dc:creator>
		<pubDate>Thu, 03 Jan 2008 03:18:28 +0000</pubDate>
		<guid isPermaLink="false">http://antoniocangiano.com/2007/11/30/more-on-fibonacci-oops-sorry-lisp-haskell-runs-it-5-times-faster/#comment-2090</guid>

					<description><![CDATA[You might also find this comparative test between SBCL Lisp and GHC Haskell useful. The &quot;recursive&quot; test does a series of recursive computations including Fibonacci, and here SBCL is only 20 % slower:

http://shootout.alioth.debian.org/gp4/benchmark.php?test=all&#038;lang=sbcl&#038;lang2=ghc

Also, note the wise words on the front page:

&quot;How can we benchmark a programming language?
We can&#039;t - we benchmark programming language implementations.
How can we benchmark language implementations?
We can&#039;t - we measure particular programs.&quot;]]></description>
			<content:encoded><![CDATA[<p>You might also find this comparative test between SBCL Lisp and GHC Haskell useful. The &#8220;recursive&#8221; test does a series of recursive computations including Fibonacci, and here SBCL is only 20 % slower:</p>
<p><a href="http://shootout.alioth.debian.org/gp4/benchmark.php?test=all&#038;lang=sbcl&#038;lang2=ghc" rel="nofollow ugc">http://shootout.alioth.debian.org/gp4/benchmark.php?test=all&#038;lang=sbcl&#038;lang2=ghc</a></p>
<p>Also, note the wise words on the front page:</p>
<p>&#8220;How can we benchmark a programming language?<br />
We can&#8217;t &#8211; we benchmark programming language implementations.<br />
How can we benchmark language implementations?<br />
We can&#8217;t &#8211; we measure particular programs.&#8221;</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Mike Hansen		</title>
		<link>https://programmingzen.com/more-on-fibonacci-oops-sorry-lisp-haskell-runs-it-5-times-faster/#comment-1948</link>

		<dc:creator><![CDATA[Mike Hansen]]></dc:creator>
		<pubDate>Wed, 26 Dec 2007 04:05:56 +0000</pubDate>
		<guid isPermaLink="false">http://antoniocangiano.com/2007/11/30/more-on-fibonacci-oops-sorry-lisp-haskell-runs-it-5-times-faster/#comment-1948</guid>

					<description><![CDATA[This nice thing about Python is that it has Cython ( http://www.cython.org ).  The original Python code took 131s on my machine.  The following is the conversion of that code to Cython:

cdef fib(int n):
   if n == 0 or n == 1:
      return n
   else:
      return fib(n-1) + fib(n-2)

def test(n):
    for i in range(n):
        print &quot;n=%d =&#062; %d&quot; % (i, fib(i))

This code runs in 2.08 CPU seconds on my machine.]]></description>
			<content:encoded><![CDATA[<p>This nice thing about Python is that it has Cython ( <a href="http://www.cython.org" rel="nofollow ugc">http://www.cython.org</a> ).  The original Python code took 131s on my machine.  The following is the conversion of that code to Cython:</p>
<p>cdef fib(int n):<br />
   if n == 0 or n == 1:<br />
      return n<br />
   else:<br />
      return fib(n-1) + fib(n-2)</p>
<p>def test(n):<br />
    for i in range(n):<br />
        print &#8220;n=%d =&gt; %d&#8221; % (i, fib(i))</p>
<p>This code runs in 2.08 CPU seconds on my machine.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Geir Aalberg		</title>
		<link>https://programmingzen.com/more-on-fibonacci-oops-sorry-lisp-haskell-runs-it-5-times-faster/#comment-1678</link>

		<dc:creator><![CDATA[Geir Aalberg]]></dc:creator>
		<pubDate>Fri, 14 Dec 2007 16:11:57 +0000</pubDate>
		<guid isPermaLink="false">http://antoniocangiano.com/2007/11/30/more-on-fibonacci-oops-sorry-lisp-haskell-runs-it-5-times-faster/#comment-1678</guid>

					<description><![CDATA[Guys,

for precise benchmarking you should turn always off I/O during iterations. Running under clisp on my MacBook Pro (same config as yours), the recursive Fibonacci test takes 0.005539 sec for n=45, while turning off the call to the actual computation reduces it to 0.003004 sec, i.e. only a 45 % reduction in cpu time.

Granted, some of this is startup overhead, but commenting out the format statement gives only a run time of 0.000125 sec, so unless it&#039;s smart enough to optimize out those function calls this can be neglected.]]></description>
			<content:encoded><![CDATA[<p>Guys,</p>
<p>for precise benchmarking you should turn always off I/O during iterations. Running under clisp on my MacBook Pro (same config as yours), the recursive Fibonacci test takes 0.005539 sec for n=45, while turning off the call to the actual computation reduces it to 0.003004 sec, i.e. only a 45 % reduction in cpu time.</p>
<p>Granted, some of this is startup overhead, but commenting out the format statement gives only a run time of 0.000125 sec, so unless it&#8217;s smart enough to optimize out those function calls this can be neglected.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Brian Adkins		</title>
		<link>https://programmingzen.com/more-on-fibonacci-oops-sorry-lisp-haskell-runs-it-5-times-faster/#comment-1552</link>

		<dc:creator><![CDATA[Brian Adkins]]></dc:creator>
		<pubDate>Sat, 01 Dec 2007 18:32:28 +0000</pubDate>
		<guid isPermaLink="false">http://antoniocangiano.com/2007/11/30/more-on-fibonacci-oops-sorry-lisp-haskell-runs-it-5-times-faster/#comment-1552</guid>

					<description><![CDATA[Compiling the Haskell code with optimizations made a *huge* difference. The fastest of several runs w/o optimization was 6.552s and with optimization was 0.860s. With that, the Lisp code took 1.8 times as long to execute.

Either one of those blows away Ruby which is what I typically code in. It took 95s :)]]></description>
			<content:encoded><![CDATA[<p>Compiling the Haskell code with optimizations made a *huge* difference. The fastest of several runs w/o optimization was 6.552s and with optimization was 0.860s. With that, the Lisp code took 1.8 times as long to execute.</p>
<p>Either one of those blows away Ruby which is what I typically code in. It took 95s 🙂</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Antonio Cangiano		</title>
		<link>https://programmingzen.com/more-on-fibonacci-oops-sorry-lisp-haskell-runs-it-5-times-faster/#comment-1548</link>

		<dc:creator><![CDATA[Antonio Cangiano]]></dc:creator>
		<pubDate>Sat, 01 Dec 2007 09:32:50 +0000</pubDate>
		<guid isPermaLink="false">http://antoniocangiano.com/2007/11/30/more-on-fibonacci-oops-sorry-lisp-haskell-runs-it-5-times-faster/#comment-1548</guid>

					<description><![CDATA[Ahah, that&#039;s cool w-g. With all the optimizations on, and using Valentino&#039;s optimized version, I can see that Lisp is &lt;b&gt;very&lt;/b&gt; fast. That&#039;s very good. We knew already that the main compilers for Lisp and Haskell were very fast, just like OCaml and F# are too. But establishing which one is faster and for what applications, is beyond the reach of our silly test. :)]]></description>
			<content:encoded><![CDATA[<p>Ahah, that&#8217;s cool w-g. With all the optimizations on, and using Valentino&#8217;s optimized version, I can see that Lisp is <b>very</b> fast. That&#8217;s very good. We knew already that the main compilers for Lisp and Haskell were very fast, just like OCaml and F# are too. But establishing which one is faster and for what applications, is beyond the reach of our silly test. 🙂</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: w-g		</title>
		<link>https://programmingzen.com/more-on-fibonacci-oops-sorry-lisp-haskell-runs-it-5-times-faster/#comment-1547</link>

		<dc:creator><![CDATA[w-g]]></dc:creator>
		<pubDate>Sat, 01 Dec 2007 08:44:53 +0000</pubDate>
		<guid isPermaLink="false">http://antoniocangiano.com/2007/11/30/more-on-fibonacci-oops-sorry-lisp-haskell-runs-it-5-times-faster/#comment-1547</guid>

					<description><![CDATA[For both non-tail-recursive versions:

Haskell (ghc with -O2):
real    3m7.850s (187.85s)
user    2m23.953s (143.95s)
sys     0m1.188s


Lisp (GCL with optimization turned on):
real time       :    137.860 secs
run-gbc time    :    117.470 secs
child run time  :      0.000 secs
gbc time        :      0.000 secs

&quot;Sorry Haskell...&quot;]]></description>
			<content:encoded><![CDATA[<p>For both non-tail-recursive versions:</p>
<p>Haskell (ghc with -O2):<br />
real    3m7.850s (187.85s)<br />
user    2m23.953s (143.95s)<br />
sys     0m1.188s</p>
<p>Lisp (GCL with optimization turned on):<br />
real time       :    137.860 secs<br />
run-gbc time    :    117.470 secs<br />
child run time  :      0.000 secs<br />
gbc time        :      0.000 secs</p>
<p>&#8220;Sorry Haskell&#8230;&#8221;</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: w-g		</title>
		<link>https://programmingzen.com/more-on-fibonacci-oops-sorry-lisp-haskell-runs-it-5-times-faster/#comment-1545</link>

		<dc:creator><![CDATA[w-g]]></dc:creator>
		<pubDate>Sat, 01 Dec 2007 01:04:19 +0000</pubDate>
		<guid isPermaLink="false">http://antoniocangiano.com/2007/11/30/more-on-fibonacci-oops-sorry-lisp-haskell-runs-it-5-times-faster/#comment-1545</guid>

					<description><![CDATA[- Include type declarations
- Set optimizations on
- Compile the functions using a fast Lisp compiler (SBCL or CMUCL)

- If you use CMUCL, then use block compilation


I tried both on my machine, and Lisp was several times faster.]]></description>
			<content:encoded><![CDATA[<p>&#8211; Include type declarations<br />
&#8211; Set optimizations on<br />
&#8211; Compile the functions using a fast Lisp compiler (SBCL or CMUCL)</p>
<p>&#8211; If you use CMUCL, then use block compilation</p>
<p>I tried both on my machine, and Lisp was several times faster.</p>
]]></content:encoded>
		
			</item>
	</channel>
</rss>
