PHP is an incredibly popular programming language. For server side languages used on the web, PHP is the most popular language and the popularity is growing. Over the past decade PHP has added new language features, such as closures, and healthy programming practices have become far more common. Despite this, PHP has a bad rap.
Recently, Facebook has announced hack and the latest round of HHVM updates. Somewhere in the mix of Facebook announcements, far too many people are referring to Facebook as the place that’s bringing about innovation and refreshing changes to PHP. I’ve heard this repeatedly and it can been seen in blog posts, like the latest one from Heroku announcing HHVM support.
While I find hack interesting and I’m glad to see more PHP execution environments, I see that a lot of the innovation that’s happened in PHP is being overshadowed or missed. Just recently, I was asked why somone would want to use PHP. Aside from executing faster in a VM they had no idea what was going on. So, let’s look at some of what you’ll find in modern PHP. All of which have happened separately from any one large marketing entity.
Package Management
A problem that needs to be solved in any language is the use of dependent packages. How do you manage using dependencies, include them easily, finding them, and dealing with versions? This is where composer and packagist come in.
Package/Library Interoperability
Packages used to be stand alone or tied to a framework. The same piece of functionality would be re-written numerous times to work with different systems. Things are changing in PHP.
In addition to the new way of doing package management, which enables packages to be shared between frameworks, there is the PHP Framework Interop Group (FIG). They are working to define interfaces and conventions for some very common things. When common things are done in a common manner it makes re-using code far easier.
Language Features
PHP has a lot of modern language features. PHP had closures before Java. Namespaces have been around long enough that there is no supported version of PHP without them. It has modern language conventions and they are used.
Software Engineering and Programming Practices
Patterns, modern conventions, and a style that a programmer could appreciate are present in modern PHP applications. I can be just at home programming in Python as PHP. There are different language semantics and each has some strengths. But, it’s not because PHP is hacky and Python (or some other language) is more elegant.
If you want to look around some of these modern projects take a look at Symfony, Guzzle, Assetic, or one of the other modern packages.
But, butt, but…
The worst software design I’ve seen was in a C application. I’ve seen some pretty wretched PHP and Python, too. There is a difference between what some people write and what’s held up as how you can write or design code.
I’m not suggesting everyone jump on PHP. Or that Facebook doesn’t deserve some credit. Or even that there isn’t a lot of poorly written PHP.
I’m simply suggesting the PHP isn’t a hack that’s is or should die off. That someone can be a real programmer and perfectly happy writing in modern PHP.