Get real about PHP4 vs. PHP5!

I am repeatedly frustrated by seemingly reputable people in the PHP industry marginalizing and downplaying PHP5 in favor of the ever aging and antiquated PHP4. 

Recently I visited the community forums of the osCommerce project to help me out with some issues I was having with a new installation.  The first thing I discovered was that register_globals had to be turned on.  This was my first clue that things were about to go down hill.  As I read further into the forums, I read posts by osCommerce people that recommended users to avoid PHP5 and MySQL5 with a spin that suggested they were still in a beta-like status!  Well, that ended my osCommerce experience quick.

I’ve been running many web sites for myself, my partners, and my clients on PHP5 for years.  When we switched from PHP4 to PHP5 we had to simply change a single method name that collided with a new PHP5 feature.  And, I’m not talking about small applications.  I’m talking about a complete online fantasy sports systems.  Content and product management, e-commerce, integration systems and many custom modules for very large companies in the construction and industrial manufacturing industries.  Company names that your kids probably know, but names that probably shouldn’t be mentioned in my little rant here out of respect.

PHP5 is here already, and many of its’ versions are completely stable for the vast majority of people.  And, soon PHP6 will be here whether other people like it or not.  So, why not get ready?  It seems to me that folks are happy living in their PHP4 bliss.  They’re not concerned with preparing for the changes that will likely render their software completely obsolete.  Newsflash!  There are already companies out there that have embraced PHP5 and are eagerly awaiting PHP6, like myself.  PHP4 projects are going to get run over and left behind by more cutting edge and proactive organizations that have no problem realizing the benefits of a more modern and progressive language.  They’ve educated themselves and are already writing stable PHP5 code that will also be ready for PHP6 with ease.

PHP5 represents a massive step in the right direction to support enterprise level methodologies and still not scare away Joe Smith who wants to setup a gallery to show pictures of his marble collection.  It’s our job as PHP supporters and professionals to embrace and promote advancements in PHP.  If we don’t, then we better start learning to spell “Ruby”

16 Comments

  • 1. hetzerrr  |  June 9th, 2006 at 4:55 pm

    Rather than spend time ranting about how unenlightened OsCommerce is, why not step up, participate and take the time to be sure OsCommerce is PHP5 ready and send the changes back to the OsCommerce community.

  • 2. kenzie  |  June 9th, 2006 at 5:13 pm

    Can you recommend some good resources for making the switch from 4 to 5? Especially those suitable for Joe Smiths like myself.

  • 3. admiraln  |  June 9th, 2006 at 5:15 pm

    Get real about language evolution. This kind of inertia in language adoption is part of the “natural” evolution of all programming language. I have experiece this with 3 language personnally and probably could find evidence of it for other.

    The evidence would be article like yours imploring the unwashed masses to “keep up with the times”. It does help to a degree but not enough to make a difference.

    The only thing that keeps a language as the LANGUAGE is the early adopters, the edgy programmers who make the best use of the language and push the features of the next few releases of it.

    If they leave and go onto the support the NEXT LANGUAGE it all over. PHP will have many years to come a first rate development language but it will have to drag itself through the debris of its own flaws and myths.

    No matter how it has developed and corrected these flaws and myths they will remain poisioning new programmers before they buy in.

    The only salvation is if something radical happens in some aspect of the language that draws the early adopter back to the fold. I never have seen that happen but if some can relate a language that has retaken the title the current best language then I will have learned something.

  • 4. mgkimsal  |  June 9th, 2006 at 5:19 pm

    There’s nothing inherently *wrong* with PHP5, but I still don’t find that much compelling about it. Things still happen at runtime (not bad, but they do) which makes some of the things people assume as ‘proper’ about software don’t work right in PHP5.

    Type hinting is type demanding, as you get fatal errors if there’s a problem. If there was a compiler and strict typing one could avoid this situation, but PHP is dynamically typed and not pre-compiled, so we have these sorts of problems. Instead of throwing “Fatal Error”s, things like that should throw exceptions and let people catch them and do better error handling.

    I’m not sure what ‘enterprise level methodologies’ you can achieve in PHP5 that you can’t get in PHP4. The *way* you use the langauge - TDD, data access objects, documentation, more testing, etc. - those are the things I associate with ‘enterprise’ projects (well, not specifically DAOs, but hopefully you get the picture).

    I don’t consider Rails any more or less ‘enterprisey’ than PHP, but the one thing the Rails community has that the PHP community doesn’t is one standard way of doing things. I know there’s differences and all that in the community, but it’s basically a ‘if you do web apps in Ruby, use Rails’ sort of mindset - not much wrong with that, and a whole lot right with it. Same in the ASP.NET world - almost everyone uses the same tools and codebase. In the PHP world, you don’t have that at all, which also hurts in the ‘enterprisey’ aspect of things too.

    Notwithstanding some of your apps you mention, people who had invested a lot in PHP4 were hurt with the move to 5 because of incompatibilities. The *primary* one that sticks out is the XML processing. There seemed to be little effort on the part of the PHP devs (and indeed the whole community) to give people who’d written large DOM apps in PHP4 a clear upgrade path. It’s great you were able to change *1* function to achieve PHP5 compatibility, but it might mean that you weren’t using PHP4 to its full potential at that point…

    TTYL…

  • 5. gcornelisse  |  June 9th, 2006 at 5:57 pm

    I completely appreciate the practicality of sifting back though countless lines of code to accommodate the changes.  The primary point I’m trying make is that we, as the PHP community, should support and encourage advancements in the PHP language.  We have to start somewhere, and that means that as we release new versions of our own code we should probably be doing what we can to make those changes.  Instead, it sounds like some people are discounting PHP5 all together. What struck a nerve with me is when people, in the position to influence someone’s perception and/or decision about PHP5, dispense advice that is almost derogatory towards the newer version.

    Kenzie, if I don’t get to it first, I’m sure someone can hunt down some good PHP4-to-PHP5 comparisons.

    Mgkimsal!  …small world

  • 6. ruzz  |  June 9th, 2006 at 6:10 pm

    One of the reocurring stop points I find for people adopting more modern development techniques (like using symfony which is only php5) is their existing codebase. But it’s more than that.

    IT’s long been believed that php programmers where not “real” programmers. They are people who managed to munge together scripts. And, by this analysis, the reluctance to move forward–as php5 is a big step forward–maybe “they” are right afterall.

    maybe the differences in php4 an php5 are not so obvious to someone who doesn’t really use, or understand the major OOP improvements.

    Either way, I think we should be calling these people out as much as we can or php is going to turn into windows where the need to support previous versions (still widely un use) bogs down and handcuffs future releases.

  • 7. Slapo  |  June 9th, 2006 at 6:20 pm

    Try using Zen Cart instead of osCommerce, it’s newer and runs fine, although it is a bit slow.

  • 8. gcornelisse  |  June 9th, 2006 at 6:29 pm

    I just started hearing about Zen Cart. I’ve also been looking at a couple others and ran across a nice list with reviews. Not sure all are PHP5, but I know a couple are because I’ve installed the trial. I have the trial of CS-Cart running and I really like what I see so far.

    Hotscripts - Shopping Carts

    ….but, I don’t want to get too far off topic

  • 9. mgkimsal  |  June 9th, 2006 at 6:33 pm

    Another issue to consider holding people back is shared hosting and control panels. I know Plesk (at least up to 7.5.4) only delivers PHP 4.3.x and MySQL 3.23. Yes there are some ‘hacks’ to get around this, but things in the shared hosting space are stuck, and probably stuck for mostly financial reasons. However, there weren’t many backwards compatiblity issues from 3->4 *and* there was much less invested in PHP code at that point. The shared hosting migration from 2->3 and 3->4 was relatively painless and quite quick. What’s the holdup this time? Compatibility concerns? Not being able to run both at the same time without some kludgy proxy hacks (that’s a big one for many people for sure)?

    The PHP community has grown much larger and more professional (and funded, see Zend, etc.) It’s certainly not because some developers on a few projects say ‘php5 sucks’ that the upgrade/adoption isn’t happening faster - they were saying ‘php’ sucks for years and the major version numbers from 2-3-4 all were adopted *much* faster.

  • 10. karl  |  June 9th, 2006 at 6:50 pm

    As an ASP.NET guy, I’ve advocated that ASP.NET isn’t always the right tool for the right job. Specifically, ASP.NET is wonderfully aimed at enterprise development as well as various medium to large scale projects. PHP, as a toolset, is better positioned to address a different problem space. While I too am generally apathetic towards those unwilling to learn and evolve, there a reality out there that isn’t as straightforward. PHP5 isn’t in the same universe as ASP.NET when it comes to enterprise development. I don’t know _anything_ about PHP6, but I’m positive that nothing short of a total redesign has a chance of making it competitive (FOR THAT PARTICULAR TYPE OF DEVELOPMENT). It’s possible that PHP6 is a complete redesign, like ASP.NET was to ASP and VB.NET to VB6, but it’s important to understand downside of that.
    If you aren’t building the type of sites/applications that ASP.NET/.NET are well suited for, you are far better off using PHP or other similar tools. Otherwise you’ll end up with horrible code that’s as unmaintainable, buggy and slow.
    The point I’m trying to make is to be careful what you ask for. PHP is positioned to capture a very healthy “market share”. It does what it does very well. The more you ask of it to do something else, the more you’ll abandon your faithful core group. Microsoft made that choice with ASP.NET and because of it, the ASP.NET team had to spend most of the 2.0 lifecycle trying to bridge the huge classic ASP gap they created. The VB team is in the same boat. It’s actually surprisingly ballsy and uncharacteristic of Microsoft (long history of backwards compatibility).
    I will admit that it’s certainly possible for both PHP and ASP.NET to find a happy home across multiple types of development. PHP5 does do a good job of starting to introduce some important enterprise level methodologies while making it possible for anyone to completely ignore those to “setup a gallery”. As I’ve already said, ASP.NET 2.0 has done a lot to soften the learning curve. But it’s a hard balancing act that requires a well thought out roadmap and amazing execution. I have no doubt that PHP will make it happen, but I’m sorry to say, it’ll take some time – that’s something I’ve only recently come to terms with in my own development world.

  • 11. mgkimsal  |  June 9th, 2006 at 8:13 pm

    yes gcornelisse, the net makes things a small world. I was googling for you today and came across this site. :)

  • 12. dasil003  |  June 9th, 2006 at 9:33 pm

    I agree that PHP developers need to get on the PHP 5 bandwagon. PHP 5 has a lot of compelling features, but it’s hard to make the switch if you’re depending on open source apps that don’t support it yet. However the last line of your article is particularly telling for me.

    I’ve been in the PHP game professionally for 6 years. I’ve probably written more PHP code than any other language. Over that time I’ve become comfortable in PHP, but also increasingly annoyed with its little foibles. Little things like magic_quotes_gpc and register_globals are easy to work around, but over time make me ask the question: Why should I have to do deal with this? I’m still looking up the order of haystack needle after 6 years. Other PHP4 issues like wonky references, extremely simplistic OOP support, lack of sensible error handling, no namespaces, and other small annoyances have seemed like more and more of a hindrance as my understanding of web applications has increased.

    Perhaps an even bigger problem is the proliferation of shitty PHP code out there. All languages have bad code, but PHP seems to have some of the worst outside of the Visual Basic / Consumer IDE realm. OSCommerce is a great example. The first response suggested trying to help them, but that’s a fool’s errand. Without the rest of the developers getting behind the effort, there is no way to make a dent in the morass of code by submitting patches. That’s why ZenCart forked, but believe me that codebase is not so great either. Part of the problem is that PHP is so easy to get into, you have new programmers taking it up all the time, copying bad practices from hotscripts.

    PHP 5 and 6 are making huge improvements to the language, but now that we’re at the top of the PHP adoption bell-curve these improvements are going to take years and years to trickle down to all the libraries and scripts. As far as I’m concerned its simply too little too late to compete with languages that had strong design philosophies from their inception. PHP is still second-to-none for hosting and easy deployment, and I expect it to stay that way for years if not decades. I will continue to use PHP for small projects. I’m looking forward to PHP 6 and the incremental improvements it makes. However for larger projects I don’t think PHP can ever match the flexibility and power of frameworks like Ruby on Rails, Django, or Seaside. It’s the expressiveness of languages like Ruby, Python and Smalltalk that make those frameworks work so well while PHP frameworks tend to be unwieldy and get in your way.

  • 13. ruzz  |  June 10th, 2006 at 3:09 am

    i think it might be helpful to point out ASP.NET is not a language, it is a development framework/platform. A very solid one, but still it’s like comparing raw php development to rails it’s not accurate, nor fair.

    Like Rails, which sits on top of the “language” ruby, asp sits on top of the pie known as .NET. The discussion here about upgrading to PHP 5 from 4 would be more suited if looked at through the lens of upgrading from .net 1.1 to .net 2.0, but even that isn’t accurate, it just underlines the point.

  • 14. gcornelisse  |  June 12th, 2006 at 1:37 pm

    PHP4 and PHP5 comparison/migration information:

    Changes in PHP 5/Zend Engine II

    Classes and Objects (PHP 5)

    Classes and Objects (PHP 4)

    Migrating from PHP 4 to PHP 5

    What’s New in PHP 5

  • 15. BitRatchet » Blog A&hellip  |  September 3rd, 2006 at 2:25 am

    […] I was googling around and found some people’s thots on migrating from PHP 4 to PHP 5. One point I didn’t see in the original post here was that PHP 4 and MySQL 5 are not present in long-term-supported distributions of Linux like RHEL4. Sometimes the Linux distro is pretty important in terms of software version choice. […]

  • 16. » Get real about PH&hellip  |  October 26th, 2006 at 10:13 pm

    […] Page Summary: I have experiece this with 3 language personnally and probably could find evidence of it for other. It does help to a degree but not enough to make a difference. PHP will have many years to come a first rate development language but it will have to drag itself through the debris of its own flaws and myths. The only salvation is if something radical happens in some aspect of the language that draws the early adopter back to the fold.read more | digg story              […]

Leave a Comment

You must be logged in to post a comment.

Trackback this post  |  Subscribe to the comments via RSS Feed