Skip navigation.
Home
That which cannot be rendered in binary is by definition a delusion
 

PHP vs. JavaScript

: Assigning the return value of new by reference is deprecated in /home/bingoman/public_html/wll_drupal/sites/all/modules/paging/pagination/pagination.module on line 508.

I have written, used and sold a lot of PHP and Javascript. They are both interesting languages and have firm grasps on their respective markets. But they are also wholly different languages with different treatements of objects and classes. And there is a lot to love about each one in their own scope. 

What I love about JavaScript

  • Javascript at its core is leaner and faster and consumes far less memory and resources than PHP. 
  • Javascript's object and class system is much more fluid than PHP's.
    • The fact that you can easily mix prototypes gives you ad-hock multiple inheritance, the "holy grail" of OOP. 
    • It is really easy to spawn a useful singleton on the fly with deep structure and functionality.
  • Both arrays and objects are passed by reference by default and are full class objects, with methods - not passive structures to be adjusted by external functions. 
  • There is no other language that I know of that has a viable presence on the server AND the client. This speaks loads for the potential of erasing that stupid "Are you a server side or a client side programmer?" question that vapid people ask all the time. (and you can shut up, Visual Basic. You know what you did.)
  • It has profound traction in the mobile field. If you are a mobile developer it is basically JavaScript or Objective C, and I call that a no brainer. 
  • JavaScript has access to the DOM. I'm not sure if I love it or hate it as the browser wars have made this a pain in the ass, but with jQuery doing the heavy lifting there is just so many wonderful things you can do with it that no other system allows you to do with any real elegance. 
  • AJAX. 

What I love about PHP

  • There is only one version of PHP - assuming of course you keep your servers up to date with the latest version and don't do something asnine like try to run it on a Windows box. You can jump into any setting and pretty much know what you are getting. While there are optional modules, they are generally very specialized and easy to add to your stack when you need them. 
  • There are reliable proven drop and run stack tools like Zend Framework and Drupal. Say what you will about these tools, you can erect a site in days with Drupal, and a viable site in a few weeks with ZF. 
  • There is a profound legacy of development done in PHP. Not all of it is good or useful but you have a lot of confidence that no matter what your client throws at you, you can find existing and useful code to use to erect a solution for them. 
  • It has classical, er, class structure, with static, private and protected variables explicitly and securely defined. This is a much more scalable pattern of implmentation then relying on semi-skilled labor to know what an underscore in front of a function or variable name means. 
  • PHP is its own templating language. The questionable value add of systems like SMARTY just emplhasize how well PHP does its original task of acting as an embedded templating language on its own. 
  • PHP has a unique and intensely personal syntax. You really know you are dealing with PHP when you look at a PHP page. Although it can easily be mistaken for PERL, no other languages besides those two execute the brilliant idea of using -> for objects and $ for variables. I really don't know why PHP doesn't use @ for arrays like PERL, but I suppose it has its reasons. Also, I acutally prefer the alternate syntax for PHP's control structure. if... endif, et. all really documents control structres better than anonymous braces. 
  • Zend Framework. (Except for forms, which suck.)

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <p> <span><small> <div> <h1> <h2> <h3> <h4> <h5> <h6> <img> <map> <area> <hr> <br> <br /> <ul> <ol> <li> <dl> <dt> <dd> <table> <tr> <td> <em> <b> <u> <i> <strong> <font> <del> <ins> <sub> <sup> <quote> <blockquote> <pre> <address> <code> <cite> <embed> <object> <param> <strike> <caption>
  • Lines and paragraphs break automatically.
  • Web page addresses and e-mail addresses turn into links automatically.

More information about formatting options