December 10, 2010

PHP is falling apart (or Why we need ‘finally’)

Kevin Hallmark @ 11:58 am —

PHP is crumbling.

PHP 6 was delayed for years and now sits abandoned as they restart the effort. In the meantime, a bunch of features are being backported to PHP5.x branches. Each new 5.x release has more features from what would have been PHP 6. PHP is stagnating.

The PHP core team has fallen apart. There is no leadership. There is no guidance. There is no logic. There is just a cobbled together release of miscellaneous features that are somebody’s baby.

For example, ‘goto’.

‘Goto’ should not be implemented in any modern language, period. It’s not needed. Yet, PHP chose to implement this in version 5.3! The reasons for adding this were dubious at best, showing a lack of language design skills. You can read all about my opinion on goto here: http://www.littleblackhat.com/blog/2009/11/php-5-3-and-goto/

I recently found this little gem on the php website: http://bugs.php.net/bug.php?id=32100 (thanks @lesmothian).

The best (and only) comment we get about why there is no ‘finally’ block is “We’ve had long discussions and came to the only conclusion that we don’t need that, for more search the mailing list archieves(sic).” Of course, that conversation can’t be found in the list archives. Does that matter? Of course not.

Finally is part of many modern programming languages: Java, Javascript, C#, Ruby, Python, Objective C, Perl, VB.net… the list goes on. Many of these languages and their designers abhor ‘goto’ and praise ‘finally’.

The use cases for finally assure proper memory management and resource deallocation. Without it, the chance for a mistake in control structure flow increases significantly. Additionally, unless I reraise the exception, it short circuits my app wide exception handling code. Reraising deletes runtime information about the source of the error.

Finally results in cleaner more reliable code. It should be implemented in PHP.

This essay only touches on the idiotic decisions of the PHP team. First ‘goto’, now ‘finally’. Suffice to say, I am getting less and less attached to PHP by the day. I hope that one day the php team gets some leadership again.

Leave a Reply

Logged in as . (Logout)