The Peculiar Nature of PHP
PHP has obviously been around for a while. Not quite as long as C, but by all accounts around 1995, the same year as Ruby and Java. And yet, I find it one of the most peculiar languages with regards to how people (those core to the language itself, as well as users) have developed using such a diverse style of programming.
I haven't had much chance to work in PHP for a while, but my recently acquired job gave me the opportunity to delve into it again. What I find most perplexing is the complex lack of consistency with how everything works.
Allow me to explain my position.
Let's start with something simple - naming convention. Java is fairly standard with this: everything is camel-case, with classes generally starting with a capital letter. Typically constants and such are all capitalized. That's pretty much adhered to across the board, unless you are creating classes which you never intend to have a user directly access, such as implementations of interfaces, and some such.
Ruby has it's own convention, some of it strictly enforced. Anything with all capitalization is always a constant, class names are camel-case, method names are underscore-case.
PHP programmers just do whatever they like. I've seen cases where both underscore and camel-case are used in a single name.
I appreciate that there isn't a big brother standing there looking over your shoulder telling you that you're not coding right for something as simple as a variable name, but the issue for me comes in that this sort of thing occurs in all the libraries, too. This means that as a newish programmer, you cannot readily assume anything about how to invoke methods on an object, because you simply don't know off-hand how the developers of that particular model chose to work.
The point can readily be seen by comparing PDO with MySQLi - okay, they are different libraries catering for different users, but note that there is virtually nothing, no matter how trivial, shared between them.
What I've ended up doing for most of my programming now is to create a "commons" library which simply provides facades for all these disparate systems. It may seem like a lot of trouble, but for my personal taste, I do find it more fluid to program when everything conforms to at least some semblance of similarity.
I'll probably end up releasing it all into open-source, so if you're interested in seeing what I'm prattling on about, just look me up on Ohloh.net
Comments
There are no comments for this post.
Add comment
Visit my Friends and Family
If you've enjoyed my site, please take a moment to visit my friends and family, many of whom have some interesting insights, and entertaining thoughts and ideas.
- Crause Family - the family website
- Peter Crause - my father
- Justin Crause - my brother
- Cencina Photomagic - great photographer