Having taken my programming roots in QBASIC (shut up), C, C++, and a very healthy self-administered dose of x86 assembly, I can say that for the most part I have a good sense of what programming is. All of what I’ve learned up until now has helped me develop my sense for good code, and helped me to write programs and applications that I can sit back and be proud of. I’ve been working with PHP for over 4 years now, and I have to say it’s the most ugly language I’ve ever used.
Let me explain. PHP itself is wonderfully loosely-typed, C-like syntactically, and all around easy to write code for. The syntax is familiar because of my background. The integration with web is apparent down to its core, and it’s a hell of a lot easier than assembly to write. When perusing through a project filled to the brim with C source code, I’m usually left thinking about how it works, why the developer did what they did, and why that makes sense for that particular application. I’m usually able to figure out these questions and there’s one main reason: the code isn’t shit. With PHP, I’m usually left wondering what the developer was thinking, the 100s of ways I could have done it more efficiently, and why this person is actually making money doing this.
With roughly 90% of open-source PHP projects, everything works great. I love it, clients love it, everyone kisses eachother’s ass. But then one day you get that inevitable change request…I want it to do THIS. A quick look at the source code reveals that, omg, it’s been written by a team of highly trained ape-like creatures! It surprises me that WordPress plugins that get 100s of downloads a day throw errors (unless you disable error output, which I never do on my dev machines). Whole architectures are written with random indentation, or indentation with spaces (sorry Rubyers, but space-indentation is an evil scourge on humanity). No effort is put into separating pieces of code that could so easily be modularized if only they were given a second thought.
Do I hate PHP? No, I love PHP. I think it’s a well-written, high-level web development language. It’s fast, portable, and scalable. It allows me to focus on the problems I face, not the syntax of what I’m trying to do. Paired with an excellent editor like Eclipse (w/ PHPeclipse) I’m unstoppable. But why can’t any other PHP developers share my love of well-written code? It’s the #1 critique of PHP, and rightly so. I’m pretty sure that all programming languages, save Python, allow you to write awful, unreadable code…but PHP’s culture seems to be built around shitty code, amateurish hacks, and lack of elegance. PHP isn’t the problem, it’s the people writing it who suck!
So I do love the language, but hate most of the implementations. I have to say though, nothing is worse than Coldfusion.