PHP is not the worst language ever like a lot of the cool kids might try to tell you these days. It’s really a wonderful little language if you’re not a total computer science snob. It runs everywhere, it’s available everywhere, and it’s incredibly easy to pick up and use for just about anything. That said, PHP offers every developer who uses it a choice. After spending some time with the language it always, at one point or another, asks “Would you like to be a good programmer or would you like to be a PHP programmer”? The answer to that question can inform the rest of your career, the people you’ll make connections with, and your influence and respect on and from other developers.
I remember when PHP asked me the question. I had gotten used to imperative programming. I used
include() calls like OO guys extend classes. My apps were just a mess of logic files that mixed HTML quite often. It’s actually pretty embarrassing. But I actually got some pretty cool things done that way! And that’s the thing about PHP to watch out for. Before it asks you to make the choice it lulls you into complacency with its ability to let you believe you can accomplish anything any other developer can accomplish in any other language with just the tools you know. You should check out Goalie, my TODO app, and Beautician, my Mardown to printer app. Those were all programs I could have written pretty quickly using object oriented design or any number of frameworks in any number of other languages but I actually wrote them as straight up imperative PHP. Just a collection of scripts that all linked to each other, read from top to bottom along with all sorts of HTML mixed in with the logic. PHP lets you do that! And that’s so amazing but it’s so awful if you don’t understand the consequences.
Thank god for my curiosity because after a while I got bored with what I knew but didn’t wasn’t ready for a totally new language either. So what did I do? I got into OOP. It was a whole new world. I picked up some PHP frameworks like CakePHP and CodeIgniter and from then on it felt like I could do anything in PHP. I just didn’t need another programming language. Python and Ruby were for those know-it-all hipsters was what I told myself. But I was wrong.
I continued building lots of little apps in PHP including the one I’m most passionate about, Write.app before I finally made the choice. I had gotten pretty deep into Write.app when suddenly things started getting hard. Libraries were tough to find, PHP’s quirks began showing up in the code, templating was a pain in straight PHP, dependencies were impossible to maintain, and I was just getting frustrated with this invisible wall I kept hitting in Write.app’s development. In the course of refactoring my code, something which was badly needed thanks to how PHP lets you write spaghetti, I realized how naive and wrong I was about PHP. I still maintain it’s a great little language but I saw “the choice” in my own code and I could pinpoint exactly when I made my choice.
Now, I didn’t make my choice based on horrible code I’d written previously. It was actually in the course of building out the platform around Write.app that I finally knew for sure that I wanted to be a good programmer. I picked up Python to write Write.app’s Sublime Text plugin and it was a really cool experience. Everything from the syntax to dependencies and libraries were all organized and laid out in such a way that pushed you in the direction of best practices while PHP always gives you the choice of doing things the wrong way. I then ran into a small problem in my own life where I wanted to easily upload files and work with my S3 buckets from the command line and so I wrote Sploder, my first Rubygem! In the course of learning Ruby to do this I finally started to understand what all the Rubyists were rambling on about. It wasn’t just a language all the cool kids are picking up (well, it is a little but that’s only a small part of the community). It was a great, simple language that made lots of sense. What was weird about Ruby was that rather than twisting my mind to think like a computer I had to untwist it to think like a human again! If that doesn’t make sense I suppose you’d just have to experience it to know what I mean. In the course of learning these new languages I would definitely try to write god-awful code but the really cool thing was that somehow the language itself kind of told me things like “there’s a better way to do this”, “why don’t you organize the code this way”, and “I just won’t let you do that”. As a PHP dev all this time having a language tell you it’s just not going to let you do something is a tough pill to swallow. I felt like telling Ruby “shut the fuck up and do what I say you arrogant fuck – go tell someone else how smart you are”. But I swallowed it. And it was cool.
I’m by no means an expert in Python or Ruby. Right now I’m at a point where I know just enough to be dangerous but even at this early stage I can see what all the fuss is about finally. I still don’t buy in to what some people say about PHP just being the worst thing to ever happen to programming. That stuff really is just a bunch of elitist bullshit. That said, you’ll still get to a point in PHP where it asks the question: Would you like to be a good programmer or would you like to be a PHP programmer? How you answer will depend on what you want to get out of programming. Are you a hobbyist? A designer who just wants to know one backend language? Fine, be a PHP programmer. But if you’re serious at all about a career in web development choose to be a good programmer, not a PHP programmer.