Php or Python

Discussion in 'Web Design & Coding' started by website-design, Jun 15, 2011.

  1. website-design

    website-design OSNN One Post Wonder

    Some people recently suggested its better off doing python rather than php!
  2. ZeroHour

    ZeroHour ho3 ho3 ho3

  3. LordOfLA

    LordOfLA Godlike!

    Maidenhead, Berkshire, UK
    Depends what you are doing but php has the advantage that the bulk of web app infratstructure is built to support it.
  4. X-Istence

    X-Istence * Political User

    I've programmed in both PHP and Python, I have written web frameworks in both, I have used web frameworks in both and I have deployed sites in both. Ultimately I think that I can honestly say with some authority: either one, it really does depend on your preference.

    Python hosting while less common than PHP hosting is becoming more common and fast. There is also a lot of free resources out there for it and it is generally considered a grown up language. Python is internally very consistent with its function naming and there is almost always a library that can help you achieve your goal easily and efficiently. Unlike PHP's Pear system PyPi A.K.A The Cheeseshop has a lot of different packages that can be easily installed with easy_install and generally packages that have a lot of followers are updated frequently.

    PHP is very well known and there is a lot of different places you can get hosting. Most hosting companies offer PHP with MySQL. I have found that PHP's Pear system unlike Python's lacks in quality components and there have been various issues with it. Also PHP allows modules to be loaded (DLL's basically) and if the order isn't right it can cause crashes in the weirdest things or in parts of applications with hard to debug issues. (I've even blogged about it: PHP 5.2.6 on FreeBSD with extensions | Bert JW Regeer).

    Either language has its strengths and weaknesses. Below I will give a little bit of an overview on my experience with different frameworks and what is considered good for use.

    PHP's major frameworks are mostly CakePHP, the Zend Framework (ZF) and Symfony. I personally have experience with CakePHP and the Zend Framework and by far prefer the Zend Framework although it does require writing a little bit more code, it feels more flexible and less rigid. Zend Framework is all about us what you need, and leave the rest alone. This works out really well when building custom sites where every include counts against you in page speed. CakePHP is a general purpose MVC framework, ZF can be moulded into a general purpose MVC framework or not. Also the IRC channel for Zend Framework is generally filled with people willing to help out and answer questions, the CakePHP guys were a tad more abrasive and not as willing to help out.

    The Python frameworks are more diverse, depending on what you are planning to do there are many to choose from and they all have different applications in which they shine. Django is the biggest general purpose one, and is used the world over on many different sites. It is a pretty hefty framework and pulls in a bunch of resources but the documentation is absolutely fantastic and in general with careful coding it can be made into a web app that is fast and performant. Pylons is another Python framework that is popular, for example is built on Pylons. Pylons has been "deprecated" and will no longer really get updates and the latest from them is Pyramid which came out of Zope/repoze.bfg and Pylons. Pyramid/Pylons is lightweight, but at the same time gives you the shell of a house but none of the internals, you will need to provide your own kitchen and sink, you will need to write your own plumbing, and build everything up partially yourself partially what is provided. This is great for someone who is looking to write an awesome custom web app that requires that but can be extremely daunting from a newcomer. Then there is Flask and I have not felt the need to play with those yet so I am not familiar with them. If you are targeting Google AppEngine (Python) there are frameworks that are specifically targeted towards AppEngine such as Tipfy.

    The one major difference I have found between Python and PHP is the examples that are available on the web. Since PHP has always had a very low barrier to entry (I started web dev there too) a lot of bad examples and bad code floats around the net and gets used when in reality it is so bad or full of security issues that it shouldn't be used at all. Python generally has more mature programmers as its users and there is a lot less bad code out there and a lot of good quality examples. The internal naming of functions also helps keep everything easy to understand.

    If you are just starting out in Python, Zed Shaw's book Learn Python the Hard Way ( is not bad at all, and it is completely free.

    Python/PHP hosting:
    - Really new, only offers beta at the moment. Command line interface.
    - Where I have some of my web-apps hosted, kinda neat to be able to specify different technologies and mix them. Good uptime and service and I like their command line based interface.
    Google App Engine - Google Code
    - If you don't mind some lock in, Google provides an awesome free tier and the paid tiers are not that expensive. The entire thing runs on Google's infrastructure and scales dynamically.

    The Django project has a good list for Python hosts:
    Hosts : Djangofriendly

    PHP hosts are a dime a dozen and it shouldn't be hard to find one. My favourites are Nearly Free Speech and A Small Orange. Both provide absolutely fantastic support. NFS is pay for what you use, so if you use fairly little disk space/bandwidth and database then you can literally run websites there for pennies a month. Got one customer site sitting there that costs me about 4 cents every month, and the client has me on retainer for $20 a month (I throw in hosting for free ;-)).

    I hope this helps you make a decision or figure out what you want to try out. I personally suggest either, just know that with PHP you may find more bad code, and with Python that you are unsure of how to proceed because it is a tad bit more complicated.

    Disclaimer on the above: I've used both, but Python is absolutely my favourite now and is what I use on personal projects. It is by far a more cohesive than PHP.