OK – following on from here and a later comment from Tim (and in fact more this rant from Jonas Maurus);
How about somebody sends me some good pro-PHP rants?
So here’s some pro-PHP ranting…
It’s the execution model
Focused on PHP as an Apache module the two big things are it works and it’s scalable. More to the point no one really has an execution model to compare with it, except perhaps Microsoft with ASP 3.0, which they’ve since abandoned. Before you fly off the handle, think about this one.
Tried to explain the basics a long time ago here – the important thing to take from that (compared to mod_perl / mod_python / mod_* or even “X” application server.) is the interpreter returning to a fresh state after every request (no globals hanging around or otherwise). PHP really is shared nothing. You want scaling? Try here.
Meanwhile, in these days of long tail enthusiasm, other than PHP, you don’t get to hear much about when stuff sucks. Put specifically, don’t bring me your FastCGI unless you’re providing free SMS to go with it, so I can alert myself when it goes down. There are smallish sites I own / run, built on PHP, which I don’t look at for months but are still, magically, running next time I go there – be it impression or not, PHP just keeps on running – restart Apache or reboot and it’s back without sysadmin effort.
Being a little more specific, the execution model PHP gets most testing under is mod_php and CGI, where there’s no “long running scripts” and no need for threads. PHP is optimized to that environment. By contrast Perl, Python and Ruby are general purpose languages and optimized to different requirements. The web is just another platform they support, compared to PHP where the web is the primary platform. The can be expressed in terms of configuration settings like max_input_time and post_max_size – with PHP these problems have had someone thinking about them.
Excellent database support
Lets start with the usual nag here – that PHP doesn’t have a common API for database abstraction. Well that’s always been bogus anyway – SQL itself is rarely portable and writing an application against a specific database requires specific work, so that you’re API happens to be the same as that for some other database is largely irrelevant. That said a common API does make the learning curve easier if you start another project with another DB but PHP’s first priority is to expose “vendor specific” features, like pg_send_query or mysql_unbuffered_query. Put another way, most of PHP’s DB APIs have a one to one relationship with the vendors client API and the benefit there is you don’t lose features or have to fight for them.
That’s not to say you can’t have your DB abstraction cake in PHP – the one I trust most is ADOdb – a native PHP implementation (side note – Python devs may be interested to know John also maintains a Python version of ADOdb). There’s also PDO which is getting there and (I’d argue) something that parallels Perl’s DBI. Should also point out PEAR::DB, PEAR::MDB2 and Creole. And don’t get me started on ORM…
What doesn’t get said is PHP may now have the best (as in most stable and feature complete) across the board db support of any of Perl, Python and Ruby, which, seen from one point of view, makes sense given the number of PHP users. That PHP’s DB support is better than Python’s or Ruby’s that’s probably no news but compared to Perl, was recently surprised to discover that DBI lacks support for Oracle collections, which PHP has. Perhaps that’s just a freak but perhaps not – anyone with experiences to share there?
PHP Arrays
Now the computer scientists typically hate PHP’s arrays, which are both indexed and hashed. Reality is they are not only easy for beginners to get in to, they’re very handy for the web problem (e.g. good fit to ad-hoc XML) and for simple iteration, it’s nice that hashes and indexed arrays unified by common syntax and behaviour. Sure they don’t support everything a computer scientist might want, such as (Python);
points = {}
points[(1,2)] = 2
points[(2,4)] = 4
…but on the web, who cares? You’d hardly ever need something like that and where you do, JPGraph makes life easy enough. Meanwhile performance turns out to be not bad by comparison.
BTW, if you want computer science and PHP, take a look at (current favorite bizarre PHP project) J4P5 (a Javascript intepreter written in PHP). Can come up with endless projects of that nature if you’re interested.
More generally, there’s a virtual web ring (how 90’s) of PHP hate which starts from here. 90% of the criticism you’ll find there is simply irrelevant (one day I’m going to do this in detail, if I can be bothered) – these are either not problems for web development or disappear with PHP’s (rollercoaster) learning curve (e.g. the endless functions in global namespace is irrelevant if you’re writing classes). One day I may also do my own take on why PHP sucks (in the sense of Bjarne Stroustrup and: “There are only two kinds of languages: the ones people complain about and the ones nobody uses”) which I’d expect to be a very different story. Today you’ll have to excuse me for focusing only on the good things.
The SPL Extension
Following on from arrays, this is a big reason to use PHP5 if you’re a programmer. It makes a number of classes of web related problem ridiculously easy to solve and gives you syntactic joy should you want it. Some further reading here, here, here, here and here.
PHP 5(.1) XML Support
One for Tim – XML support in PHP 5(.1) is excellent, thanks to libxml2. And it’s not just that the core parser is good, it’s that you’ve got multiple APIs in PHP to it, namely SAX and it’s faster “invert” XML pull reader, SimpleXML and DOM, as well as the supporting cast of XSLT etc. Of course Python, Perl, Ruby etc. also have libxml2 wrappers but this is still a PHP strength, plus libxml2 has become the core of PHP’s XML capabilities, rather than another alternative.
The stuff that says it works… works
Programmers have obsessions with building better cages for themselves, for the sake of a particular paradigm they believe in. Nothing wrong with that but the road to get there is littered with stuff that was broken or partially complete. For the stuff you need for the web, PHP is already there. That’s not to say there isn’t a bunch of unstable code in PHP – just the stuff you’re typically going to use works.
Put another way, PHP has become predictable, at least for me and anyone willing to travel the learning curve. That means if I need to give projects estimates, for example, I know when I can keep to them. I’ve also found it easy to teach to others – takes about a week to get a programmer able to churn out useful PHP if I can work directly with them. I’d rather trade a (slightly more) verbose syntax and delivering on time against 15 minutes syntactic glory, followed by 10 hours bug hunting and another 15 hours workaround. Luckily not everyone thinks this way or progress would have halted.
Unicode and ICU
Having talking about stuff PHP already has, it’s worth being aware that PHP6 is using ICU as part of it’s “core” – see here, here and here. PHP6 already “exists” under CVS and if it’s resticted to the Unicode changes only, it’s less of a step up than PHP5 and may be here sooner rather than later. You might then be able to argue PHP has better Unicode support than Perl and Python.
Stuck in Little boxes
This is bordering on holy war, which I don’t want. Recently language bickering has been back “in”, and if you take it seriously you might believe Perl, Python and PHP are all dead and there is only Ruby. To me that’s simply Ruby (rightly) jostling for a space alongside the others and it’s best put in perspective here.
Being happy in Perl, Python and PHP these days, watching people cry “This rox, everything else sux” borders between amusing and frustrating. Syntax is only one part of the story. Libraries is, to me, the bigger part – what use is great syntax if you can’t do anything with it or need to spend time re-inventing wheels?
For example Perl is like comfortable slippers on the command line – take me away from Getopt::Long and POD::Usage and get screaming. Little things which matter. And have found Perl capable of pushing big blocks of data around a DB at speeds comparable to SQL*Loader.
Meanwhile have used wxPython in earnest once (book due soon!) – none of the other dynamic languages can compare to it – yes there’s wxPerl, wxRuby (**cough** wxHaskell) and even wxPHP but they’re not mature by comparison – check out Activegrid’s IDE download under “/src/python/wxPythonDemos/ide” – these days we can all write our own IDEs… And Python has the dirty secret of excellent Windows support. If I had time to burn I’d love to take this shell namespace extension demo and the Python libssh2 wrapper and do a GMail drive for scp.
The point is people leap on a language then claim, because it does one thing well, it’s the only tool for everything. It’s really a shame time is being spent on wxRuby / wxPerl or otherwise, given that wxPython is already there. It’s far more of a shame that we’ve invented endless template engines for the web – not just the wasted development time – also the wasted user time in identifying and learning to use them (this stuff drives them to Microsoft). And it’s not just the re-invention – it’s that we not even really sharing ideas or seeing them spread – Jeff nailed templates a long time ago but today you’ll find Ruby developers discussing the pros and cons of curly brackets vs. attribute for templates.
Specific to PHP, if you accept there are some things it actually does well, in particular the execution model, it then becomes more a question of how to get the best out of all worlds. In my view (based on what I’m happy with) that’s Perl at your backend for sysadmin, moving data around etc., Python helping users publish their MS Office stuff and PHP serving it to the world.
Along that lines been looking at Fuse and it’s Python and Perl bindings. Have a very specific interest right now which I guess will tell me how stable this stuff is but, all being well, think there’s potential here for hooking up PHP with Perl and Python, via the filesystem, perhaps in conjunction with libxml2.
In short: PHP’s Schwarz is bigger!







I’m not going to say PHP is perfect, but it isn’t going anywhere.
Everything needed to create a dynamic website is right there and it works.
The syntax is similar to C, so the average C programmer can jump right in.
It’s simple, it’s effective, it gets the job done. I predict PHP will be around for decades to come, just like C has been.
There is no real compelling reason to switch… as much as tech-nerds would like to say there is. My advice to them, stop trying to get everyone else to switch and just use it yourself if it’s so good.
You know, lots of businesses still use COBOL…
February 21st, 2006 at 1:01 pm
> PHP is optimized to that environment. By contrast Perl, Python and Ruby
> are general purpose languages and optimized to different requirements.
> The web is just another platform they support, compared to PHP where the
> web is the primary platform.
thank you… that is exactly why i see that php is the perfect solution for web development. said it a number of times in past threads to various answers, but no — some people just don’t know any better, or just don’t listen :eek:
so, lets all just clap hands…
February 21st, 2006 at 2:12 pm
great article!!!
Added to my bookmarks to be used when the nasty PHP haters attack.
February 21st, 2006 at 2:46 pm
Awesome article. All the links were great and I really like Maurus’s post. Its the first time that I’ve seen a semi-objective PHP put-down :]
I came across PHP and immediately took to it because I could have it up and running in 5 minutes and I could actually use the code to do something … anything (I think this is what a lot of PHP critics miss). Very few other languages can boast of that. I’ve been coding for 2-3 years now and the base I’ve built in PHP/Oracle/MySQL has allowed me branch out to ASP.NET, C#, VB.NET and COLDFUSION (I already knew C,C++ and Java from school) and I’m only just getting familar with the finer points of application design and programming in general because of it.
I’m thankful to PHP for giving me the avenue to pursue my passion for programming, but now that I’ve started programming in C# ASP.NET I don’t know if I’ll be programming much more in PHP. The things that ASP.NET makes trivial for me (form validation, built in XML support, pagination of Database records on page display etc) now seem like a chore in PHP
What I think I’ve figured out is that the more powerful a language is C++, C … the more difficult it is to learn and use and languages that are easier to pick up and use (PHP … and VB.NET – can’t believe I put those in the same category) will always have the problem that very bad code can be produced with them.
February 21st, 2006 at 3:06 pm
Great rant Harry!!!
and you’re right… no single language is a silver bullet… let’s use the right tool for the right problem and we’ll all be happy! (well at least I’ll be) ;)
February 21st, 2006 at 3:15 pm
Nice stuff – some great links in there, and a great rant.
February 21st, 2006 at 4:09 pm
ikeo,
ASP.NET is a great development environment and I wish you all the best luck in your work. However, please realize that you are talking about using libraries that perform a function for you and not something that is unique to the .NET environment. They are simply tools that are part of your environment.
The same form validation, XML, and Database functions that you are getting in ASP.NET can be accomplished in PHP using outside packages. Unlike with .NET, there is not a unified PHP IDE that every PHP developer uses. It can be argued that this is a either a good or bad thing but that is for another discussion. Learning what is available for PHP is one of the “learning curve” issues that PHP developers face.
Good article Harry and thank you for the SPL links.
February 21st, 2006 at 4:14 pm
I understand that, but that is exactly what I’m saying. I don’t want to build an application or a site using extensions or libraries that might not be available to work in a given environment. I want something I build to work right out the box with minimal configuration.
And it cuts both ways too, ASP.NET 2.0 dropped support for XQuery in Visual Studio 2.0 in late 2004. You can still downlad a module that provides the classes that you need to run XQuery but if I built something with ASP.NET and XQuery then it might not work on a given webhost since they’d kick against installing the module.
ASP.NET has these things like web controls, Datagrids, Authentication etc built in and optimized not as separately downloadable libraries and I’m loving the functionality that it gives me. ASP.NET is huge and I’m fast becoming a groupie … but the ASP.NET community is horrible (to say the least). People help you, but they are rude, vague and sometimes a touch condescending. I really miss the camraderie of PHP developers and I’ve made it a point to help out more on the PHP board because of it.
February 21st, 2006 at 5:01 pm
And what is wrong in JSP with custom tags?
Much more scalable and also very simple to use.
Some like Coldtags suite lets you develop very fast.
February 21st, 2006 at 5:14 pm
Nothing if it works for you.
That’s very subjective – see here please. And when done, try this;
February 21st, 2006 at 5:34 pm
That’s very understandable. It steps into where I might do a “PHP sucks” – from my point of view much of PHP’s future depends on Zend’s framework (including whether it actually gets released).
February 21st, 2006 at 5:36 pm
I am a p programmer. Have used perl, php3/4, python
Nowadays I use python to do xml and unicode stuff that php4 is not very good at doing. But for database related ap, I will use php.
Now it seems that php5/6 is gaining the ground back. That’s nice.
But I think we still need to wait some time until more lib/open source software support php5. Like I upgraded my box to php5 then my gallery 2 become buggy and I have no time to solve the problem….
And for some good old server, it is not very easy to compile apache2 with php5.
Most p developers in the net are very helpful, and lots of them have their own good stuff like to share with the world.
That’s the good human nature I like to be with and hope my kid does too.
February 21st, 2006 at 6:14 pm
[...] An oft-forgotten feature of PHP is its shared-nothing architecture as pointed out in this pro-PHP rant (countering all the PHP bashing going on at the moment): …the important thing to take from that (compared to mod_perl / mod_python / mod_* or even “X” application server.) is the interpreter returning to a fresh state after every request (no globals hanging around or otherwise) [...]
February 21st, 2006 at 6:57 pm
Awesome links Harry! I’m looking at getting a Masters in Computer Science (I’m really getting interested in Databases, Parallel computing/Clustering issues) so I enjoyed reading both items. I’ve also been milling around Barnes and Nobles trying to get some advanced PHP books (I’ve already got the Anthology :]) and I recognized George Schnossnagle’s name right away. I was looking at his book “Advanced PHP Programming” just days ago. I liked his book but it was a bit vague … I’m still going to buy it though.
My thoughts exactly. I’ve been thinking that the next stage in PHP’s evolution is to add some sort of framework to its make up (like .NET). I think the flexibility of just being able to script … or do OOP along with a framework that can help automate mundane thinks will really make PHP a monster.
The hobbyists can write their code as they like it, and the Pros can really kick back and have some fun with the new toys.
February 21st, 2006 at 7:42 pm
you are not alone – http://del.icio.us/tag/php+framework, http://www.phpwact.org/php/mvc_frameworks etc.
February 21st, 2006 at 7:54 pm
[...] There is lots of PHP hatred on the web. It doesn’t seem to matter that some of the biggest sites on the web run PHP, including Yahoo and CNET’s own Gamespot. PHP still doesn’t get any respect. Anyway, for all the PHP lovers out there, here’s two excellent defenses of PHP: http://www.schlossnagle.org/~george/blog/index.php?/archives/29-Why-PHP-Scales-A-Cranky,-Snarky-Answer.html and http://www.sitepoint.com/blogs/2006/02/21/a-pro-php-rant. [...]
February 21st, 2006 at 10:03 pm
I love PHP, especially its handling of arrays. A great rant Harry!
I too believe that a framework is the natural evolution of PHP. I would be extremely interested in what people thought about current frameworks. I am currently trying out symfony so far it seems extremely well written, I especially like the tutorial.
Harry, why are you waiting for the Zend framework? Do you really believe that a PHP framework wont achieve acceptance from the majority of the PHP community unless it comes from Zend?
February 21st, 2006 at 10:45 pm
php.net documentation Good.
With comments. Double Plus Good
February 21st, 2006 at 11:21 pm
Outstanding counter to the anti-PHP sentiment that Tim’s post brought out. I have nothing to say really, until I absorb all of this. Thanks for your post and all the terrific links.
February 22nd, 2006 at 2:28 am
Great rant. Don’t forget the documentation. The manual has to be one of the best ever made.
February 22nd, 2006 at 2:59 am
It’s possible a community framework could succeed. Personally, if I had much more time to spare, I’d be working full time on / with WACT, which has some outstanding code and ideas.
But the problem is, given time constraints and working in an environment where only J2EE and .NET normally get a look in, a framework not only needs to sound credible (having IBM as a committer helps), it also needs to have someone committed to supporting and maintaining it.
The latter points is in fact the most important – if you adopt a framework only to find, say, significant portions break with PHP5 and the maintainer has given up (not uncommon), you’re likely to find yourself maintaining not just your code but your own fork of the framework. Add to that the learning curve any worthwhile framework carries and you start to want a standing target.
February 22nd, 2006 at 4:39 am
Php Code similer to Delphi, C++, Visual Basic.. it’s a mix so that people can catch up easily .. of course not perfect.. But can create a crm like SugerCRM .. i’ve seen PHp based forums With 200,000 users and every moment an avarage of 350users online.. serves well and fast.. THink about compiere or similer systems.. need a huge resource and such a painful way of deployment.. Also as a base you will need Oracle.. Which is already a full time resource hungry lion. A standard web host doesn’t provide support for jsp servlets.. and of course.. Java is still slower..
February 22nd, 2006 at 6:30 am
[...] Merely a linkdump, since I haven’t read them through properly enough to have any opinions: Going dynamic with PHP from IBM developerWorks, and a pro-PHP rant from sitepoint. [...]
February 22nd, 2006 at 7:10 am
I’m not so sure about that
That’s by George Schnossnagle. Java is compiled to byte code and PHP is interpreted so I don’t see how PHP could be faster than Java.
February 22nd, 2006 at 7:57 am
I just want it to all work out the box. I want to install PHP on my webserver and have all the added functionality of the template available to me right away. I think the only way that will happen is if Zend integrates that framework with PHP the way Microsoft has done with ASP.NET or how its done in Ruby on Rails.
BTW WACT looks really nice, I wonder if Zend took a look at that in coming up with the Z framework.
February 22nd, 2006 at 8:07 am
One thing that I abhor about PHP is that the language itself has bugs and they just don’t get fixed. Every time I sit down to do some serious PHP work, I hit problems in the underlying language… I file them in PHP’s bugzilla, and they get triaged either to “feature request” or “fixed in 5.1 cvs” (like anyone is going to be using 5.1 within the next few years… it’s hard enough to find hosts with 5.0 installed).
And these aren’t trivial bugs… it’s horrible things like objects randomly morphing into references to objects so things like = stop working!
February 22nd, 2006 at 10:36 am
In general Java is much faster than PHP when the runtime is loaded – put simply far more money into making Java fast than PHP.
But PHP probably has a smaller “startup” cost per request (at least when running as mod_php under Apache) than Java, so the Java guys tend to keep their runtime (and application objects) in memory all the time.
Long discussion here which I’ll kill with “performance != scaling”.
Know what you mean and it’s true to an extent (recent reference patches were painful). At the same time, most people evolve a style that avoids the hairy parts or aren’t even aware there are hairy parts. It’s wise sometimes not to be too clever with objects in PHP. Think if you want to get that serious with your code, you need to stay with the latest PHP release.
February 22nd, 2006 at 12:25 pm
Harry … I’m a little dissapointed in you … such a long rant and no mention of Java … not even once :)
Urgh … from where did you heard that ?
Actually Java is faster, even if you use Zend Accelerator, because of improvments like adaptive optimizations in the latest Hotspot VMs.
PHP does scale though, and I agree with Harry in this rant.
And … who gives a **** about standard webhosting ?
Want cheap JSP webhosting ? You won’t find it for $5, but for $15 you can find anything, including virtual private servers … and $15/mo is really that much ?
February 22nd, 2006 at 2:10 pm
[...] To hear some good things about PHP, read this Pro PHP Rant at SitePoint. See—not everyone thinks PHP is so horrible. [...]
February 22nd, 2006 at 2:17 pm
This is nice article with a one glaring omission from SPL links. The definitive introduction to SPL is http://www.phpro.org/tutorials/spl.php.
Keep up the good work
February 22nd, 2006 at 4:36 pm
Thinking the follow up might be called “PHP sucks. But Java sucked first”
February 22nd, 2006 at 4:50 pm
[...] Link [...]
February 22nd, 2006 at 5:14 pm
php is a great language for opensource community, very easy to code, hack and very efficient.
But in the past when I think of doing something not so traditional, I don’t find solution in php4.
Maybe php5 have the answer now.
If you throw this rant into python-list@python.org, you can see what is a real bash … Lots of helpful good hands there
When I used php, I hate learning python.
When I learned python, I rarely go back to php…
February 22nd, 2006 at 5:18 pm
[...] When you build big systems — and I’m fully expecting Ookles to exceed my last gig by at least 1 order of magnitude** — then you get ridiculously conservative on what you let in the firewall. Even code from experts that you know personally, that write stellar books, hang with at development conferences, etc often just doesn’t work. IT environments these days are so complex that its hard to know why stuff doesn’t work at times. For example, we all like to think “its a LAMP app” and then assume that simple basics like OS distro, MySQL version, GCC libraries, etc don’t matter and that stuff will just work. I’d argue that that’s correct in some cases (small scale apps) and quite incorrect if you’re trying to scale something out. A different distro or a different version of GCC can often make all the difference. The classic case in point is memory leaks which are really, really nasty when you’re deploying large apps in Foo (where Foo is Apache / PHP / Etc). Yes PHP itself is a shared_nothing model as Harry Fuecks recently (and brilliantly) pointed out but if you have a memory leak in a php extension then it can fairly easily take down your Apache boxes. And, if you deploy an extension globally across all boxes you have, which you would do with something like this then when it, under heavy load (possibly; remember I haven’t tried it yet), leaks memory then you’re in a hellishly hard debug cycle – because at that point — you’ve forgotten that you even installed it. And then you’re playing whackamole and doing crazy ass stuff like writing shell scripts around your apache processes to terminate them after they’ve been active for Foo minutes / hours / etc. [...]
February 23rd, 2006 at 1:30 am
[...] On the other hand, you have Harry Fuecks having his pro-PHP rant. “Shared nothing” has been one of his main argument why PHP is scalable. And it works — with Apache and mod_php — as the web development platform it was designed to be. [...]
February 23rd, 2006 at 4:36 am
PHP’s array handling is only hated by people who are stuck in the past. Arrays of this nature are pretty much the standard now. Javascript’s objects are nearly directly mappable (see JSON). This works extremely well for the web. People need to learn that the web is not the server and the web is not the desktop. Get over it.
Anybody who doesn’t think that PHP scales well has probably never heard of a small web company known as Yahoo! (sorry, it had to be said).
At what? Certainly not at serving web apps and the common AJAX stuff that we’re seeing nowadays. As a general-purpose language? Yeah, probably, but C++ is faster still. What’s your point?
PHP and java are both compiled to byte code and both fed into an interpreter. The difference is that java is compiled at package time, and PHP is compiled at run time. That’s where things like APC and Zend Accelerator come into play. Beyond that, performance is mostly dictated by the performance of the interpreter implementation. There’s no apples to apples comparison. PHP extensions are more or less just a function call wrapped around C code, which will outperform Java in the vast majority of situations. In other words, the only real measurement of performance is real-world scenerios, not hypothetical ones.
February 23rd, 2006 at 7:26 am
Also I agree to many points, there are really reasons not to use PHP.
PHP5 breaks backwards compatibility. So no webhoster is going to install it, because he doesn’t want to break the applications of the customers.
This is a showstopper.
Therefore it doesn’t matter at all if version, 5.0, 5.1, 5.5, 6.0 fixes any problems and introduces new features. And one feature which I’m really missing is a decent Unicode Support. In Version 5.5 you say? I don’t have the time.
So, if no hoster is going to upgrade, it doesn’t matter anyway and I’m stuck with PHP4. But I want the features now, without the need to rewrite my complete applications. Bye bye.
February 23rd, 2006 at 8:18 am
[SitePoint Rant]
Ever bothered to have this rant a printable form ?
Printing in IE 6 or Firefox 1.5.01 displays:
“Unfortunately, as SitePoint takes advantage of web standards that your browser seems unable to support, this site’s layout will be simplified in your browser”.
Er ?
Firefox 1.5.0.1 ?
IE 6 sp2 ?
Opera 8.5.2 ?
Konqueror 3.4.3 ?
None of those support web standards ?
Which browser am I supposed to use ?
Amaya ?
The layout is to “simplified” that the article does not even print as a whole in most of those browsers.
Ever bothered to respect webstandard instead of only saying you respect web standards ?
I had to copy/paste the text in a word processor. :-(
SitePoint -1
February 23rd, 2006 at 8:53 am
You’re spot on about the arrays :) As a java learner it’s been hard to adjust to the rigid structure that arrays in java have :)
February 23rd, 2006 at 3:01 pm
Can someone explain to me why (technical details welcome) Java is faster than PHP. I was always under the impression that the reason why was because Java was compiled to Byte code. But I’ve been doing a lot of reading lately and I came across this on Wikipedia
http://en.wikipedia.org/wiki/Java_programming_language.
Thanks.
February 23rd, 2006 at 7:15 pm
sebsauvage, fair point.
Not intentional. When we refitted WordPress for our layout we rewrote the screen CSS but clearly missed the print-specific CSS. We’ll get that fixed.
February 23rd, 2006 at 11:01 pm
Interesting article Harry. The PHP vs the rest argument will never die, and long may those religious wars continue. However, I’d like to point out that there is no way any language, Perl included, can load data into Oracle as fast as SQL*Loader – unless you stick to conventional path loads. SQL*Loader has the direct path load option for bypassing the SQL layer and it’s blindingly fast. If you have an Oracle data warehouse, there’s no alternative for loading large amounts of data.
February 24th, 2006 at 4:31 am
Point taken – was making blanket statements as with most of this rant – better might have been “fast enough for my purposes and faster than other scripting languages, hence rumours of Perl’s demise premature”.
February 24th, 2006 at 10:44 am
How quaint, another PHP developer trying to claim that PHP is the greatest thing since sliced bread, even though the module _still_ doesn’t work when Apache 2 is in worker MPM mode. Come on folks, it’s the 21st century, certainly you can work well with a multi-threaded webserver.
February 24th, 2006 at 6:59 pm
I found a benchmark comparing a couple of programming lanuages including PHP. I ran it myself and found PHP to be faster than python and ruby. But much slower than Java and ofcourse C. You can see the results in my blog.
February 25th, 2006 at 8:56 am
[...] SitePoint Blogs » A pro-PHP Rant settle (once and for all) that php is not out of fashion wrt ruby (tags: php) [...]
February 26th, 2006 at 12:22 pm
An other very nice thing about PHP is the community supporting it … the documentation !!! The best of all!
Geza
February 27th, 2006 at 10:51 am
Quaint or not, this issue of thread safety needs shooting down as it’s something people clearly have some quaint ideas about – Jonas for example also gets it “wrong”.
First of all the majority of the core of PHP is thread safe and . The problem is extensions (third party code) that PHP uses, which may or may not be thread safe. In particular I believe (not 100% sure) the PCRE extension is
not thread safe (the project is maintained here). You want to rewrite PCRE – be my guest.
Certainly I’d expect extensions like GD and Curl to need looking at. Also system calls like localtime(), gmtime(),
readdir(), rand(), and srand() will depend on the operating system implementation – in other words you really need platform independence (Java, .NET) if you really want to “go threads”.
It’s also worth pointing out that it’s not only mod_php that has this problem. From “Practical mod_perl” – http://modperlbook.org/html/ch24_03.html
No doubt mod_python and mod_ruby have similar issues.
Seen from a distance, perhaps the “mistake” was Apache’s in choosing to use threads in the first place, given likely issues some of their most popular modules would have to face. I don’t know enough to say if there were any valid alternatives but perhaps there’s room to do something with Asynchronous I/O.
February 27th, 2006 at 11:54 am
Hi,
I love PHP and glad to see a good pro PHP Rant.
Cheers
Ron
March 2nd, 2006 at 3:33 am
One thing that should be no suprise to anybody about the squawkings of PHP not being scalable is that they are allways made by those that most likely haven’t designed and implemented a cluster. I’ve done so now with VB aps and PHP sites, dealt with the issues of DB fail over operation in a clustered environment, and done so with both software and hardware Cluster managers. One thing I noticed right away is that the solutions were in the vast majority of cases not language/platform dependent.
There is one thing I’d like to clear up. Shared Nothing isn’t in some way a part of the PHP language/platform. It’s the logical arrived upon conclusion when deploying it in a Highly Available Load Balanced Fault Tolerant environment.
I sorted these issues out for myself in 2001 and had great fun doing it.
March 2nd, 2006 at 9:23 am
If you are going to pick an example to demonstrate PHP’s scalability then I would have thought you could come up with a slightly more professional example than WikiPedia! (But then maybe you can’t?)
I also fail to understand why you think that ‘the template problem’ should be ignored – no-one has solved it, and no-one ever will, because it is not possible to completely seperate any code layer from its neighbours.
March 2nd, 2006 at 9:51 am
I’m not 100% sure what you’re trying to suggest there and what your notion of professionalism is.
What I will say is wikipedia is fascinating because they have some unique technical problems; extremely high traffic combined with a large number of writes. I doubt there’s any technical organisation on the planet (i.e. not Microsoft, not IBM, not Sun etc.) which could do a better job (or even have the experience to start). What’s also interesting about Wikipedia is “they” (I don’t fully understand who they are as an organisation) publish a good deal of information about how they do it, which everyone can learn from. The reality is it’s not PHP that’s scaling – it’s PHP that’s not causing a problem (or PHP that’s not getting in the way) while stuff like squid sorts out the rest.
Do your own research – you’d might be surprised by which big sites run PHP.
That’s not what I’m saying – specifically, that doc categorizes the problem but does not prescribe solutions. What it offers is a basis for analyzing template solutions for their relative merit as well as providing a common reference point for people to describe their solutions. By understanding this and what other people have done in your preferred language, you may be able to avoid re-inventing yet another wheel and save yourself (and everyone else) time.
In general the point is there’s a bunch of stuff (templates is just one example) which has already been well solved one or more languages – Perl (CPAN) for example is a wealth of examples, good ideas and reference projects. In PHP some categories of web problem have been well solved. Unfortunately many people take a blinkered view and insist of re-inventing wheels (and mistakes) without looking at those who have already been there elsewhere.
March 3rd, 2006 at 4:53 am
[...] I’ve been blissfully neglecting this site for months with the assumption that a large part of our goal was completed. After watching good people like Martin LaMonica and Jon Udell balance out the mainstream tech press with coverage of lessish tools and languages, and having seen forward looking companies like RedMonk inject themselves into the traditional analyst racket with smart, honest, and unignorable critique, and having seen herds of Java luminaries migrate to simpler, more agile tools and languages, and after hearing Bill Gates say that less code was the only metric, and having watched David, Bill, Ian, Adrian, Phillip, Aristotle, Harry, Mark, Mark, Chad, Curt, James and many other extremely talented programmers dismantle all the common hollow arguments for superfluous complexity and replace them with simple methodologies and working code, after all that I just figured there wasn’t much to do around here. [...]
March 12th, 2006 at 9:27 am
[...] Otherwise, Python hasn’t picked up the kind of following in help sites (forums etc) that PHP has, although those that exist seem better focused and more likely to result in informed response. Fundamentally, I’d still argue PHP is better suited for web applications (perhaps there’s room for a Py2PHP here via PyPy?) but in terms of “right tool for job”, there are many areas where PHP is the wrong tool… [...]
May 16th, 2006 at 7:07 am
Good article but the conclusions are a bit exaggerated. Best database access layer in PHP? Well, have you seen Hibernate? Best framework for WEB? Maybe PHP’s templating systems are good, but Java is not worse with Struts, Cocoon, Tapestry or Velocity. PHP5 object model? It’s just like Java without some features – generics and annotations. Are there any business rule engines for PHP like Drools? Can you have database connection pools, remote objects, object cache without implementing it all by yourself? Have you got any support for unit testing? Can you easily implement IOC concept in your application with any of PHP tools?
How do you manage to maintain a 1000+ files application written by 10 persons without packages/namespaces/modules or anything like that? Can you make a PHP webapp that runs anywhere, without a need to have a webserver (by using embedded webserver)? What about security? Can you run PHP in a sandbox and control exactly what it is allowed to do and what not?
One of the biggest advantage of PHP is its simplicity and easy learning curve. Great for beginners and small sites. I don’t think it sucks. But when you get more experienced, you realize there are lot of things in the world around you do not have in PHP. I don’t see any reasons why use PHP if I am already experienced in Java/C++/.NET.
May 20th, 2006 at 12:29 am
Nice article and some nice comments. In my opinion, all languages tend to borrow syntax and features from their counterparts every now and then. PHP borrowed from languages like Perl, C, C++ and others. Java borrowed a lot from C++. However its because of innovation why these languages are surviving. PHP introduced inline code which was later used by JSP, ASP and most other languages. Allaire Coldfusion used tags for scripting, which was either incorporated or supported in most languages.
PHP doesnt have the extensive frameworks or templating engines like Java or .Net has. However, its not because PHP is incapable of producing such frameworks, but because they aren’t the elegant solutions that the majority of developers want. In fact, I find these extensive frameworks to have a higher learning curve than the programming language itself.
Maybe until a simple solution comes out for the simple problems of code separation and scalability, we’ll keep arguing over petty template engines and frameworks.
July 5th, 2006 at 4:16 am
XGANiCJQbR u35MDmIkxd2 OMtgBwLVGravU
July 6th, 2006 at 11:59 am
Well many arguments to and against PHP, what really sucks the most is that most of the arguments against PHP, can be played agains most other languages.
As a PHP, Java and Delphi Programmer. Delphi is good for enforsing structure, and is clean, and great with plug ins with a fast GUI environment. and people may use it as an argument to say that PHP code is messy, unstructured etc, but mark my words, Crap programing, messy structures in not a fault of the Language, it is a fault of the programmer or development process and procedures. I have seen and Debugged other peoples code in many languages, and seen some real crappy implementations, but not always the Programmer fault, usually the fault of the Busines modals, who get new programmers to add or change functionality in code wrote by another Developer in the past, and not allw time for the new developer to learn how it is structured, and do it write.
So those idiots who are Against PHP, are in most cases the cause of most of the bad code in all Languages.
August 3rd, 2006 at 12:33 pm
I find the PHP documentation to have a lot of errors, or stuff like PEAR is just plain buggy.
For instance, I needed form data validation. I used ereg and it failed. Hmmm. I took an example from and tried another from php.net with the same result. So, I tried the latest PEAR Validate module. The email validation randomly failed. Yes, random. WTF? I also made a logger which reported an error in the module. Great testing, thx!
So, I go back to ereg for naother round and discover IT WILL NOT WORK WITH DOUBLE QUOTES. Yup. The docs show expressions in double quotes, but it FAILS to evaluate. Single quotes? Worked.
I find a lot of this type of crap in PHP and other strange behaviors, and it’s unacceptable.
If the core runtime can’t be fully trusted( sorry, 95% stability doesn’t cut it in my world ) and the code from supposedly top notch places like PEAR can’t be trusted, then perhaps it explains why PHP’s detractors feel as they do.
September 7th, 2006 at 4:54 am
.. Geez o pete’s. What a a bunch of cry babies in here.
Let’s get real here…. how many of you have ever release a product that had bugs, that you had to come and fix later. I bet everyone on this list has made mistakes and/or fighting some right now. No fault of what Lang you’re using but just honest mistakes or situtions you didn’t test for. Why get all worked up over what Zend, Sun, or Microsoft puts out if it doesn’t work in YOUR situation.
GET OVER IT!
If ASP.net works for you… so be it. If you think Java is faster, who the freak cares! All of this talk is subjective and has many variables… and many of you make very vague statements that have no meaning.
For example.. many of you say PHP is good for smaller projects. Define small! Is small in the number of features, is small the user base, is small the number legacy or remote systems it must depend on? 50K users with a small feature set is still a good PHP setup. 20users on a HUGE feature would still be a good for PHP. I’ve been on a lot of projects… and 9 out 10 times… The IT department or Tech lead makes the project more complex than it should be.
And about Unicode in PHP6, yet another .. who the freak cares… about 1% of you have to worry about other non-english chars. If this is problem… Don’t use PHP its just that simple. I don’t understand why smart people have such a hard time figuring out simple problems. Everybody here knows more than one language… and this is why!
Bottom line.. the point of the article is to Learn to use the RIGHT tool. Don’t be a moron and complain about something in Lang A that works well in Lang B. USE Lang B then ya loon!
September 14th, 2006 at 5:22 am
balzac’s got it – I just got through finding out that the PEAR string translation / internationalization module doesn’t support CJK if you’re using a database with it. Despite scanning through hundreds of pages of (mostly auto-generated, of course) documentation, Googling, and spelunking through the code of the package itself, doing all my due diligence, somehow that didn’t seem to get mentioned. Sure, it’s still in beta (though that’s quite de-emphasized too – I didn’t find out until I went to install it, and it’s the only package of this kind mentioned in the PEAR Manual) but “Oh, by the way, the Internationalization support leaves out a third of the world’s population” would have been nice to know.
And as Faruk Ates said in response to Tim Bray’s root article there, “…a lot of skilled PHP coders have become incredibly elitist and rude.” If so it comes from the top – PHP.net, not a single web-based forum or even a link to a web-based forum? All discussion is done through USENET newsgroups. Not too welcoming to the newcomer, if you ask me – not only is it a pain in the butt to go dig up a newsreader, but of course for the rare individual these days of what the USENET is, there no explanation whatsoever. Much less a screencast or anything like that, God forbid. Keeps the rabble out, you know.
But oh, the news server does convert your smilies into little gif images when you post. Gee, thanks guys.
November 6th, 2006 at 8:04 pm
php guys please read this
true:spaghetti-code is a result of spaghetti-mind
also true: i cannot understand the features of a “better” language, so i stay with my spaghetti (Sapir-Whorf)
true:java needs more memory than php
not true: java is slow
look here
ask yourself: why is php so easy to learn?
February 15th, 2007 at 1:27 am
Article Opinion <a
April 10th, 2008 at 10:35 am
Truly, exceptional post, nicely written.. thanks…
php application development
January 13th, 2009 at 7:40 pm