September 20, 2004
Why PHP still stinks
Yoz just wrote an excellent counter-point to my PHP overtaking Perl doesn't matter post and argues that the Perl community should be bothered about PHP taking away their market share. Yet I'm still not convinced, and here's why.
Let's take a look at what made PHP so wildly popular:
-
Executable PHP scripts in any folder, not just inside your
cgi-binor whatever directory you manually arm for scripting. - The possibility to shuffle PHP code within HTML.
- No modularity, no namespace separation, 3079 functions in the core namespace.
- "No nonsense" procedural-style API with few hints of encapsulation or abstraction of concepts.
Every single point in this list is evidence of a bad design decision, and for any serious developer a valid reason to flush PHP down the toilet and never look back. For the Average Web Grunt, however, priorities are different. He wants to know how to display shit in the browser. He wants to know how to get shit in and out of his database. He wants to get his shit done regardless of the collateral damage involved. And for this purpose PHP's design decisions work like a charm.
The reason for PHP's success? The Average Web Grunt gets away with it. Future-proofing his code is not on the top of his agenda, or that of his clients. He doesn't develop in teams. And for the most part his applications are simple enough that the PHP school of doing development doesn't yet rear its ugly head.
In my previous post about PHP I claimed that "PHP's crudeness is actually by design in order to lower the barrier of entry for people who struggle with other things than programming in their day job.", to which Duncan replied with a trace of cynism:
Yes, I'm sure all the 'amateur' PHP 'kids' are pleased to be writing code in a language whose 'crudeness' is there to benefit them and make sure they get their projects done on time.
So you're going to tell the Average Web Grunt that it's much nicer having to include libraries for any functionality that doesn't belong in the core? You're going to tell him that he's much better off having layers of abstraction between him and his data? That handlers are so 1985 and namespace pollution is a bad thing? That he should learn to work with objects and divide his application into tiers? YEAH, RIGHT.
For thousands of people, PHP is just what they need. Easy to learn, easy to copy & paste and no hard concepts which they must wrap their brains around before they can get shit done. Side effects like awfully designed and unmaintainable applications don't matter for them because due to the the nature of their projects, design, maintainability and complexity are rarely an issue.
Does that mean that other languages are already the holy grail we're looking for? Certainly not. Perl in particular has many grave deficiencies, like the weirdness that Larry Wall calls OOP in Perl, or the difficulty of installing stuff when you're on a $5/month shared server account. What I'm saying is that different user groups have different ideas of what constitutes a good language, and you're not going to take away PHP's pie without doing away with all the best practices that only pay off further down the way.
Comments
I am sure you are right, it looks like PHP5 will be quite a bit better. I used to be a perl programmer but found I could do the same coding in less time with PHP.
Perl has made some gains in the mainframe market. My father works for Freddy Mac and he uses perl now.
I am interested to hear what other languages besides perl and php you like for the web. I have been hearing alot of great things about phython.
Posted by Chris Brainard (#)
Chris: As for loosely typed languages, I think that Ruby is currently the best thing there is. Ruby feels like someone sat down, looked at what was out there, and created a language that was RIGHT from tip to toe. By all means have a look at it.
Posted by
Henning
(#)
You criticisms of PHP are not very compelling. The quality of code in an application project is a function of the ability and training of its programmers, not the features of a specific language. There is poor code - from a software engineering standpoint - written in every language and great code written in every language. I'm speaking from the vantage point of 25 years of programming experience and teaching computer science through the graduate level.
Some of the worse code I've even seen was written in Perl. My God man, all variables were global until just recently.
Five years ago 90% of my web-related programming was done in Perl, today I don't use it any more. Why? I can code the same application in a half to two thirds of the time in PHP as opposed to Perl.
If you prefer Perl over PHP, that's your choice. However, you should come up with better arguments - not simply your elitist perspective - if you want to dissuade others from making the switch.
Posted by Urb LeJeune (#)