Wednesday, 26 September 2007

PHP double plus good?

I've just read this article about how PHP was better for one user than Ruby on Rails. It's given me a lot of food for thought about where I go with PfP Studio (but I'm not short of ideas - just time to code!). James Gosling's comments that PHP is only really suitable for web-based applications seemed a bit unfair, but thinking about it, they really demonstrate one of the main areas where Java fails as a web programming language.
Sure in PHP there are bindings for GTK, ncurses and rumours of Qt/KDE bindings, but the Garbage Collection problem remains - AFAIK PHP handles Garbage Collection by way of reference counting, but there are scenarios where an object can have a reference but still be garbage (actually I can only think of one, with variations, where two objects reference each other, but aren't referenced by anything else). Java can cater for such a scenario - but this comes at a cost. In Java GC is always a trade off between throughput and pause times. For PHP running in a Web application, its simple - at the end of executing the script, delete everything! However this model doesn't really work for long running PHP programs.

I suppose if PHP wants to be taken seriously for non-web applications it will need a tracing (reachability) based Garbage Collector. If it does come, I hope I can still switch it off for my web applications!

1 comment:

  1. Some time after I wrote this, PHP got a new Garbage Collector. More recently the phar support means that it's increasingly becming viable to build standalone apps using PHP.