<?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>Sun, 11 Sep 2011 16:00:11 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Markus</title>
		<link>http://blog.curiasolutions.com/2009/11/python-as-a-php-replacement/comment-page-1/#comment-646</link>
		<dc:creator>Markus</dc:creator>
		<pubDate>Mon, 27 Jun 2011 21:31:31 +0000</pubDate>
		<guid isPermaLink="false">http://blog.curiasolutions.com/?p=637#comment-646</guid>
		<description>&quot;Has the Python community really been that bad at promoting the strengths of Python for web development?&quot;

-&gt; Yes, somehow. It is really the marketing - this is the only part where we should learn from Ruby, how to hype and push something.. 

-&gt; And perhaps also a posterboy like David Heinemeier-Hanson is missing - instead of boygroup appeal our outstanding persons are more of the type &quot;lumberjack&quot; :) Just see this: http://www.flickr.com/photos/termie/sets/72157616044454732/ :)

I am just joking, but the truth is that the Python community sucks at marketing, and pushing more into the public.. It is frightening every time how less PHP and Ruby guys know from Python, and also how many misinformation is out there..

Blog posts like yours, for example the benchmarks where people can see how performant web stuff in Python is running, helps, but sometimes it has to be more than facts.

:)</description>
		<content:encoded><![CDATA[<p>&#8220;Has the Python community really been that bad at promoting the strengths of Python for web development?&#8221;</p>
<p>-&gt; Yes, somehow. It is really the marketing &#8211; this is the only part where we should learn from Ruby, how to hype and push something.. </p>
<p>-&gt; And perhaps also a posterboy like David Heinemeier-Hanson is missing &#8211; instead of boygroup appeal our outstanding persons are more of the type &#8220;lumberjack&#8221; :) Just see this: <a href="http://www.flickr.com/photos/termie/sets/72157616044454732/" rel="nofollow">http://www.flickr.com/photos/termie/sets/72157616044454732/</a> :)</p>
<p>I am just joking, but the truth is that the Python community sucks at marketing, and pushing more into the public.. It is frightening every time how less PHP and Ruby guys know from Python, and also how many misinformation is out there..</p>
<p>Blog posts like yours, for example the benchmarks where people can see how performant web stuff in Python is running, helps, but sometimes it has to be more than facts.</p>
<p>:)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alan</title>
		<link>http://blog.curiasolutions.com/2009/11/python-as-a-php-replacement/comment-page-1/#comment-640</link>
		<dc:creator>Alan</dc:creator>
		<pubDate>Mon, 20 Jun 2011 13:58:04 +0000</pubDate>
		<guid isPermaLink="false">http://blog.curiasolutions.com/?p=637#comment-640</guid>
		<description>V, I can understand where your concerns come from, but considering the performance difference between PHP and Python (hint: Python is faster), most of these aren&#039;t issues at all.

1. You&#039;ll find that performance-critical parts of Python libraries are often implemented in C, also. In fact, Python makes this easier because you can treat C extensions to Python just like regular Python libraries. If you ever really need to optimize your code beyond what Python lets you do, you can always fall back to C.

It&#039;s usually better to optimize other things first, though. The language is usually the last things you need to optimize in any given scenario.

You&#039;ll also note that servers like Paster are usually put behind a reverse proxy (Apache, nginx or lighttpd) that takes care of static files and thus reduces the load on the app. Some are faster than others, too. For most websites, you probably don&#039;t need to worry, though. Someone who should know these things once told me you can go a long way just using Python&#039;s built-in wsgiref server to run your wsgi apps.

2. The GIL shouldn&#039;t worry you. While there is a lot of drama about it, you probably won&#039;t encounter any such problems in practice. Most of the criticism is theoretical or only relevant for high-performance scenarios.

3. If the prospect of cleaner, more straight-forward code and a much saner object model (first-class functions, etc) can&#039;t convince you, nothing will. You should work with whatever language is easiest on your brain. For some people this is Python. For some people this is Ruby. Heck, for some people this is Perl.

You should give it a try, if only for the sake of learning something new and keeping your mind fresh (it&#039;s a good idea to try out new languages at least once per year to keep up with the times and broaden your horizon). Maybe you&#039;ll like it. Maybe you won&#039;t.

You should also try Ruby. It has a lot in common with Python but is completely different (if only in its philosophy).

This article seems to be aimed more at people who only stick with PHP because they don&#039;t know of any alternatives. So if you use PHP because you made a conscious and educated choice, more power to you. But if you only stick with PHP because you haven&#039;t written even a simple web app in another language, you should go and do that right now.</description>
		<content:encoded><![CDATA[<p>V, I can understand where your concerns come from, but considering the performance difference between PHP and Python (hint: Python is faster), most of these aren&#8217;t issues at all.</p>
<p>1. You&#8217;ll find that performance-critical parts of Python libraries are often implemented in C, also. In fact, Python makes this easier because you can treat C extensions to Python just like regular Python libraries. If you ever really need to optimize your code beyond what Python lets you do, you can always fall back to C.</p>
<p>It&#8217;s usually better to optimize other things first, though. The language is usually the last things you need to optimize in any given scenario.</p>
<p>You&#8217;ll also note that servers like Paster are usually put behind a reverse proxy (Apache, nginx or lighttpd) that takes care of static files and thus reduces the load on the app. Some are faster than others, too. For most websites, you probably don&#8217;t need to worry, though. Someone who should know these things once told me you can go a long way just using Python&#8217;s built-in wsgiref server to run your wsgi apps.</p>
<p>2. The GIL shouldn&#8217;t worry you. While there is a lot of drama about it, you probably won&#8217;t encounter any such problems in practice. Most of the criticism is theoretical or only relevant for high-performance scenarios.</p>
<p>3. If the prospect of cleaner, more straight-forward code and a much saner object model (first-class functions, etc) can&#8217;t convince you, nothing will. You should work with whatever language is easiest on your brain. For some people this is Python. For some people this is Ruby. Heck, for some people this is Perl.</p>
<p>You should give it a try, if only for the sake of learning something new and keeping your mind fresh (it&#8217;s a good idea to try out new languages at least once per year to keep up with the times and broaden your horizon). Maybe you&#8217;ll like it. Maybe you won&#8217;t.</p>
<p>You should also try Ruby. It has a lot in common with Python but is completely different (if only in its philosophy).</p>
<p>This article seems to be aimed more at people who only stick with PHP because they don&#8217;t know of any alternatives. So if you use PHP because you made a conscious and educated choice, more power to you. But if you only stick with PHP because you haven&#8217;t written even a simple web app in another language, you should go and do that right now.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: aardmaat</title>
		<link>http://blog.curiasolutions.com/2009/11/python-as-a-php-replacement/comment-page-1/#comment-585</link>
		<dc:creator>aardmaat</dc:creator>
		<pubDate>Sat, 12 Mar 2011 11:19:01 +0000</pubDate>
		<guid isPermaLink="false">http://blog.curiasolutions.com/?p=637#comment-585</guid>
		<description>great summary but I still have one question:
for a while I&#039;ve been thinking to switch to python on the web, because I already know some python for desktop development, but every time I try to do so, I get trapped into a world that&#039;s the exact opposite from the &#039;there should be one obvious way to do it&#039; philosophy:
it seems like there are like a million ways to use python for web development, of which only PyHP seems a little promising since I only do simple sites. unfortunately I use things like XAMPP and WAMPP on windows for developing, and it seems like PyHP is no option for that either, so what would be the best way for me to transfer?

I really like Python for desktop development, so I&#039;d like to use the nice Python syntax for web development, but I also really love the way PHP can be mixed with HTML.

thanks in advance</description>
		<content:encoded><![CDATA[<p>great summary but I still have one question:<br />
for a while I&#8217;ve been thinking to switch to python on the web, because I already know some python for desktop development, but every time I try to do so, I get trapped into a world that&#8217;s the exact opposite from the &#8216;there should be one obvious way to do it&#8217; philosophy:<br />
it seems like there are like a million ways to use python for web development, of which only PyHP seems a little promising since I only do simple sites. unfortunately I use things like XAMPP and WAMPP on windows for developing, and it seems like PyHP is no option for that either, so what would be the best way for me to transfer?</p>
<p>I really like Python for desktop development, so I&#8217;d like to use the nice Python syntax for web development, but I also really love the way PHP can be mixed with HTML.</p>
<p>thanks in advance</p>
]]></content:encoded>
	</item>
	<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>

