My Love Affair With PHP - Or Why I've Never Loved Another Language So Much

My Love Affair With PHP - Or Why I've Never Loved Another Language So Much December 22nd, 2014, by Matthew Setter

There are many software languages to choose from today — but why PHP? Does it even rate a mention? Let’s think about this for a moment.

There are many software languages to choose from today — but why PHP? Let’s think about this for a moment.

It Was Never Designed As A Language

There’s the more traditional, and “enterprisey”, such as Java, C, C++, Perl, and C#. Then there’s the newer, more dynamic, languages, such as Python, Ruby, Node.js.

Then there’s some not-so-mainstream languages, such as Haskell, Scala, and Clojure too. And finally, there’s the newest kids on the block, including Go and Swift.

Does PHP even rate a mention in the company of languages such as these?

To be fair, when PHP started off in 1994, it wasn’t designed as a language; a language was what it’s evolved in to.

When Rasmus Lerdorf first created it, and for quite some time afterwards, it was a set of separate tools written in C, which helped him create his own projects.

It was never created with the intention of being a language, such as just about all of the aforementioned languages here, as this quote from SitePoint, back in 2002 attests:

The first version of PHP was a simple set of tools that I put together for my Website and for a couple of projects. One tool did some fancy hit logging to an mSQL database, another acted as a form data interpreter. I ended up with about 30 different little CGI programs written in C before I got sick of it, and combined all of them into a single C library. I then wrote a very simple parser that would pick tags out of HTML files and replace them with the output of the corresponding functions in the C library.

It’s Been Plagued With Issues (And Detractors)

Then there’s the issues which plagued it for so many years, to the extent that it was almost seen as insanity to use it. Here’s a short summary of the most often cited detractions:

  • PHP’s Not Predictable
  • PHP’s Not Consistent
  • PHP’s Inconcise
  • PHP’s Unreliable
  • PHP Wasn’t Designed For Programmers
  • PHP’s the Nickelback of Programming Languages

With all of these smells lingering around it, could you really, truly, confidently call yourself a software developer and say you use PHP in the same sentence?

But I Still Love It

Yet despite all of this, it’s a language which I still have so much passion for using on a regular – even daily – basis. Perhaps I’ve not pushed myself to branch out as much as I should.

Perhaps I just haven’t tried hard enough. Perhaps it was the one I had to use the most so early in my career. Hey, my first professional application was a VB6 frontend on a Microsoft Access “database”.

Maybe this was what did it; Maybe, as a result of this experience, I just wanted to code on anything other than Windows, and these events coincided so nicely that it just worked for me.

I think it definitely had a first-mover advantage with me, because I loathed using Visual Basic and it was just so easy to get started with; it still is!

This isn’t always a good thing. In recent years I’m oft to think that a certain amount of challenge, or barrier, to entry might actually be a good thing.

It might see some of the detractions go away, because the kind of developer using it might increasingly be unassociated with “copy & paste” style coding practices.

But I can look past all that. PHP was inspired by a really rich heritage, one that I’ve always identified with, with an almost evangelical passion.

It is heavily influenced by languages such as C, C++, Perl, and could not have existed with out the extremely rich UNIX ecosystem.

I took to it like a duck to water.

And that’s a lot of why I used it so much and stayed with it. But it’s not as though I started out with UNIX or a UNIX-like operating system.

My first computer, when I was about 12 or so, was an Apple 2/c, quickly followed by an Apple 2/e. No amount of symbolism is lost on the fact that I’m writing these words on a Macbook Pro.

I Was Never A Windows Fanboy

After a hiatus – no, I wasn’t coding at 7, 8, or 14 years of age – I came back to computers and, like a lot of people around me at the time, I started using Windows 3 & 3.11 but never felt they were worth developing on.

Then Windows® 95(a) came along…Let’s just say it didn’t start out positively and the 95 series put the final nails in the Windows coffin.

I’ve never felt comfortable on Windows since, though I did dabble briefly in ASP classic for a time.

I was at university at the time and heard about Linux. I knew a good friend of mine would know about it and asked him to help me get started.

It’s been almost all open-source software since then. Yes, using a Mac changed that balance somewhat, but I’ve not deployed an application to a Windows server in countless years, unless the need demanded it.

No Language, Nor Tool, Is Perfect

Bringing this long-winding storing to a close, I love PHP for many reasons, yet fully respect that it’s not perfect.

I can see how far it’s come, from the days of PHP 3 and the syntactic sugar which masqueraded as object-oriented support, and choose to not reflect on the baggage and legacy from its past.

The developments since PHP 5.3 have continued to inspire me. If you’re not as familiar with them, here’s a short list of what’s come about since then:

  • Namespaces
  • Late static binding
  • Lambda functions and closures
  • Traits
  • Built-in web server
  • Removal of register globals, magic quotes and safe mode
  • Support for multibyte languages
  • Function array dereferencing
  • Class::{expr}() syntax
  • Generators
  • Class name resolution via ::class

Do Other Languages Just Have More Advantages?

Yes, its syntax isn’t quite as fluid, or expressive, as some other languages, such as Ruby. It doesn’t have some of the built-in, helper, features of some other languages, such as Go’s. And it doesn’t have some of the natural assistive features, such as Python’s.

But that doesn’t mean that you can’t write great applications with it. Yes, it has its limits and, like any tool, no matter how good, it shouldn’t be used as the solution to each and every problem.

But the most modern versions are as capable as any other, in the hands of those who are professionals, people who continue to learn and grow their own skills.

It’s Easy To Be A Hater

It’s easy to hate on just about everything, if you want to. But in the words of Tim Minchin:

We have tendency to define ourselves in opposition to stuff; as a comedian, I make a living out of it. But try to also express your passion for things you love. Be demonstrative and generous in your praise of those you admire. Send thank-you cards and give standing ovations. Be pro-stuff, not just anti-stuff.

A Big Thank You

So in that light, I acknowledge that PHP, like anything, has flaws. But I also tip my hat to the hundreds, even thousands of people, who devote time to resolving those flaws and improving on the language which powers, by differing estimates, around 85% of the websites the world over.

Whether they’re direct code contributors, documentation writers, application creators, open source project maintainers, and everywhere in between.

Thank you for all your efforts thus far, and in to the future. And finally, a thank you to Rasmus himself for kicking it all off all those many years ago.

image copyright © Scott Beale


Like That?

Don’t miss my next post. Drop your email in the box below, and get it straight to your inbox, PLUS exclusive content only available by email. No spam, and you can unsubscribe at any time.