When the “Python Vs PHP” war matters
February 21st, 2008
Yesterday I had a meeting with a customer about a new site I should develop for them. Since they’re a book publisher, they wanted an online book store. Apart from the technical details (the site isn’t as simple as you may believe, they need a lot of not-so-easy-to-do stuff), the most important point we focused on is the fact that they have an internal IT technician that handles all their computer needs. If you’re asking yourself why this matters, keep reading:
- me (to be precise, my company) stopped development of PHP sites about one year ago in favor of Python
- we release the web site’s code to them
- for this project, we haven’t been asked any kind of future support; this means that when the site is finished, we won’t touch the product anymore (unless they don’t pay us to do the modifies they need)
- but they don’t want to pay us to these modifies, because they have their internal IT technician
- their technician knows only PHP (and he never even known the Python’s existence until yesterday)
So I had to illustrate why me and my company chosen Python for our web development needs, and here’s a summary of what I told them yesterday. Note that I’m not talking about why a language is better than the other, because this would move us in another direction, but why we chosen Python as our main programming language (even if this unconsciously lead us to say why, for us, Python is better than PHP, but that’s another story) :
- Time: remember that time is money. If I’d build an application in PHP, I’d spend about 1/3 of the time more if I’d develop the same application in Python
- Frameworks: nowadays all the popular languages have their web frameworks; Ruby has Ruby on Rails, PHP has Symfony, php.MVC, Python has Django, CherryPy, Pylons, and so on. But none of them (apart from rails, but we’re talking about PHP Vs Python) goes near to the completeness and functionality of django. And this take us at the previous point: less time in develop the same application
- Future modifies: even if for this project this isn’t the case, it’s much easier to modify a Python application than a PHP one due to the syntax of the language and its strong OOP orientation. You may argue that PHP 5 introduced a deep OOP support too, but that’s not the same thing and you know. PHP is born as procedural programming language, and even if we had OOP introduction in version 5, it doesn’t even comes near to Python under this point of view
With this I’m not saying that PHP is useless: what I mean is that Python is more convenient under the (our) business point of view. So if someone ask me why I use Python to do the same thing I can make with PHP, the answer will be: because with Python I can make the same thing in a shorter time and, consequently, with a lower budget.
Very interesting. I’ve been learning Python for two days.
We currently develop in PHP and I have been thinking about Ruby. I’m finding it difficult to find any reason to go with Ruby. The positives always seem to originate from Ruby developers who have never used another language. The negatives mostly come from PHP developers who have tried Ruby, but this may be due to OO blindness.
Personally, I think PHP is a bit clunky. Historically I have a lot of experience with a proprietary language, Magik, (used for GIS applications) that is very similar to Smalltalk, hence my interest in Ruby and Python. Also I remember (about 15 years ago) a colleague setting out to learn Python.
In your experience, is Python as versatile as PHP? There doesn’t seem to be anything I can’t do with PHP and I wouldn’t want to go with another language only to have to drop back into PHP for certain tasks.
Comment by leo — April 9th, 2008 at 15:17
Actually you can do with Python the same things you do with PHP. In addition you can use python scripts as standalone executables (even if PHP has a command line intepreter, it’s not very suitable for this purpose) and this is a plus that is very useful when you have to do some pre/post processing stuff (think at the GIS stuff you mentioned).
If you want additional modules, there are a lot of them around the web, just like pecl/pear (but assuming you’re in a shared hosting environment, python modules are not really an issue as could be pear for php).
Definitely I’m not thinking that PHP is useless, for simple purposes and lower-budget projects it’s still a must due to the fact that php hosting costs a lot less than python hosting, and because setting up a classic php-powered server is a straightforward procedure (setting up apache + mod_wsgi + python could be a pain in the ass sometimes), but I’m still loving python more as it’s saving me a lot of time in developing the same kind of applications I done until one year and half ago.
Comment by Giuliani Vito, Ivan — April 12th, 2008 at 13:48
LMAO.
Comment by john — July 31st, 2008 at 21:13
I don’t mean to nitpick, but this sentence made me cringe:
Ehm, no. No, it isn’t.
I guess you mean that PHP’s fundamental abstraction and unit of modularity is not the object, but the function. The term you are looking for might be procedural programming.
But PHP is a long way from real functional languages, both in features and mindset.
Comment by seb — August 15th, 2008 at 3:04
Gosh, you’re right. I know what functional languages are (I’ve done something in Haskell too), I just don’t know what I had in mind at that time. Anyway, fixed, thanks.
Comment by Giuliani Vito, Ivan — August 15th, 2008 at 9:45
This article is fun to read. But the author hides a truth: PHP is designed for web and Python is not.
When you said: “If I’d build an application in PHP, I’d spend about 1/3 of the time more if I’d develop the same application in Python” I think it is your problem: your PHP skill instead of PHP or Python matter.
I have developed web application PHP in 6 years and Python for 7 months. I find that the rich of PHP functions, classes that support web development is much more superior than in Python.
I still find that django lacks of a lot features that Zend, SolarPHP and Symfony have.
Comment by pcdinh — December 6th, 2008 at 21:35
I do respect your opinion, but it does not say too much to me. Your election seem based on your abilities not the language, so, waht kind of application you are talking about. Because a large application does not means a complex application, it seems to me your choice is based in an application ready with templates and wizards.
What I can say is … I really hate PHP syntax, and for the rest of the matter, I am sure it is the best option for a proffesional developer.
Comment by oscar — December 11th, 2008 at 2:32
@pcdinh, @oscar: both of you missed an important point of the post that I’ll repeat here:
I agree that PHP was born for web development and for many use cases is the perfect choice. What I wanted to say with this post is that Python has, for us, worked rather better than PHP from our enterprise point of view, that could be quite different from other scenarios.
Comment by Giuliani Vito, Ivan — December 11th, 2008 at 11:01
In design, Python is better than php. but when you program for the web… what can I say… PHP is realy easy to learn, realy fast, realy powerFull, and every time whith a better design and becaming a general purpose language… Mean while I program for the web … even console scripts I will continue loving PHP. Thanks
Comment by Julian — March 19th, 2009 at 2:56