Thinking


The view from here

PHP: A Bad Language or Just Misunderstood?

By Matt Hurst in Web Development on October 23rd, 2014

PHP is a programming language that is sometimes disrespected by parts of the development community. But despite its flaws, it’s still a dominant, effective, and flexible tool in the right hands. That matters to agencies and clients alike, because if you’re operating in the digital space (and if you’re not, you need to catch up a few decades), you’ll definitely be dealing with PHP on a regular basis. That means your developers need to be able to keep up.

 PHPLarge

Rasmus Lerdorf created “Personal Home Page Tools” in 1994 (a set of CGI binaries written in C) to track visits to his personal resume. Over the next few years, PHP capabilities were expanded and with the 3.0 release it was renamed PHP: Hypertext Preprocessor. With this release, PHP had become a full scripting language in its own right.

A lot of the flak PHP receives now comes from its performance in these early years. Compared to full-blown programming languages released at that time (like Ruby and Python), it was not on the same level — nor was it meant to be. These programming languages were created with object-oriented programming (OOP) in mind. On the other hand, PHP was “born” out of need for a simple scripting language for the web.

Fast-forward to the present, a lot of things have changed. PHP has come a long way towards being a full object-oriented, web-based scripting language. And with the creation of model-view-controller (MVC) frameworks such as Symphony, Zend, CodeIgniter etc., PHP is finally ready to compete on a larger scale.

So, why choose PHP?

  • PHP allows you to code the way you want to code.

    Many developers argue that PHP encourages you to code in an inefficient, inconsistent or lazy manner. However, the programmer should be blamed for such behavior, not the language itself. PHP does not force you to use some standard that may or may not be the “right” thing two years from now. And let’s face it, when writing something simple like a contact form, you don’t need an object-oriented or MVC-equipped (model-view-controller) language. PHP allows you do simple, quick scripting inside HTML, create elegant web based applications and everything in between.

  • PHP is everywhere!

    Rent a server from most any web server provider and 9 times out of 10 it will have PHP installed. You typically have PHP at your disposal no matter where you have to work. PHP can even run on a Windows server.                                                                                                                                                          

  • PHP is hands-down the most popular language on the web.

    Take a look around the web one day; many of the most popular sites you use on a daily basis were written in PHP. A few examples you may have heard of: Facebook, Wikipedia, Flickr, Yahoo! Answers, Delicious, Digg, WordPress, SourceForge, Photobucket and Vimeo.

To be fair, PHP has some technical problems

  • PHP has very loose type casting.

    By many, this is considered part of the design of PHP.

  • Inconsistent naming conventions are an issue.

    This weakness is simply a flaw, in my opinion, but not one that is so terrible. For instance, two built-in PHP functions with the same parameters, but in a different order. This may seem trivial, but from a developer’s perspective this makes a big difference.

    Here's an example:

    in_array ($needle , $haystack )
    strstr ($haystack , $needle)

  • The manual is not the best.

    PHP’s official user manual is not exactly the most inviting or effective document. But we have seen far worse from other languages.

  • In the past PHP had no OO properties.

    This deficiency has been remedied somewhat over the years and isn’t as much of a problem as it once was.

  • The community does include subpar developers.

    Although PHP has a great community, it is also plagued with subpar developers spitting out subpar work. This is, frankly, the number-one cause of problems with PHP. Look across the Internet and you will see thousands of tutorials explaining how to use the language incorrectly.

Why it matters to agencies and clients

Let’s face it, an agency is not a development house. And job-hopping has become the new norm these days for many in the industry. PHP developers have the majority of the job market. So think about this: if you have a developer writing all your sites/software in Python, Scala, NodeJs etc., and then he or she decides to move on, you are left with very few options for hiring someone to maintain these projects. On the other hand, even if you hire a Ruby on Rails developer, it’s more than likely they have had some experience with PHP. Yes, PHP my not be the latest and greatest trendy buzzword. But it is tried and true, with a larger percentage of developers who can maintain it.

The Verdict? Learn PHP, but don't stop there

Learn PHP, but don’t stop with it. A language is a tool, not a religion. In fact, languages, CMS’s, libraries, frameworks, etc. are all just tools in a developer’s toolbox. If a job calls for a hammer, don’t use a sledgehammer, or a stick. Use a hammer. People who dismiss PHP are either blindly devoted to their preferred language, bandwagon-jumpers, or are just plain ignorant of how far PHP has come.

Is it the perfect solution for everything? No. However, does it have its place? Absolutely, and it does a spectacular job in the right hands. And you might want to get used to it, because it’s not going anywhere.

What’s been your experience with PHP? Let us know in the comments below!

Need help choosing the right development language for your next project?  Get in touch with our experts today!