<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>A Tempest of Thoughts &#187; PHP</title>
	<atom:link href="http://tempe.st/category/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://tempe.st</link>
	<description>aka blog.to_int(:inig)</description>
	<lastBuildDate>Thu, 07 Apr 2011 08:24:09 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.1</generator>
		<item>
		<title>How to ease Drupal development with Capistrano</title>
		<link>http://tempe.st/2008/07/how-to-ease-drupal-development-with-capistrano/</link>
		<comments>http://tempe.st/2008/07/how-to-ease-drupal-development-with-capistrano/#comments</comments>
		<pubDate>Tue, 22 Jul 2008 07:12:58 +0000</pubDate>
		<dc:creator>Giovanni Intini</dc:creator>
				<category><![CDATA[Capistrano]]></category>
		<category><![CDATA[Drupal]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[development]]></category>

		<guid isPermaLink="false">http://tempe.st/?p=240</guid>
		<description><![CDATA[Drupal is a great piece of software, unfortunately it stores so much stuff in the db that people struggle keeping in sync the development server/box and a staging server to show their customers how the work is proceeding. Today I will share the Capistrano tasks I use to sync my development box with the staging [...]]]></description>
			<content:encoded><![CDATA[	<p>Drupal is a great piece of software, unfortunately it stores so much stuff in the db that people struggle keeping in sync the development server/box and a staging server to show their customers how the work is proceeding.</p>
	<p>Today I will share the Capistrano tasks I use to sync my development box with the staging server. What I basically do is dumping the development db, sending it to the server via capistrano and then use the dump to replace the server&#8217;s database.</p>
	<p>The following tasks should be used together with the tasks in my <a href="http://tempe.st/2008/07/deploying-drupal-with-capistrano/">Deploying drupal with Capistrano</a> article. I took advantage of deploy:cold not being needed with Drupal, and added a callback to it, so if you want to do a deploy that also updated the database you should use deploy:cold.</p>
	<p>You should also have two settings files (usually stored in drupal_root/sites/default), one called settings.development.php, with your local database setup and one called settings.production.php with the remote database setup, the capistrano tasks will take care of choosing the correct one.</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#008000; font-style:italic;"># Callbacks</span>
before <span style="color:#996600;">'deploy:start'</span>, <span style="color:#996600;">'drupal:db:import:production'</span>
before <span style="color:#996600;">'deploy:restart'</span>, <span style="color:#996600;">'drupal:configure:production'</span>
before <span style="color:#996600;">'deploy:start'</span>, <span style="color:#996600;">'drupal:configure:production'</span>
before <span style="color:#996600;">'deploy:cold'</span>, <span style="color:#996600;">'drupal:db:dump:development'</span>
&nbsp;
<span style="color:#008000; font-style:italic;"># DB Stuff</span>
set <span style="color:#ff3333; font-weight:bold;">:mysqldump</span>, <span style="color:#996600;">&quot;/path/to/mysqldump&quot;</span>
set <span style="color:#ff3333; font-weight:bold;">:local_db_user</span>, <span style="color:#996600;">&quot;local_mysql_username&quot;</span>
set <span style="color:#ff3333; font-weight:bold;">:local_db_password</span>, <span style="color:#996600;">&quot;local_mysql_password&quot;</span>
set <span style="color:#ff3333; font-weight:bold;">:local_db_name</span>, <span style="color:#996600;">&quot;local_db_name&quot;</span>
set <span style="color:#ff3333; font-weight:bold;">:db_user</span>, <span style="color:#996600;">&quot;remote_mysql_username&quot;</span>
set <span style="color:#ff3333; font-weight:bold;">:db_password</span>, <span style="color:#996600;">&quot;remote_mysql_password&quot;</span>
set <span style="color:#ff3333; font-weight:bold;">:db_name</span>, <span style="color:#996600;">&quot;remote_db_name&quot;</span>
&nbsp;
namespace <span style="color:#ff3333; font-weight:bold;">:drupal</span> <span style="color:#9966CC; font-weight:bold;">do</span>
  namespace <span style="color:#ff3333; font-weight:bold;">:configure</span> <span style="color:#9966CC; font-weight:bold;">do</span>
    task <span style="color:#ff3333; font-weight:bold;">:production</span> <span style="color:#9966CC; font-weight:bold;">do</span>
      sudo <span style="color:#996600;">&quot;cp #{latest_release}/sites/default/settings.production.php #{latest_release}/sites/default/settings.php&quot;</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
    task <span style="color:#ff3333; font-weight:bold;">:development</span> <span style="color:#9966CC; font-weight:bold;">do</span>
      sudo <span style="color:#996600;">&quot;cp #{latest_release}/sites/default/settings.development.php #{latest_release}/sites/default/settings.php&quot;</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  namespace <span style="color:#ff3333; font-weight:bold;">:db</span> <span style="color:#9966CC; font-weight:bold;">do</span>
    namespace <span style="color:#ff3333; font-weight:bold;">:dump</span> <span style="color:#9966CC; font-weight:bold;">do</span>
      task <span style="color:#ff3333; font-weight:bold;">:development</span> <span style="color:#9966CC; font-weight:bold;">do</span>
        <span style="color:#CC0066; font-weight:bold;">raise</span> <span style="color:#CC00FF; font-weight:bold;">RuntimeError</span>.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;failed dump&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">unless</span> <span style="color:#CC0066; font-weight:bold;">system</span> <span style="color:#996600;">&quot;#{mysqldump} -u #{local_db_user} --password=#{local_db_password} #{local_db_name} &gt; dump.sql&quot;</span>
      <span style="color:#9966CC; font-weight:bold;">end</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
    namespace <span style="color:#ff3333; font-weight:bold;">:import</span> <span style="color:#9966CC; font-weight:bold;">do</span>
      task <span style="color:#ff3333; font-weight:bold;">:production</span> <span style="color:#9966CC; font-weight:bold;">do</span>
        ENV<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;FILES&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#996600;">&quot;dump.sql&quot;</span>
        deploy::upload
        run <span style="color:#996600;">&quot;mysql -u #{db_user} --password=#{db_password} #{db_name} &lt; #{latest_release}/dump.sql&quot;</span>
      <span style="color:#9966CC; font-weight:bold;">end</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>



 ]]></content:encoded>
			<wfw:commentRss>http://tempe.st/2008/07/how-to-ease-drupal-development-with-capistrano/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Deploying Drupal with Capistrano</title>
		<link>http://tempe.st/2008/07/deploying-drupal-with-capistrano/</link>
		<comments>http://tempe.st/2008/07/deploying-drupal-with-capistrano/#comments</comments>
		<pubDate>Thu, 17 Jul 2008 21:02:48 +0000</pubDate>
		<dc:creator>Giovanni Intini</dc:creator>
				<category><![CDATA[Capistrano]]></category>
		<category><![CDATA[Drupal]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://tempe.st/?p=230</guid>
		<description><![CDATA[Mikamai, the company I work for, has just released Montalbano.tv, the companion site to one of the most successful TV shows in Italy. I was the technical director of this Drupal based project, and while I was happy we chose Drupal, because it allowed us to deliver all the features they needed on time, I [...]]]></description>
			<content:encoded><![CDATA[	<p><a href="http://mikamai.com">Mikamai</a>, the company I work for, has just released <a href="http://montalbano.tv">Montalbano.tv</a>, the companion site to one of the most successful TV shows in Italy.</p>
	<p>I was the technical director of this Drupal based project, and while I was happy we chose Drupal, because it allowed us to deliver all the features they needed on time, I almost panicked when they told us the production setup would have two servers, both with database and web serving duties.</p>
	<p>The database replication was standard MySql master-master setup, but I had to develop a strategy to keep the two code-bases on the two servers synchronized. </p>
	<p>Being a Ruby programmer at heart, I selected the only tool that never fails me in circumstances like the one we had: <a href="http://capify.org">Capistrano</a>.</p>
	<p>Unfortunately, while Capistrano is all easy to use with Rails, I had to write a custom Drupal-tailored Capfile.</p>
	<p>Here it is, in its entirety, in case you ever need to  deploy Drupal with cap (now I always deploy Drupal with cap, since I have the recipe ready <img src='http://tempe.st/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> ):</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#CC0066; font-weight:bold;">load</span> <span style="color:#996600;">'deploy'</span> <span style="color:#9966CC; font-weight:bold;">if</span> respond_to?<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:namespace</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#008000; font-style:italic;"># cap2 differentiator</span>
&nbsp;
<span style="color:#008000; font-style:italic;"># Standard configuration</span>
set <span style="color:#ff3333; font-weight:bold;">:user</span>, <span style="color:#996600;">&quot;username&quot;</span>
set <span style="color:#ff3333; font-weight:bold;">:password</span>, <span style="color:#996600;">&quot;password&quot;</span>
set <span style="color:#ff3333; font-weight:bold;">:application</span>, <span style="color:#996600;">&quot;application.name&quot;</span>
&nbsp;
<span style="color:#008000; font-style:italic;"># I like to deploy the code in /var/apps</span>
<span style="color:#008000; font-style:italic;"># and then link it to the webserver directory</span>
set <span style="color:#ff3333; font-weight:bold;">:deploy_to</span>, <span style="color:#996600;">&quot;/var/apps/#{application}&quot;</span>
&nbsp;
<span style="color:#008000; font-style:italic;"># SCM Stuff configure to taste, just remember the repository</span>
<span style="color:#008000; font-style:italic;"># here I used github as main repository</span>
set <span style="color:#ff3333; font-weight:bold;">:repository</span>,  <span style="color:#996600;">&quot;git@github.com:username/project.git&quot;</span>
set <span style="color:#ff3333; font-weight:bold;">:scm</span>, <span style="color:#ff3333; font-weight:bold;">:git</span>
set <span style="color:#ff3333; font-weight:bold;">:branch</span>, <span style="color:#996600;">&quot;master&quot;</span>
set <span style="color:#ff3333; font-weight:bold;">:repository_cache</span>, <span style="color:#996600;">&quot;git_master&quot;</span>
set <span style="color:#ff3333; font-weight:bold;">:deploy_via</span>, <span style="color:#ff3333; font-weight:bold;">:remote_cache</span>
set <span style="color:#ff3333; font-weight:bold;">:scm_verbose</span>,  <span style="color:#0000FF; font-weight:bold;">true</span>
&nbsp;
<span style="color:#008000; font-style:italic;"># Two servers, double fun</span>
<span style="color:#008000; font-style:italic;"># You really don't need app, web and db here,</span>
<span style="color:#008000; font-style:italic;"># but I used all of them just to be sure.</span>
<span style="color:#008000; font-style:italic;"># Usually only web is ok.</span>
role <span style="color:#ff3333; font-weight:bold;">:app</span>, <span style="color:#996600;">&quot;first.server.address.com&quot;</span>
role <span style="color:#ff3333; font-weight:bold;">:app</span>, <span style="color:#996600;">&quot;second.server.address.com&quot;</span>, <span style="color:#ff3333; font-weight:bold;">:primary</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#0000FF; font-weight:bold;">true</span>
role <span style="color:#ff3333; font-weight:bold;">:web</span>, <span style="color:#996600;">&quot;first.server.address.com&quot;</span>
role <span style="color:#ff3333; font-weight:bold;">:web</span>, <span style="color:#996600;">&quot;second.server.address.com&quot;</span>, <span style="color:#ff3333; font-weight:bold;">:primary</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#0000FF; font-weight:bold;">true</span>
role <span style="color:#ff3333; font-weight:bold;">:db</span>, <span style="color:#996600;">&quot;first.server.address.com&quot;</span>
role <span style="color:#ff3333; font-weight:bold;">:db</span>, <span style="color:#996600;">&quot;second.server.address.com&quot;</span>, <span style="color:#ff3333; font-weight:bold;">:primary</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#0000FF; font-weight:bold;">true</span>
&nbsp;
after <span style="color:#996600;">'deploy:setup'</span>, <span style="color:#996600;">'drupal:setup'</span> <span style="color:#008000; font-style:italic;"># Here we setup the shared files directory</span>
after <span style="color:#996600;">'deploy:symlink'</span>, <span style="color:#996600;">'drupal:symlink'</span> <span style="color:#008000; font-style:italic;"># After symlinking the code we symlink the shared dirs</span>
&nbsp;
<span style="color:#008000; font-style:italic;"># Before restarting the webserver we fix all the </span>
<span style="color:#008000; font-style:italic;"># permissions and then symlink it to production</span>
before <span style="color:#996600;">'deploy:restart'</span>, <span style="color:#996600;">'mikamai:permissions:fix'</span>, <span style="color:#996600;">'mikamai:symlink:application'</span>
&nbsp;
&nbsp;
namespace <span style="color:#ff3333; font-weight:bold;">:drupal</span> <span style="color:#9966CC; font-weight:bold;">do</span>
  <span style="color:#008000; font-style:italic;"># shared directories</span>
  task <span style="color:#ff3333; font-weight:bold;">:setup</span>, <span style="color:#ff3333; font-weight:bold;">:except</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#ff3333; font-weight:bold;">:no_release</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#0000FF; font-weight:bold;">true</span> <span style="color:#006600; font-weight:bold;">&#125;</span> <span style="color:#9966CC; font-weight:bold;">do</span>
    sudo <span style="color:#996600;">&quot;mkdir -p #{shared_path}/files&quot;</span>
    sudo <span style="color:#996600;">&quot;chown -R #{user}:#{user} #{deploy_to}&quot;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#008000; font-style:italic;"># symlink shared directories</span>
  task <span style="color:#ff3333; font-weight:bold;">:symlink</span>, <span style="color:#ff3333; font-weight:bold;">:except</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#ff3333; font-weight:bold;">:no_release</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#0000FF; font-weight:bold;">true</span> <span style="color:#006600; font-weight:bold;">&#125;</span> <span style="color:#9966CC; font-weight:bold;">do</span>
    sudo <span style="color:#996600;">&quot;ln -s #{shared_path}/files #{latest_release}&quot;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
namespace <span style="color:#ff3333; font-weight:bold;">:deploy</span> <span style="color:#9966CC; font-weight:bold;">do</span>
  <span style="color:#008000; font-style:italic;"># adjusted finalize_update, removed non rails stuff</span>
  task <span style="color:#ff3333; font-weight:bold;">:finalize_update</span>, <span style="color:#ff3333; font-weight:bold;">:except</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#ff3333; font-weight:bold;">:no_release</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#0000FF; font-weight:bold;">true</span> <span style="color:#006600; font-weight:bold;">&#125;</span> <span style="color:#9966CC; font-weight:bold;">do</span>
    sudo <span style="color:#996600;">&quot;chmod -R g+w #{latest_release}&quot;</span> <span style="color:#9966CC; font-weight:bold;">if</span> fetch<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:group_writable</span>, <span style="color:#0000FF; font-weight:bold;">true</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  task <span style="color:#ff3333; font-weight:bold;">:restart</span> <span style="color:#9966CC; font-weight:bold;">do</span>
    <span style="color:#008000; font-style:italic;"># nothing to do here since we're on mod-php</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
namespace <span style="color:#ff3333; font-weight:bold;">:mikamai</span> <span style="color:#9966CC; font-weight:bold;">do</span>
  <span style="color:#008000; font-style:italic;"># symlinking to production</span>
  namespace <span style="color:#ff3333; font-weight:bold;">:symlink</span> <span style="color:#9966CC; font-weight:bold;">do</span>
    task <span style="color:#ff3333; font-weight:bold;">:application</span>, <span style="color:#ff3333; font-weight:bold;">:except</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#ff3333; font-weight:bold;">:no_release</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#0000FF; font-weight:bold;">true</span> <span style="color:#006600; font-weight:bold;">&#125;</span> <span style="color:#9966CC; font-weight:bold;">do</span>
      sudo <span style="color:#996600;">&quot;rm -rf /var/www/montalbano&quot;</span>
      sudo <span style="color:#996600;">&quot;ln -s #{latest_release} /var/www/montalbano&quot;</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#008000; font-style:italic;"># change ownership</span>
  namespace <span style="color:#ff3333; font-weight:bold;">:permissions</span> <span style="color:#9966CC; font-weight:bold;">do</span>
    task <span style="color:#ff3333; font-weight:bold;">:fix</span>, <span style="color:#ff3333; font-weight:bold;">:except</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#ff3333; font-weight:bold;">:no_release</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#0000FF; font-weight:bold;">true</span> <span style="color:#006600; font-weight:bold;">&#125;</span> <span style="color:#9966CC; font-weight:bold;">do</span>
      sudo <span style="color:#996600;">&quot;chown -R www-data:www-data #{latest_release}&quot;</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>



 ]]></content:encoded>
			<wfw:commentRss>http://tempe.st/2008/07/deploying-drupal-with-capistrano/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>For the first time ever Apple failed me. A PHP horror story on mac os x.</title>
		<link>http://tempe.st/2008/03/for-the-first-time-ever-apple-failed-me-a-php-horror-story-on-mac-os-x/</link>
		<comments>http://tempe.st/2008/03/for-the-first-time-ever-apple-failed-me-a-php-horror-story-on-mac-os-x/#comments</comments>
		<pubDate>Mon, 31 Mar 2008 20:54:19 +0000</pubDate>
		<dc:creator>Giovanni Intini</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://tempe.st/2008/03/for-the-first-time-ever-apple-failed-me-a-php-horror-story-on-mac-os-x/</guid>
		<description><![CDATA[Earlier today I was on the verge of smashing my macbook pro keyboard. I lost one whole day trying to make mssql support work on php5. Apple ships a working php5, but obviously without any support for mssql. So I had to rebuild php from scratch. I battle for 2 hours trying to compile freetds, [...]]]></description>
			<content:encoded><![CDATA[	<p>Earlier today I was on the verge of smashing my macbook pro keyboard. I lost one whole day trying to make mssql support work on php5.</p>
	<p>Apple ships a working php5, but obviously without any support for mssql. So I had to rebuild php from scratch.</p>
	<p>I battle for 2 hours trying to compile <a href="http://freetds.org">freetds</a>, then I discovered the latest version of freetds doesn&#8217;t work with php5.</p>
	<p>When I finally compiled freetds I discovered the infamous iconv bug that doesn&#8217;t allow php to compile on mac os x with iconv support. I disabled iconv, and it compiled. </p>
	<p>I was not finished though: apple shipped apache doesn&#8217;t want any recompiled PHP, so I had to recompile apache too.</p>
	<p>When I thought it was all ok I discovered that symfony needs iconv so I threw all away and installed Macports (now I have macports <strong>and</strong> fink), and am trying to compile php5.</p>
	<p>Wish me good luck.</p>

 ]]></content:encoded>
			<wfw:commentRss>http://tempe.st/2008/03/for-the-first-time-ever-apple-failed-me-a-php-horror-story-on-mac-os-x/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>The battle of the languages part II</title>
		<link>http://tempe.st/2007/05/the-battle-of-the-languages-part-ii/</link>
		<comments>http://tempe.st/2007/05/the-battle-of-the-languages-part-ii/#comments</comments>
		<pubDate>Wed, 23 May 2007 15:41:21 +0000</pubDate>
		<dc:creator>Giovanni Intini</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Lua]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://tempe.st/2007/05/the-battle-of-the-languages-part-ii/</guid>
		<description><![CDATA[My previous post about a programming contest I had with my friends was wildly popular. Much much more than I even thought possible. I started with a simple comparison of PHP, C, Ruby, Erlang and Javascript and ended up with lots of comments where people posted interesting implementations in more and more languages, even obscure [...]]]></description>
			<content:encoded><![CDATA[	<p><a href="http://tempe.st/2007/05/erlang-ruby-and-php-battle-it-out">My previous post</a> about a programming contest I had with my friends was wildly popular. Much much more than I even thought possible.</p>
	<p>I started with a simple comparison of PHP, C, Ruby, Erlang and Javascript and ended up with lots of comments where people posted interesting implementations in more and more languages, even obscure ones (to me) like Haskell and Ocaml.</p>
	<p>I owe everyone a fairer benchmark so I will do the test again, this time testing the following languages:</p>
	<ul>
		<li>C</li>
		<li>Common Lisp</li>
		<li>Erlang</li>
		<li>Haskell</li>
		<li>Javascript</li>
		<li>Java</li>
		<li>Ocaml</li>
		<li>Perl</li>
		<li>PHP</li>
		<li>Python</li>
		<li>Ruby</li>
	</ul>
	<p>I need submissions for most of these languages, and I actually am quite open to submissions for the languages I speak <img src='http://tempe.st/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
	<p>The rules are simple, the program has to store the results in an array (not just count them) and has to run without any strange libraries or compilers or compiler switches. To avoid interpreter starting time problems, please submit programs that autotime themselves.</p>
	<p>As usual we&#8217;ll find the pythagorean triplets up to 5000. The reference implementation is the following, in Ruby:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">t = <span style="color:#CC00FF; font-weight:bold;">Time</span>.<span style="color:#9900CC;">now</span>
result = <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006600; font-weight:bold;">&#93;</span>
<span style="color:#006666;">2</span>.<span style="color:#9900CC;">upto</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006666;">5000</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>c<span style="color:#006600; font-weight:bold;">|</span> 
  <span style="color:#006666;">1</span>.<span style="color:#9900CC;">upto</span><span style="color:#006600; font-weight:bold;">&#40;</span>c<span style="color:#006600; font-weight:bold;">-</span><span style="color:#006666;">1</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>b<span style="color:#006600; font-weight:bold;">|</span>
    a = <span style="color:#CC00FF; font-weight:bold;">Math</span>.<span style="color:#9900CC;">sqrt</span><span style="color:#006600; font-weight:bold;">&#40;</span>c<span style="color:#006600; font-weight:bold;">*</span>c <span style="color:#006600; font-weight:bold;">-</span> b<span style="color:#006600; font-weight:bold;">*</span>b<span style="color:#006600; font-weight:bold;">&#41;</span>
    result <span style="color:#006600; font-weight:bold;">&lt;&lt;</span> <span style="color:#006600; font-weight:bold;">&#91;</span>a.<span style="color:#9900CC;">to_i</span>, b, c<span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color:#9966CC; font-weight:bold;">if</span> a.<span style="color:#9900CC;">to_i</span> == a 
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#CC00FF; font-weight:bold;">Time</span>.<span style="color:#9900CC;">now</span> <span style="color:#006600; font-weight:bold;">-</span> t</pre></div></div>

	<p>This code takes 15.70s to run on my macbook pro. </p>
	<p>Now it&#8217;s your turn!</p>
	<p><strong>Update:</strong> Lua version by Sindisil</p>

<div class="wp_syntax"><div class="code"><pre class="lua" style="font-family:monospace;"><span style="color: #b1b100;">local</span> tt <span style="color: #66cc66;">=</span> <span style="color: #b1b100;">os.clock</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #b1b100;">local</span> result <span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">&#125;</span>
<span style="color: #b1b100;">local</span> c
  <span style="color: #b1b100;">for</span> c <span style="color: #66cc66;">=</span> <span style="color: #cc66cc;">2</span>, <span style="color: #cc66cc;">5000</span> <span style="color: #b1b100;">do</span>
    <span style="color: #b1b100;">local</span> b
    <span style="color: #b1b100;">for</span> b <span style="color: #66cc66;">=</span> <span style="color: #cc66cc;">1</span>, c-<span style="color: #cc66cc;">1</span> <span style="color: #b1b100;">do</span>
      <span style="color: #b1b100;">local</span> a <span style="color: #66cc66;">=</span> <span style="color: #b1b100;">math.sqrt</span><span style="color: #66cc66;">&#40;</span>c<span style="color: #66cc66;">*</span>c - b<span style="color: #66cc66;">*</span>b<span style="color: #66cc66;">&#41;</span>
      <span style="color: #b1b100;">if</span> a <span style="color: #66cc66;">==</span> <span style="color: #b1b100;">math.floor</span><span style="color: #66cc66;">&#40;</span>a<span style="color: #66cc66;">&#41;</span> <span style="color: #b1b100;">then</span>
      result<span style="color: #66cc66;">&#91;</span>#result+<span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#123;</span> a, b, c <span style="color: #66cc66;">&#125;</span>
    <span style="color: #b1b100;">end</span>
  <span style="color: #b1b100;">end</span>
<span style="color: #b1b100;">end</span>
<span style="color: #b1b100;">print</span><span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">os.clock</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> - tt<span style="color: #66cc66;">&#41;</span></pre></div></div>

	<p>It takes 5.48s to run on my box.</p>
	<p><strong>Update:</strong> new Ruby version.</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">include</span> <span style="color:#CC00FF; font-weight:bold;">Math</span>
&nbsp;
a, b, c = <span style="color:#006666;">0</span>
result = <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006600; font-weight:bold;">&#93;</span>
<span style="color:#006666;">2</span>.<span style="color:#9900CC;">upto</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006666;">5000</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>c<span style="color:#006600; font-weight:bold;">|</span> 
  d = c <span style="color:#006600; font-weight:bold;">*</span> c
  <span style="color:#006666;">1</span>.<span style="color:#9900CC;">upto</span><span style="color:#006600; font-weight:bold;">&#40;</span>c<span style="color:#006600; font-weight:bold;">-</span><span style="color:#006666;">1</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>b<span style="color:#006600; font-weight:bold;">|</span>
    a = sqrt<span style="color:#006600; font-weight:bold;">&#40;</span>d <span style="color:#006600; font-weight:bold;">-</span> b<span style="color:#006600; font-weight:bold;">*</span>b<span style="color:#006600; font-weight:bold;">&#41;</span>
    result <span style="color:#006600; font-weight:bold;">&lt;&lt;</span> <span style="color:#006600; font-weight:bold;">&#91;</span>a.<span style="color:#9900CC;">floor</span>, b, c<span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color:#9966CC; font-weight:bold;">if</span> a.<span style="color:#9900CC;">floor</span> == a 
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#CC00FF; font-weight:bold;">Process</span>.<span style="color:#9900CC;">times</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">0</span><span style="color:#006600; font-weight:bold;">&#93;</span></pre></div></div>

	<p>Following Gabriele Renzi&#8217;s suggestions we now have a faster ruby version: 12.30s</p>
	<p><strong>Update:</strong> faster Lua version from Chris Swetenham, it runs in 3.44s</p>

<div class="wp_syntax"><div class="code"><pre class="lua" style="font-family:monospace;"><span style="color: #b1b100;">local</span> tt <span style="color: #66cc66;">=</span> <span style="color: #b1b100;">os.clock</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #b1b100;">local</span> result <span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">&#125;</span>
<span style="color: #b1b100;">local</span> c
<span style="color: #b1b100;">local</span> n <span style="color: #66cc66;">=</span> <span style="color: #cc66cc;">1</span>
<span style="color: #b1b100;">local</span> <span style="color: #b1b100;">math</span> <span style="color: #66cc66;">=</span> <span style="color: #b1b100;">math</span>
<span style="color: #b1b100;">local</span> <span style="color: #b1b100;">sqrt</span> <span style="color: #66cc66;">=</span> <span style="color: #b1b100;">math.sqrt</span>
<span style="color: #b1b100;">local</span> <span style="color: #b1b100;">floor</span> <span style="color: #66cc66;">=</span> <span style="color: #b1b100;">math.floor</span>
&nbsp;
<span style="color: #b1b100;">for</span> c <span style="color: #66cc66;">=</span> <span style="color: #cc66cc;">2</span>, <span style="color: #cc66cc;">5000</span> <span style="color: #b1b100;">do</span>
  <span style="color: #b1b100;">local</span> b
  <span style="color: #b1b100;">for</span> b <span style="color: #66cc66;">=</span> <span style="color: #cc66cc;">1</span>, c-<span style="color: #cc66cc;">1</span> <span style="color: #b1b100;">do</span>
    <span style="color: #b1b100;">local</span> a <span style="color: #66cc66;">=</span> <span style="color: #b1b100;">sqrt</span><span style="color: #66cc66;">&#40;</span>c<span style="color: #66cc66;">*</span>c - b<span style="color: #66cc66;">*</span>b<span style="color: #66cc66;">&#41;</span>
    <span style="color: #b1b100;">if</span> a <span style="color: #66cc66;">==</span> <span style="color: #b1b100;">floor</span><span style="color: #66cc66;">&#40;</span>a<span style="color: #66cc66;">&#41;</span> <span style="color: #b1b100;">then</span>
      result<span style="color: #66cc66;">&#91;</span>n<span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#123;</span> a, b, c <span style="color: #66cc66;">&#125;</span>
      n <span style="color: #66cc66;">=</span> n + <span style="color: #cc66cc;">1</span>
    <span style="color: #b1b100;">end</span>
  <span style="color: #b1b100;">end</span>
<span style="color: #b1b100;">end</span>
&nbsp;
<span style="color: #b1b100;">print</span><span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">os.clock</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> - tt<span style="color: #66cc66;">&#41;</span></pre></div></div>

	<p><strong>Update:</strong> PHP version by <a href="http://fullo.net">Fullo</a></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$start</span> <span style="color: #339933;">=</span> <span style="color: #990000;">microtime</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$a</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$b</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$c</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$result</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$c</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">2</span><span style="color: #339933;">;</span> <span style="color: #000088;">$c</span> <span style="color: #339933;">&lt;=</span> <span style="color: #cc66cc;">5000</span><span style="color: #339933;">;</span> <span style="color: #000088;">$c</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$b</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span> <span style="color: #000088;">$b</span> <span style="color: #339933;">&lt;</span> <span style="color: #000088;">$c</span><span style="color: #339933;">;</span> <span style="color: #000088;">$b</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$a</span> <span style="color: #339933;">=</span> <span style="color: #990000;">sqrt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$c</span><span style="color: #339933;">*</span><span style="color: #000088;">$c</span> <span style="color: #339933;">-</span> <span style="color: #000088;">$b</span><span style="color: #339933;">*</span><span style="color: #000088;">$b</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">intval</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$a</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #000088;">$a</span><span style="color: #009900;">&#41;</span> 
       <span style="color: #000088;">$result</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$a</span><span style="color: #339933;">,</span><span style="color: #000088;">$b</span><span style="color: #339933;">,</span><span style="color: #000088;">$c</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>              
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">microtime</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">-</span> <span style="color: #000088;">$start</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

	<p>It runs in 9.73s.</p>
	<p><strong>Update:</strong> Python version from ludo, it runs in 11.2s</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">from</span> <span style="color: #dc143c;">time</span> <span style="color: #ff7700;font-weight:bold;">import</span> clock
&nbsp;
start = clock<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">from</span> <span style="color: #dc143c;">math</span> <span style="color: #ff7700;font-weight:bold;">import</span> sqrt
&nbsp;
results = <span style="color: black;">&#91;</span><span style="color: black;">&#93;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">for</span> c <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">xrange</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">2</span>, <span style="color: #ff4500;">5001</span><span style="color: black;">&#41;</span>:
  d = c <span style="color: #66cc66;">*</span> c
  <span style="color: #ff7700;font-weight:bold;">for</span> b <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">xrange</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">1</span>, c<span style="color: black;">&#41;</span>:
    a = sqrt<span style="color: black;">&#40;</span>d - b <span style="color: #66cc66;">*</span> b<span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">if</span> a <span style="color: #66cc66;">%</span> <span style="color: #ff4500;">1</span> == <span style="color: #ff4500;">0.0</span>:
      results.<span style="color: black;">append</span><span style="color: black;">&#40;</span><span style="color: black;">&#40;</span>a, b, c<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">print</span> clock<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span> - start</pre></div></div>

	<p>The results for now:</p>
	<ol>
		<li>Lua 3.44</li>
		<li>PHP 9.73</li>
		<li>Python 11.20</li>
		<li>Ruby 12.30</li>
	</ol>


 ]]></content:encoded>
			<wfw:commentRss>http://tempe.st/2007/05/the-battle-of-the-languages-part-ii/feed/</wfw:commentRss>
		<slash:comments>31</slash:comments>
		</item>
		<item>
		<title>PHP @ Yahoo!</title>
		<link>http://tempe.st/2007/05/php-yahoo/</link>
		<comments>http://tempe.st/2007/05/php-yahoo/#comments</comments>
		<pubDate>Sat, 19 May 2007 15:46:26 +0000</pubDate>
		<dc:creator>Giovanni Intini</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Yahoo]]></category>

		<guid isPermaLink="false">http://tempe.st/2007/05/php-yahoo/</guid>
		<description><![CDATA[As I said in my last post yesterday I attended PHP Day, mainly for the presentation given by my friend Federico Feroldi, Senior Architect Engineer at an important internet company (not the most important one though). The presentation was really nice, because it&#8217;s an insight in Yahoo&#8217;s architecture and it&#8217;s helpful to understand certain best [...]]]></description>
			<content:encoded><![CDATA[	<p>As I said in my last post yesterday I attended PHP Day, mainly for the presentation given by my friend <a href="http://pixzone.com">Federico Feroldi</a>, Senior Architect Engineer at an <a href="http://yahoo.com">important internet company</a> (not <a href="http://google.com">the most important one</a> though).</p>
	<p>The presentation was really nice, because it&#8217;s an insight in Yahoo&#8217;s architecture and it&#8217;s helpful to understand certain best practices for really-high traffic websites.</p>
	<p>You can find the slides <a href="http://www.pixzone.com/blog/225/phpday-2007-is-over">here</a>.</p>

 ]]></content:encoded>
			<wfw:commentRss>http://tempe.st/2007/05/php-yahoo/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Erlang, Ruby and PHP battle it out!</title>
		<link>http://tempe.st/2007/05/erlang-ruby-and-php-battle-it-out/</link>
		<comments>http://tempe.st/2007/05/erlang-ruby-and-php-battle-it-out/#comments</comments>
		<pubDate>Sat, 19 May 2007 10:21:23 +0000</pubDate>
		<dc:creator>Giovanni Intini</dc:creator>
				<category><![CDATA[Erlang]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://tempe.st/2007/05/erlang-ruby-and-php-battle-it-out/</guid>
		<description><![CDATA[Update: here&#8217;s the followup! Yesterday I attended PHP Day, in the beautiful city of Verona, and while going there by train, together with my friend Federico Feroldi, I told him that in a test I made a week ago Erlang was much slower than ruby in finding pythagorean triplets. That was a partial lie, since [...]]]></description>
			<content:encoded><![CDATA[	<p><strong>Update</strong>: <a href="http://tempe.st/2007/05/the-battle-of-the-languages-part-ii">here&#8217;s the followup!</a></p>
	<p>Yesterday I attended <a href="http://www.phpday.it/site">PHP Day</a>, in the beautiful city of Verona, and while going there by train, together with my friend <a href="http://www.pixzone.com/blog">Federico Feroldi</a>, I told him that in a test I made a week ago Erlang was much slower than ruby in finding <a href="http://en.wikipedia.org/wiki/Pythagorean_triple">pythagorean triplets</a>. </p>
	<p>That was a partial lie, since the ruby implementation was somewhat optimized, while the erlang implementation wasn&#8217;t at all. So we decided to rewrite both programs using the same optimized algorithm and then test their speeds.</p>
	<p>This is the ruby implementation of a method that counts the number of pythagorean triplets up to N:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">def</span> pythag<span style="color:#006600; font-weight:bold;">&#40;</span>n<span style="color:#006600; font-weight:bold;">&#41;</span>
  result = <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006600; font-weight:bold;">&#93;</span>
  <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006666;">2</span>..<span style="color:#9900CC;">n</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>c<span style="color:#006600; font-weight:bold;">|</span> 
    <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006666;">1</span>...<span style="color:#9900CC;">c</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>b<span style="color:#006600; font-weight:bold;">|</span>
      a = <span style="color:#CC00FF; font-weight:bold;">Math</span>.<span style="color:#9900CC;">sqrt</span><span style="color:#006600; font-weight:bold;">&#40;</span>c<span style="color:#006600; font-weight:bold;">*</span>c <span style="color:#006600; font-weight:bold;">-</span> b<span style="color:#006600; font-weight:bold;">*</span>b<span style="color:#006600; font-weight:bold;">&#41;</span>
      result <span style="color:#006600; font-weight:bold;">&lt;&lt;</span> <span style="color:#006600; font-weight:bold;">&#91;</span>a.<span style="color:#9900CC;">to_i</span>, b, c<span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color:#9966CC; font-weight:bold;">if</span> a.<span style="color:#9900CC;">to_i</span> == a 
    <span style="color:#9966CC; font-weight:bold;">end</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
  result
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

	<p>Then we coded it in Erlang. The code I&#8217;m going to show you is more complex than the ruby code because we took advantage of the parallelization features of the Erlang language:</p>

<div class="wp_syntax"><div class="code"><pre class="erlang" style="font-family:monospace;"><span style="color: #014ea4;">-</span><span style="color: #5400b3;">module</span><span style="color: #109ab8;">&#40;</span>pythag<span style="color: #109ab8;">&#41;</span><span style="color: #6bb810;">.</span>
<span style="color: #014ea4;">-</span><span style="color: #5400b3;">export</span><span style="color: #109ab8;">&#40;</span><span style="color: #109ab8;">&#91;</span>bard<span style="color: #014ea4;">/</span><span style="color: #ff9600;">1</span><span style="color: #6bb810;">,</span> pbard<span style="color: #014ea4;">/</span><span style="color: #ff9600;">1</span><span style="color: #109ab8;">&#93;</span><span style="color: #109ab8;">&#41;</span><span style="color: #6bb810;">.</span>
&nbsp;
<span style="color: #ff3c00;">my_is_integer</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">X</span><span style="color: #109ab8;">&#41;</span> <span style="color: #6bb810;">-&gt;</span>
  <span style="color: #fa6fff;">round</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">X</span><span style="color: #109ab8;">&#41;</span> <span style="color: #014ea4;">==</span> <span style="color: #45b3e6;">X</span><span style="color: #6bb810;">.</span>
&nbsp;
<span style="color: #ff3c00;">pbard</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">N</span><span style="color: #109ab8;">&#41;</span> <span style="color: #6bb810;">-&gt;</span>
  <span style="color: #ff3c00;">pmap</span><span style="color: #109ab8;">&#40;</span><span style="color: #186895;">fun</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">C</span><span style="color: #109ab8;">&#41;</span> <span style="color: #6bb810;">-&gt;</span> 
              <span style="color: #109ab8;">&#91;</span>
               <span style="color: #109ab8;">&#123;</span><span style="color: #45b3e6;">C</span><span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">B</span><span style="color: #6bb810;">,</span> <span style="color: #fa6fff;">trunc</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">A</span><span style="color: #109ab8;">&#41;</span><span style="color: #109ab8;">&#125;</span> <span style="color: #014ea4;">||</span> 
                <span style="color: #45b3e6;">B</span> <span style="color: #014ea4;">&lt;-</span> <span style="color: #ff4e18;">lists</span>:<span style="color: #ff3c00;">seq</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">C</span><span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">N</span><span style="color: #109ab8;">&#41;</span><span style="color: #6bb810;">,</span> 
                <span style="color: #45b3e6;">A</span> <span style="color: #014ea4;">&lt;-</span> <span style="color: #109ab8;">&#91;</span><span style="color: #ff4e18;">math</span>:<span style="color: #ff3c00;">sqrt</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">C</span><span style="color: #014ea4;">*</span><span style="color: #45b3e6;">C</span> <span style="color: #014ea4;">+</span> <span style="color: #45b3e6;">B</span><span style="color: #014ea4;">*</span><span style="color: #45b3e6;">B</span><span style="color: #109ab8;">&#41;</span><span style="color: #109ab8;">&#93;</span><span style="color: #6bb810;">,</span> <span style="color: #ff3c00;">my_is_integer</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">A</span><span style="color: #109ab8;">&#41;</span> 
              <span style="color: #109ab8;">&#93;</span>
            <span style="color: #186895;">end</span><span style="color: #6bb810;">,</span> 
            <span style="color: #ff4e18;">lists</span>:<span style="color: #ff3c00;">seq</span><span style="color: #109ab8;">&#40;</span><span style="color: #ff9600;">2</span><span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">N</span><span style="color: #109ab8;">&#41;</span><span style="color: #109ab8;">&#41;</span><span style="color: #6bb810;">.</span>
&nbsp;
<span style="color: #ff3c00;">bard</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">N</span><span style="color: #109ab8;">&#41;</span> <span style="color: #6bb810;">-&gt;</span>
  <span style="color: #ff4e18;">lists</span>:<span style="color: #ff3c00;">map</span><span style="color: #109ab8;">&#40;</span><span style="color: #186895;">fun</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">C</span><span style="color: #109ab8;">&#41;</span> <span style="color: #6bb810;">-&gt;</span> 
              <span style="color: #109ab8;">&#91;</span>
               <span style="color: #109ab8;">&#123;</span><span style="color: #45b3e6;">C</span><span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">B</span><span style="color: #6bb810;">,</span> <span style="color: #fa6fff;">trunc</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">A</span><span style="color: #109ab8;">&#41;</span><span style="color: #109ab8;">&#125;</span> <span style="color: #014ea4;">||</span> 
                <span style="color: #45b3e6;">B</span> <span style="color: #014ea4;">&lt;-</span> <span style="color: #ff4e18;">lists</span>:<span style="color: #ff3c00;">seq</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">C</span><span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">N</span><span style="color: #109ab8;">&#41;</span><span style="color: #6bb810;">,</span> 
                <span style="color: #45b3e6;">A</span> <span style="color: #014ea4;">&lt;-</span> <span style="color: #109ab8;">&#91;</span><span style="color: #ff4e18;">math</span>:<span style="color: #ff3c00;">sqrt</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">C</span><span style="color: #014ea4;">*</span><span style="color: #45b3e6;">C</span> <span style="color: #014ea4;">+</span> <span style="color: #45b3e6;">B</span><span style="color: #014ea4;">*</span><span style="color: #45b3e6;">B</span><span style="color: #109ab8;">&#41;</span><span style="color: #109ab8;">&#93;</span><span style="color: #6bb810;">,</span> <span style="color: #ff3c00;">my_is_integer</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">A</span><span style="color: #109ab8;">&#41;</span> 
              <span style="color: #109ab8;">&#93;</span>
            <span style="color: #186895;">end</span><span style="color: #6bb810;">,</span> 
            <span style="color: #ff4e18;">lists</span>:<span style="color: #ff3c00;">seq</span><span style="color: #109ab8;">&#40;</span><span style="color: #ff9600;">2</span><span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">N</span><span style="color: #109ab8;">&#41;</span><span style="color: #109ab8;">&#41;</span><span style="color: #6bb810;">.</span>
&nbsp;
<span style="color: #ff3c00;">pmap</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">F</span><span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">L</span><span style="color: #109ab8;">&#41;</span> <span style="color: #6bb810;">-&gt;</span> 
  <span style="color: #45b3e6;">S</span> <span style="color: #014ea4;">=</span> <span style="color: #fa6fff;">self</span><span style="color: #109ab8;">&#40;</span><span style="color: #109ab8;">&#41;</span><span style="color: #6bb810;">,</span> 
  <span style="color: #666666; font-style: italic;">%% make_ref() returns a unique reference </span>
  <span style="color: #666666; font-style: italic;">%% we'll match on this later </span>
  <span style="color: #45b3e6;">Ref</span> <span style="color: #014ea4;">=</span> <span style="color: #ff4e18;">erlang</span>:<span style="color: #fa6fff;">make_ref</span><span style="color: #109ab8;">&#40;</span><span style="color: #109ab8;">&#41;</span><span style="color: #6bb810;">,</span> 
  <span style="color: #45b3e6;">Pids</span> <span style="color: #014ea4;">=</span> <span style="color: #ff4e18;">lists</span>:<span style="color: #ff3c00;">map</span><span style="color: #109ab8;">&#40;</span><span style="color: #186895;">fun</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">I</span><span style="color: #109ab8;">&#41;</span> <span style="color: #6bb810;">-&gt;</span> 
                    <span style="color: #fa6fff;">spawn</span><span style="color: #109ab8;">&#40;</span><span style="color: #186895;">fun</span><span style="color: #109ab8;">&#40;</span><span style="color: #109ab8;">&#41;</span> <span style="color: #6bb810;">-&gt;</span> <span style="color: #ff3c00;">do_f</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">S</span><span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">Ref</span><span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">F</span><span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">I</span><span style="color: #109ab8;">&#41;</span> <span style="color: #186895;">end</span><span style="color: #109ab8;">&#41;</span> 
             <span style="color: #186895;">end</span><span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">L</span><span style="color: #109ab8;">&#41;</span><span style="color: #6bb810;">,</span> 
  <span style="color: #666666; font-style: italic;">%% gather the results </span>
  <span style="color: #ff3c00;">gather</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">Pids</span><span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">Ref</span><span style="color: #109ab8;">&#41;</span><span style="color: #6bb810;">.</span> 
&nbsp;
<span style="color: #ff3c00;">do_f</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">Parent</span><span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">Ref</span><span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">F</span><span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">I</span><span style="color: #109ab8;">&#41;</span> <span style="color: #6bb810;">-&gt;</span> 
  <span style="color: #45b3e6;">Parent</span> <span style="color: #014ea4;">!</span> <span style="color: #109ab8;">&#123;</span><span style="color: #fa6fff;">self</span><span style="color: #109ab8;">&#40;</span><span style="color: #109ab8;">&#41;</span><span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">Ref</span><span style="color: #6bb810;">,</span> <span style="color: #109ab8;">&#40;</span><span style="color: #186895;">catch</span> <span style="color: #45b3e6;">F</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">I</span><span style="color: #109ab8;">&#41;</span><span style="color: #109ab8;">&#41;</span><span style="color: #109ab8;">&#125;</span><span style="color: #6bb810;">.</span> 
<span style="color: #ff3c00;">gather</span><span style="color: #109ab8;">&#40;</span><span style="color: #109ab8;">&#91;</span><span style="color: #45b3e6;">Pid</span>|T<span style="color: #109ab8;">&#93;</span><span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">Ref</span><span style="color: #109ab8;">&#41;</span> <span style="color: #6bb810;">-&gt;</span> 
  <span style="color: #186895;">receive</span> 
    <span style="color: #109ab8;">&#123;</span><span style="color: #45b3e6;">Pid</span><span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">Ref</span><span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">Ret</span><span style="color: #109ab8;">&#125;</span> <span style="color: #6bb810;">-&gt;</span> <span style="color: #109ab8;">&#91;</span><span style="color: #45b3e6;">Ret</span>|<span style="color: #ff3c00;">gather</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">T</span><span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">Ref</span><span style="color: #109ab8;">&#41;</span><span style="color: #109ab8;">&#93;</span> 
  <span style="color: #186895;">end</span><span style="color: #6bb810;">;</span> 
<span style="color: #ff3c00;">gather</span><span style="color: #109ab8;">&#40;</span><span style="color: #109ab8;">&#91;</span><span style="color: #109ab8;">&#93;</span><span style="color: #6bb810;">,</span> <span style="color: #45b3e6;">_</span><span style="color: #109ab8;">&#41;</span> <span style="color: #6bb810;">-&gt;</span> 
  <span style="color: #109ab8;">&#91;</span><span style="color: #109ab8;">&#93;</span><span style="color: #6bb810;">.</span></pre></div></div>

	<p>The pythag function has been named bard, as in <a href="http://hyperstruct.net">The Bard</a> <img src='http://tempe.st/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> <br />
The pbard function fires up a thread for each iteration of the outer loop and then gathers all the result back. This allows for up to 50% performance increase when using dual core CPUs (like my Macbook Pro <img src='http://tempe.st/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> ).</p>
	<p>Once we coded it in two languages we couldn&#8217;t stop, so here&#8217;s a PHP implementation, a Javascript one and, last, but not least, a C implementation, because you can never forget C when you need speed <img src='http://tempe.st/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
	<p>PHP:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$i</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$c</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">2</span><span style="color: #339933;">;</span> <span style="color: #000088;">$c</span> <span style="color: #339933;">&lt;=</span> <span style="color: #cc66cc;">5000</span><span style="color: #339933;">;</span> <span style="color: #000088;">$c</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$b</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span> <span style="color: #000088;">$b</span> <span style="color: #339933;">&lt;</span> <span style="color: #000088;">$c</span><span style="color: #339933;">;</span> <span style="color: #000088;">$b</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$a</span> <span style="color: #339933;">=</span> <span style="color: #990000;">sqrt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$c</span><span style="color: #339933;">*</span><span style="color: #000088;">$c</span> <span style="color: #339933;">-</span> <span style="color: #000088;">$b</span><span style="color: #339933;">*</span><span style="color: #000088;">$b</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">is_int</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$a</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #000088;">$i</span><span style="color: #339933;">++;</span>
    <span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">print</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$i</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

	<p>JavaScript:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> pythag<span style="color: #009900;">&#40;</span>n<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #003366; font-weight: bold;">var</span> a<span style="color: #339933;">,</span>b<span style="color: #339933;">,</span>c<span style="color: #339933;">,</span>i
  <span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>c <span style="color: #339933;">=</span> <span style="color: #CC0000;">2</span><span style="color: #339933;">;</span> c <span style="color: #339933;">&lt;=</span> n<span style="color: #339933;">;</span> c<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>b <span style="color: #339933;">=</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">;</span> b <span style="color: #339933;">&lt;</span> c<span style="color: #339933;">;</span> b<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      a <span style="color: #339933;">=</span> Math.<span style="color: #660066;">sqrt</span><span style="color: #009900;">&#40;</span>c<span style="color: #339933;">*</span>c <span style="color: #339933;">-</span> b<span style="color: #339933;">*</span>b<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>Math.<span style="color: #660066;">floor</span><span style="color: #009900;">&#40;</span>a<span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> a<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        i<span style="color: #339933;">++;</span>
      <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #000066; font-weight: bold;">return</span> i<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

	<p>C:</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #339933;">#include &lt;stdio.h&gt;</span>
<span style="color: #339933;">#include &lt;math.h&gt;</span>
&nbsp;
<span style="color: #339933;">#define MAX 5000</span>
&nbsp;
<span style="color: #993333;">int</span> main<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #993333;">double</span> c<span style="color: #339933;">,</span> b<span style="color: #339933;">;</span>
  <span style="color: #993333;">int</span> i <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
  <span style="color: #993333;">double</span> a<span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span>c <span style="color: #339933;">=</span> <span style="color: #0000dd;">2</span><span style="color: #339933;">;</span> c <span style="color: #339933;">&lt;=</span> MAX<span style="color: #339933;">;</span> c<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span>b <span style="color: #339933;">=</span> <span style="color: #0000dd;">1</span><span style="color: #339933;">;</span> b <span style="color: #339933;">&lt;</span> c<span style="color: #339933;">;</span> b<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      a <span style="color: #339933;">=</span> sqrt<span style="color: #009900;">&#40;</span>c<span style="color: #339933;">*</span>c <span style="color: #339933;">-</span> b<span style="color: #339933;">*</span>b<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>trunc<span style="color: #009900;">&#40;</span>a<span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> a<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        i<span style="color: #339933;">++;</span>
      <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;%d<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> i<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

	<p>To test the various relative speeds I ran them from the shell using time (php ruby and c), or used the internal timer (erlang), or ran them in firefox (js only actually).</p>
	<p>The results were interesting. At the first run, using 5000 as N in the pythag functions the order was:</p>
	<ol>
		<li>C (obviously): 0.40s</li>
		<li>Erlang (smp): 3.95s</li>
		<li>Erlang (non-smp): 5.66s</li>
		<li>Ruby: 15.31s</li>
		<li>PHP: 19s (or so)</li>
		<li>Javascript: couldn&#8217;t even finish running because firefox said it was taking too much time</li>
	</ol>
	<p><a href="http://fullo.net">Fullo</a> passed by and asked what we were doing, I told him I was testing languages and that PHP was dog-slow. He said it couldn&#8217;t be and asked me what version of PHP I was using. I checked and it was PHP 4.x.x. </p>
	<p>After downloading and compiling PHP5 I ran the tests again and the final result was this:</p>
	<ol>
		<li>C (obviously): 0.40s</li>
		<li>Erlang (smp): 3.95s</li>
		<li>Erlang (non-smp): 5.66s</li>
		<li>PHP5: 8.9s (or so)</li>
		<li>Ruby: 15.31s</li>
		<li>Javascript: couldn&#8217;t even finish running because firefox said it was taking too much time</li>
	</ol>
	<p>Now the numbers make sense. Doing these comparations was a nice experience, because when you implement the same thing in different languages you always learn something about optimization and code beauty.</p>


 ]]></content:encoded>
			<wfw:commentRss>http://tempe.st/2007/05/erlang-ruby-and-php-battle-it-out/feed/</wfw:commentRss>
		<slash:comments>48</slash:comments>
		</item>
	</channel>
</rss>

