Link: PHP is meant to die

Apr 26, 2013  

TL;DR: PHP is still a poor choice for continually-running processes. See this post for context. Read on for more proof.

There’s been some reaction to the previous entry. Some people agreed, mostly seasoned PHP folks, some others just didn’t. Yeah, apparently it pleased or infuriated more than two folks in the entire Internet.

First and foremost, a correction to previous statements: PHP’s 5.3+ enables garbage collection by default, it’s an opt-out feature, not opt-in. So it’s probably enabled in all your scripts, even the fast-dying ones, if your PHP version is recent enough and you didn’t do anything funny to your php.ini file.

Yes, I already acknowledged that PHP has a garbage collection implementation starting 5.3.0 and up (opt-in or opt-out, that’s not the problem). I also acknowledge that garbage collection works, and is able to take care of most circular references just fine. However, if you’re one of the many that think “hey, no one should be using anything below PHP 5.4 nowadays”, you’re clearly too young to remember how much blood, sweat and years it took to get rid of PHP 4, even when PHP 5.0 was reaching end-of-life, 5.1 was healthy, and 5.2 was already in the works.

Anyway, as previously stated too, garbage collection is a great thing, but not enough for PHP. It’s a borrowed feature that does not play well with old fundamental decisions inherited from the original design. Garbage collection is not a magical solution for every problem, like many tried to argue about. Let’s illustrate with another example.

Very interesting read. PHP dying at the end of every request is a feature of the language, but can lead to some problems if you want to use it for long-running processes.