<?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: Python as a PHP replacement?</title>
	<atom:link href="http://blog.curiasolutions.com/2009/11/python-as-a-php-replacement/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.curiasolutions.com/2009/11/python-as-a-php-replacement/</link>
	<description>Technology thoughts and ideas</description>
	<lastBuildDate>Tue, 13 Jul 2010 02:50:28 -0700</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Julius H from San Jose, ca</title>
		<link>http://blog.curiasolutions.com/2009/11/python-as-a-php-replacement/comment-page-1/#comment-139</link>
		<dc:creator>Julius H from San Jose, ca</dc:creator>
		<pubDate>Tue, 13 Jul 2010 02:50:28 +0000</pubDate>
		<guid isPermaLink="false">http://blog.curiasolutions.com/?p=637#comment-139</guid>
		<description>Wow! Thanks for the thorough explanation! Personally I am a bit of a newbie and was teaching myself python for application development, but wanted to eventually learn web developmen. So I thought I would have to eventually have to learn PHP to do this, reading this makes me more confident in Python and will save me time since I will not spend hours and hours of grueling study learning PHP. I will start from scratch figuring out how to deploy Python and hopefully by then the community will be bigger so I can ask around for meticulous question. 
THANKS A BUNCH!!!! =D</description>
		<content:encoded><![CDATA[<p>Wow! Thanks for the thorough explanation! Personally I am a bit of a newbie and was teaching myself python for application development, but wanted to eventually learn web developmen. So I thought I would have to eventually have to learn PHP to do this, reading this makes me more confident in Python and will save me time since I will not spend hours and hours of grueling study learning PHP. I will start from scratch figuring out how to deploy Python and hopefully by then the community will be bigger so I can ask around for meticulous question.<br />
THANKS A BUNCH!!!! =D</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nilesh</title>
		<link>http://blog.curiasolutions.com/2009/11/python-as-a-php-replacement/comment-page-1/#comment-90</link>
		<dc:creator>Nilesh</dc:creator>
		<pubDate>Fri, 30 Apr 2010 11:36:45 +0000</pubDate>
		<guid isPermaLink="false">http://blog.curiasolutions.com/?p=637#comment-90</guid>
		<description>Thank you for this summary, I was searching for something like this - step wise differences between PHP and Python. I am a PHP Programmer but something clicked my mind that Python may be faster than PHP in webdev. And finally it is true what I thought :) Thanks again.</description>
		<content:encoded><![CDATA[<p>Thank you for this summary, I was searching for something like this &#8211; step wise differences between PHP and Python. I am a PHP Programmer but something clicked my mind that Python may be faster than PHP in webdev. And finally it is true what I thought :) Thanks again.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: V</title>
		<link>http://blog.curiasolutions.com/2009/11/python-as-a-php-replacement/comment-page-1/#comment-52</link>
		<dc:creator>V</dc:creator>
		<pubDate>Sat, 05 Dec 2009 01:06:42 +0000</pubDate>
		<guid isPermaLink="false">http://blog.curiasolutions.com/?p=637#comment-52</guid>
		<description>Interesting post.

I&#039;ve been interested in Python for a while now, having spent almost a decade with PHP. Seems a rather nice language and I can certainly see its benefits over PHP.

However, I wonder about some things, for instance:

1. Being developed for web, PHP has some inherent solutions for common requirements like session management, fcgi interfacing. Those are done in C, in the core of PHP, while Python requires middleware written in Python (e.g Beaker, Paster&#039;s HTTP server or wsgi/fastcgi implementation).

I wonder if there is a significant performance hit for Python because of that.

It is true that there exists some theoretical threshold of app complexity above which PHP&#039;s requirement to bootstrap entire application (the part thereof required to process the request) becomes significant performance bottleneck compared to load-once apps like those written in Python, which offsets any speed benefits of C code inside PHP. But I wonder how significant this is in practice? Even the most complex app has little to do in PHP. They all wait on I/O of whatever sort, even if the request generates dozens or more queries (take Drupal modules for example, at some point there can be over a hundred of queries per request). It is the stateless nature of HTTP that brings all languages to the same level requiring &quot;third party&quot; intervention like memory cached session management or data layers, database I/O, etc..., and number crunching algorithms can anyways be moved to C both in Python and in PHP. That being the common denominator, the true differences are then shown in parts that are done in the language itself: in this case the aforementioned session management, fastcgi interfacing (or in Python, entire HTTP server written in Python -- Paster&#039;s), etc...

2. GIL worries me. While it is true that, especially for web applications, threads usually wait on I/O so GIL is not that much of a problem, I am not so convinced for practical implementations of apps that require performance and cache data wherever possible (reducing I/O wait). There, the GIL definitely impairs performance, but I wonder how significant?

Also, SMP deployment with PHP is as simple as instructing PHP to spawn more processes. I&#039;m assuming fastcgi implementation since Apache (and it&#039;s mod_php) should not coexist with &quot;performance&quot; in the same sentence. :)

It is as easy with Python (for instance using Paster), but each of those instances is interfaced with the web server through Python code, not C implemented code. Evenmoreso if proxying is used for load balancing.

So if syntactic sugar present in Python is not sufficient to move us from PHP to Python (and in my case, I can name two: decorators and indentation/lack-of-$;{}, everything else is more or else the same), is there anything else that Python can offer?</description>
		<content:encoded><![CDATA[<p>Interesting post.</p>
<p>I&#8217;ve been interested in Python for a while now, having spent almost a decade with PHP. Seems a rather nice language and I can certainly see its benefits over PHP.</p>
<p>However, I wonder about some things, for instance:</p>
<p>1. Being developed for web, PHP has some inherent solutions for common requirements like session management, fcgi interfacing. Those are done in C, in the core of PHP, while Python requires middleware written in Python (e.g Beaker, Paster&#8217;s HTTP server or wsgi/fastcgi implementation).</p>
<p>I wonder if there is a significant performance hit for Python because of that.</p>
<p>It is true that there exists some theoretical threshold of app complexity above which PHP&#8217;s requirement to bootstrap entire application (the part thereof required to process the request) becomes significant performance bottleneck compared to load-once apps like those written in Python, which offsets any speed benefits of C code inside PHP. But I wonder how significant this is in practice? Even the most complex app has little to do in PHP. They all wait on I/O of whatever sort, even if the request generates dozens or more queries (take Drupal modules for example, at some point there can be over a hundred of queries per request). It is the stateless nature of HTTP that brings all languages to the same level requiring &#8220;third party&#8221; intervention like memory cached session management or data layers, database I/O, etc&#8230;, and number crunching algorithms can anyways be moved to C both in Python and in PHP. That being the common denominator, the true differences are then shown in parts that are done in the language itself: in this case the aforementioned session management, fastcgi interfacing (or in Python, entire HTTP server written in Python &#8212; Paster&#8217;s), etc&#8230;</p>
<p>2. GIL worries me. While it is true that, especially for web applications, threads usually wait on I/O so GIL is not that much of a problem, I am not so convinced for practical implementations of apps that require performance and cache data wherever possible (reducing I/O wait). There, the GIL definitely impairs performance, but I wonder how significant?</p>
<p>Also, SMP deployment with PHP is as simple as instructing PHP to spawn more processes. I&#8217;m assuming fastcgi implementation since Apache (and it&#8217;s mod_php) should not coexist with &#8220;performance&#8221; in the same sentence. :)</p>
<p>It is as easy with Python (for instance using Paster), but each of those instances is interfaced with the web server through Python code, not C implemented code. Evenmoreso if proxying is used for load balancing.</p>
<p>So if syntactic sugar present in Python is not sufficient to move us from PHP to Python (and in my case, I can name two: decorators and indentation/lack-of-$;{}, everything else is more or else the same), is there anything else that Python can offer?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Seth</title>
		<link>http://blog.curiasolutions.com/2009/11/python-as-a-php-replacement/comment-page-1/#comment-51</link>
		<dc:creator>Seth</dc:creator>
		<pubDate>Tue, 01 Dec 2009 01:09:07 +0000</pubDate>
		<guid isPermaLink="false">http://blog.curiasolutions.com/?p=637#comment-51</guid>
		<description>Dave,

Thank you. Good question, and perhaps I will do a &quot;part 2&quot; of this post going into more detail about that.

In short I would suggest you check out a simple Python framework (&lt;a href=&quot;http://bottle.paws.de/&quot; target=&quot;_blank&quot; rel=&quot;nofollow&quot;&gt;Bottle&lt;/a&gt; is a great option) to familiarize yourself with how Python does things differently.

Like PHP, the Python interpreter process can be run with Apache (using &lt;a href=&quot;http://code.google.com/p/modwsgi/&quot; target=&quot;_blank&quot; rel=&quot;nofollow&quot;&gt;mod_wsgi&lt;/a&gt;). However, unlike PHP you will typically separate your &quot;controller&quot; and &quot;view&quot; code instead of writing HTML around &lt;? and ?&gt; type tags. While this may seem complicated at first, it actually lends itself to a better code layout. In PHP terms, it&#039;s much like the process of using &lt;a href=&quot;http://en.wikipedia.org/wiki/Smarty&quot; target=&quot;_blank&quot; rel=&quot;nofollow&quot;&gt;Smarty templates&lt;/a&gt; (PHP-only files as your &quot;business&quot; code, which then process and render your Smarty &quot;presentation&quot; code).

Several Python template options exist, with the most popular ones probably being &lt;a href=&quot;http://www.makotemplates.org/&quot; target=&quot;_blank&quot; rel=&quot;nofollow&quot;&gt;Mako&lt;/a&gt; (super-fast), &lt;a href=&quot;http://jinja.pocoo.org/2/&quot; target=&quot;_blank&quot; rel=&quot;nofollow&quot;&gt;Jinja&lt;/a&gt; (quick &amp; simple), and &lt;a href=&quot;http://genshi.edgewall.org/&quot; target=&quot;_blank&quot; rel=&quot;nofollow&quot;&gt;Genshi&lt;/a&gt; (slower but XML-based).

There are of course many options for deploying Python web applications, with mod_wsgi only being one of them. Typically during the building &amp; testing phase, you will run your Python web app on some sort of built-in WSGI implementation and load it locally (if you&#039;re familiar with Rails, it&#039;s like running your Rails app locally and loading it on port 3000).

Hope this helps!</description>
		<content:encoded><![CDATA[<p>Dave,</p>
<p>Thank you. Good question, and perhaps I will do a &#8220;part 2&#8243; of this post going into more detail about that.</p>
<p>In short I would suggest you check out a simple Python framework (<a href="http://bottle.paws.de/" target="_blank" rel="nofollow">Bottle</a> is a great option) to familiarize yourself with how Python does things differently.</p>
<p>Like PHP, the Python interpreter process can be run with Apache (using <a href="http://code.google.com/p/modwsgi/" target="_blank" rel="nofollow">mod_wsgi</a>). However, unlike PHP you will typically separate your &#8220;controller&#8221; and &#8220;view&#8221; code instead of writing HTML around &lt;? and ?&gt; type tags. While this may seem complicated at first, it actually lends itself to a better code layout. In PHP terms, it&#8217;s much like the process of using <a href="http://en.wikipedia.org/wiki/Smarty" target="_blank" rel="nofollow">Smarty templates</a> (PHP-only files as your &#8220;business&#8221; code, which then process and render your Smarty &#8220;presentation&#8221; code).</p>
<p>Several Python template options exist, with the most popular ones probably being <a href="http://www.makotemplates.org/" target="_blank" rel="nofollow">Mako</a> (super-fast), <a href="http://jinja.pocoo.org/2/" target="_blank" rel="nofollow">Jinja</a> (quick &#038; simple), and <a href="http://genshi.edgewall.org/" target="_blank" rel="nofollow">Genshi</a> (slower but XML-based).</p>
<p>There are of course many options for deploying Python web applications, with mod_wsgi only being one of them. Typically during the building &#038; testing phase, you will run your Python web app on some sort of built-in WSGI implementation and load it locally (if you&#8217;re familiar with Rails, it&#8217;s like running your Rails app locally and loading it on port 3000).</p>
<p>Hope this helps!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dave</title>
		<link>http://blog.curiasolutions.com/2009/11/python-as-a-php-replacement/comment-page-1/#comment-50</link>
		<dc:creator>Dave</dc:creator>
		<pubDate>Mon, 30 Nov 2009 21:05:03 +0000</pubDate>
		<guid isPermaLink="false">http://blog.curiasolutions.com/?p=637#comment-50</guid>
		<description>Nice summary.  How do I use python directly as a scripting language?  Is there something similar to having PHP run by apache, or is there a little more to it?</description>
		<content:encoded><![CDATA[<p>Nice summary.  How do I use python directly as a scripting language?  Is there something similar to having PHP run by apache, or is there a little more to it?</p>
]]></content:encoded>
	</item>
</channel>
</rss>
