Sunday, November 21, 2010

PHP? Fine with me


Have ever you heard "Ewww, you use PHP? I thought you were cool!"?
Despite having just been using PHP for 2 weeks for a company project, I have heard some of those from my colleagues who are using Python and Ruby for theirs. PHP has always been considered as creepy by many web developers, especially those who work on big systems with back-end and front-end components. I agree with those to certain points:
  • PHP code is usually a mess of spaghetti where server code wraps SQL query and projects whatever to HTML
  • PHP is by far not an expressive language, as not much as LISP family.
  • PHP development is never actually designed but hacked but a group of people want to fill in their needs without any concerns about the language big picture.
That answers why you are very likely to run into
  • Interface semantic story - the assumption about how the interface will be used which cant be enforced by the compiler. The semantic interface includes consideration such as "Method A must be called before Method B" (lack of design),
  • Messy PHP code (the lack of expressive power)
  • And a function with a perfect name but doesn't work while another with a 'more awkward' name does (it was HACKED by a group NOT a team)
Yet, despite of that you can find PHP here and there. PHP can make a good demonstration for worse-is-better principal, the messy code enables programmers develop sites with a few pages and interacts with the same number of db tables fast and easy, think about the pain you have to suffer if using an enterprise-standard solution such as J2EE. PHP is not well-known for its scalability but it does not mean it would take you 5 minutes to load a page and except client's target is the second Facebook, entrepreneur and start-up in general find PHP as an acceptable solution to have their projects. PHP also goes really with Apache (#mod_php) and thank to that, you can run PHP on almost every 10$/month hosting server.
Last but not least the core value of PHP has never been a complete server side language but a TEMPLATING SYSTEM, enabling developer to create dynamic content and at the same time keeping the code designer-readable. Many big guys are using PHP such as MailChimp, Yahoo and probably the most well-known: Facebook. Those manages to live with PHP while keeping their system scalable all because PHP is used as what it's meant to be: a templating language supported by a proper back-end. And with MVC framework such as Yii or Zen, where PHP core drawbacks such as class loading mechanism is resolved, PHP is going to live for a couple of years more.

No comments:

Post a Comment