WordPress Weekly episode 6 had some comments about PHP5, that I want to address. It should be noted that they were referring to Matt Mullenweg’s interview at Yahoo!.
To me the argument that Matt was making was that End Users don’t care what language a project is in, as long as they are able to use it. This is true and there is enough proof out there with other consumer products to provide the evidence to support that statement. People only care about one thing, “does it work?” and if it doesn’t then they’ll either find something else that does or if they care enough or have enough patience will try to get it to work (as long as it isn’t the original product that is at fault).
The arguments against Matt’s are developer centric. I will only code in PHP5 for web development, except for a few rare occasions. Those being when I’m writing patches for WordPress, or when I am on a server that only supports PHP4. Both instances are rare in and of themselves, so it isn’t like I’m back in the dark ages. However, PHP4 isn’t that terrible, but in truth PHP4 answered a lot of complaints that a lot of developers had with PHP3. PHP5 offers a lot of enhancements over PHP4, but the amount of people really passionate about them don’t seem to be near the amount of the fans of PHP4 when it was initially released.
The fact that patches have to support PHP4 does limit what I will want to do, because I don’t want to duplicate and back-port something that already exists within PHP5. Likewise, I wouldn’t build a JSON library for converting PHP variables, because that already exists in PECL and is in PHP 5.2.x by default. It would be a waste of time to try to attempt to do so now, since the majority of hosts should be switching to PHP5 anyway.
The second fact is that PHP4 is already in end of life and will only receive security fixes until 8/08/2008 and after that, every bug, whether general or security related is not going to be fixed for any PHP4 version. This means, that WordPress will have to provide any work around for PHP security defects in any affected function. WordPress is also not going to provide any patches for PHP4, so I mean, it isn’t like users of PHP4 will be able to get the fixes from WordPress community. Only user land fixes can be made and sometimes you need to have low level fixes instead. It is very difficult to prevent a stack overflow in userland PHP.
The argument about hosts is that, most shared hosts already support running either PHP4 or PHP5. The statistics reported are just the versions users are running at that time. So even though, the user can easily switch to PHP5, if the user wanted to, but people are making the argument that they don’t even have PHP5, when they do.
I say this with only minor experience with dedicated servers, which I’ve found are extremely difficult to upgrade unless you know someone who knows what they are doing. Site down for 10-30 minutes to upgrade PHP is okay. Site down for 5 hours to 3 days before you completely botched the PHP installation is not cool. If a cluster is not used and the system administration skill level is low, then the odds of keeping up to date are pretty slim.
Doesn’t Have Any Real “Killer Features”
One of the quotes was that, “PHP5 doesn’t have any real killer features that make you need to move away from PHP4…” Okay, this is really based on opinion. I would have to say that either the commenter hasn’t touched PHP5, or just used any one of the great features in any depth. These are just a few of the “killer features” I think PHP5 has and that I think others would enjoy if they switched over to PHP5.
- Database Access Abstraction
To most people who created their own simple database access abstraction, know what a boon and awesome extension PDO is. It is available by default in PHP versions 5.1+. To compare with WordPress, you can replace the entire WPDB class with PDO instance. It would only slight improve the database SQL abstraction, as you would still need to intercept MySQL SQL statements and convert them to the SQL that the database supported can understand.
I’ve built a project, where I was easily able to support both MySQL and SQLite. I could further extend support to any number of other DBMS without having to touch the access layer. This same technique could be used with WordPress to implement an extremely flexible SQL abstraction to where it pulls the SQL from any data source.
Furthermore, WordPress implements a prepare feature that PDO already has, which in PDO is better and faster.
- Filter Extension
Have security issues with filtering input? Not any more. The filter extension allows for handling input with built in techniques or hooking another function in to do the work instead. All of the complaints about WordPress would instantly cease to be relevant.
Now, the Filter extension isn’t a cure-all solution, but by using it throughout you offer a standard interface by either using the filter extension library functions or by building an application sanitizing and validating library around it. The reason you would wrap the filter extension is if it isn’t available (using PHP 5.1 or server admin forgot to install or forgot to enable the filter extension) or if you already have an established library.
WordPress offers a lot for sanitizing and validation, but it can offer more. The Filter extension could be a good solution to solve that problem. I think it is great, but it really isn’t a “killer feature”.
- JSON
JSON, isn’t difficult enough that if you don’t have dynamic data structure changes, that you can write the JSON out for yourself. However, you do have less of a chance of making an error and risk not having your AJAX call work by using the one function it takes to encode a PHP variable to JSON syntax.
- XML Capabilities
Between SimpleXML, DOM, XMLReader, and XMLWriter, I think all of your XML headaches will cease to be. Each of the extensions have their advantages and disadvantages, but it totally wins over regex or DOMXML alone (PHP 4.3+, not including PHP 5.0+ which replaced it with DOM).
- SPL
Iterators, DirectorIterator, and ArrayAccess, might not mean anything to you, but to me, it means that my objects can kick your loser PHP4 objects’ asses. Everytime I’m iterating over a directory, I kiss the ground DirectoryIterator walks on, because it includes everything I’ll ever need in one very simple to use class.
As for Iterators, why return an array from either a method or function, when you can just loop over the object and get back relevant data. WP_Category_Iterator anyone? I’ll tell you right now, if it was available, a lot of developers would be rushing to use PHP5.
- SOAP
I have heard many people shout the praises with having a built-in solution for SOAP. I don’t use it and I suspect others don’t as well. From the criticisms, it isn’t perfect, but for those that it does help, it is that one killer feature.
- Improved Object Oriented Support
If you don’t do OO, then this means nothing to you, but for me, it is the one reason I will only code in PHP5+. The above features are just extra advantages to keep me coming back to PHP5. If you do care about interfaces
- Increase Speed Performance
This is based off a recent benchmark of PHP4 and PHP5 versions. I think for those that speed matters, will enjoy the increase that PHP5 offers. It should be noted that for most tasks it only means a few milliseconds (if even that), but those do eventually add up to a lot.
Of course, for someone else, they will have a different set of features or just might not think anything in PHP5 is that great. In my experience, I don’t know how I lived without these features. I just suggest looking into these above features more before you decide that PHP5 is a non-event.
“…PHP6 won’t be PHP4 compatible…”
That statement is false. The only parts that won’t be compatible are if they applications depends on Register Globals (which shouldn’t anyway since PHP 4.2), safe mode, or magic quotes. Those that don’t depend on those three should have only a few minor issues depending on whether they are using a function that has been deprecated since PHP4 or PHP3 (I’m referring to the E_DEPRECATED error level that might be part of PHP 5.3 and PHP6).
There might be others, but until PHP6 is released, I think people should hold off on statements, because it is like saying PHP 5.3 is going to have namespaces. Right at this moment it does, but that can change in the future (or might have already changed since I last looked at the debate). It can be pulled just like it was for PHP 5.0. That only sure thing about PHP 6.0, is that it is going to have Unicode, which shouldn’t affect the majority of string functions out there.
Until PHP 6 is released, I think the only ones that know now verses those that will know then when everyone will know, are the ones that are developing PHP or watching the Internals.
Possibly Related Posts: