What I like about PHP
- 4 minutes read - 694 wordsThere’s a somewhat prevalent notion in some circles that PHP is a bad language and everyone that uses it is some sort of idiot that wouldn’t recognise a real programming language if it compiled to Javascript right in front of their nose. What a real programming language is varies greatly depending on what person you ask (it usually involves things that are specific to their preferred language), but there’s a lot of people that say PHP isn’t one.
Sure, PHP has its warts — every language does. It appears that just because PHP has been used a lot more than most languages it gets compared to, its warts are known about a lot more which makes it a much easier target.
As someone who actually enjoys using PHP for the most part, this sort of attitude is rather annoying and reminds me of some of the OS debates I’ve seen which can generally be summed up as “That X you use sucks because I use Y which means it’s infinitely better. LOL GTFO”.
Since I’m not a fan of such negativity, I’m going to doing something radical. I’m going to detail some of the reasons I like something rather than reasons why something is crap. So, here’s some of the reasons why I like PHP.
It’s simple
One of the main reasons PHP is so popular is because of how simple it is. This means it’s really easy to pick up and start using. Once you’ve got the basic syntax down, you’re set to start building The Next Big Thing™.
It’s powerful
PHP has a massive standard library that provides a huge amount of power. On my local install there’s 1820 inbuilt functions, plus a large amount of classes. Want to talk to some esoteric database? There’s probably functions for that. Want to manipulate images? There are functions for that. Want to perform arbitrary precision calculations? There are functions for that. There are even functions to run an interactive SSH session.
As they’re all part of the standard library, you get all this power for free.
It’s well documented
The PHP documentation is extremely well done. Once you know the basic syntax, the online documentation is pretty much all you need to be able to figure out how to use anything in the standard library.
If you’re looking for an example of good documentation to base your documentation efforts on, you can’t go wrong with the PHP docs.
It’s fast
Here, I’m not talking about execution speed (though that is fairly decent in the standard PHP and then amazing in HHVM). I’m talking about development speed which, in most cases, is far more important.
The lack of boilerplate, the simplicity and the power all mean you can build something quickly. Then there’s the feedback cycle. If you make a change, all you have to do is save, switch to your browser and refresh. Your change is now applied. For everyone, from beginners to veterans, being able to test your changes quickly is a massive boon.
It doesn’t enforce a certain paradigm
Want to use OOP? Go for it! How about something procedural? Yup, you can do that too. There’s even support for some functional programming-esque coding. You can mix these, or just go with one style.
This means you can do some simple procedural code when writing a quick script, and then add in OOP as it grows. Whatever suits what you’re trying to do.
The future is exciting
That’s what PHP currently has. What’s planned is even more exciting. You can check out the current RFCs to see what’s being planned. There’s also Facebook’s addition to PHP, Hack, that corrects most of the complaints people have about PHP as well as adding a bunch of really useful new features. Facebook is actively working on bringing some of these features back into PHP too.
There you have it. That’s a short list of some of the things I like about PHP. This isn’t a complete list – far from it – and PHP isn’t the only language with these benefits. That doesn’t stop it from being a useful, general purpose language for today’s web.