Monday, June 08, 2009

Maximum failure: PHP 6 deprecates short tags

I just discovered that PHP 6 is officially deprecating short tags. I'm sorry, but short tags are incredibly useful. They should be turned on for every server. They simplify coding dynamic actions within HTML. Plus, you get the added bonus of using:

<?=$x?>

Which is short for:

<?php echo $x; ?>

Compare: 7 characters vs. 17 characters. The latter is over twice the length, quite unreadable, and, from personal experience with large code bases, unmaintainable! Typing 'php echo' in every time I want to execute/display data that is hosted within the PHP engine is ridiculous. This is a step backwards going in the wrong direction.

The lame excuse for removing short tags is XML. PHP is for HTML, not XML.

I write PHP code quite regularly. Prior to PHP 5, PHP stunk. PHP 5 really changed my view of scripting languages. PHP 6 is going to ruin that view as we will return, once again, to the dark ages of software development. What really gets me is that someone made a decent recommendation and the PHP development team scoffed at the idea and one person even had the gall to suggest that syntax highlighting is all that is needed - let me point out that blind PHP programmers probably don't want to hear JAWS attempting to speak '<?php echo' over and over again and syntax highlighting is a useless recommendation to a blind programmer. I can imagine a small army of blind PHP programmers beating up the PHP developers (especially the one developer who made the recommendation to use syntax highlighting) while blaring an audio recording of JAWS speaking '<?php echo' over and over.

XML seems to be the pervasive reason. I personally dislike XML and wish it would go away (I also wish Ruby, Perl, and Python would go away too - all three are equally terrible languages - and, yes, I've used them all). I've used XML enough to know that it is a terrible storage mechanism for any data. JSON is better but still not perfect. The PHP serialize() function gets even closer but is a language-specific solution. XML is hereby a lame excuse for not coming up with an alternate short tag strategy.

If XML is sooo important, then simply recognize the sequence of characters '<?xml ' and ignore it. It is already invalid PHP code, so fix the problem transparently. Oh the horror! Three lines of code at most is all that is needed. This whole issue is over a data storage format that isn't commonly output by PHP, is a terrible storage format to begin with, and is over the two starting characters at the very beginning of the storage format. Most people DO NOT EVEN USE XML in the first place! Requiring '<?php echo ' every time output is needed from within the PHP engine in HTML is a surefire way to tick people off. Especially when they learn that the reasoning is the two measly characters at the start of a XML document.

Good grief. I can't believe I'm having to tell the PHP developers how to write software. I'm now going to start tagging posts with "maximum failure" for areas where programmers have failed spectacularly to see the simple solution to a problem. End-users (PHP programmers) want short tags in PHP, the PHP developers see a singlular issue with XML and proceed to blow the whole thing out of proportion, and there is an easy fix (see previous paragraph) that allows both camps to be happy - it is as simple as that.

I'm hoping that as soon as PHP 6 comes out of its internal development cycle and becomes the official release, there will be a significant (read: massive) backlash in the short tag department. In other words, I'm hoping the PHP developers will be forced to add short tags back in and undeprecate them. The only reason there hasn't been a huge backlash already is because: No one knows they are already deprecated, deprecated functionality is rarely enforced, and people are too lazy to rewrite code that works just fine. So, I have one question:

Can the PHP internal developers mailing list handle a million programmers dropping by and asking the same question over and over and over and over and over and over again?

Edit: To date I've rejected all comments to this post. People are attacking me personally and completely ignoring both the purpose of this post and this blog as a whole. This is my rant blog - a place to let off steam - if you don't like it, then don't comment and simply leave. Sheesh.

4 comments:

John Peterson said...

Amen brother. The php core team is smoking crack. I use <?= all the time and think <?php echo is a waste of time and very ugly... Maybe its time to jump ship and start developing in Ruby and Rails...?

Thomas Hruska said...

PHP, at the moment, is the only good web language. I agree with you about the devs smoking crack. My experience with Ruby (and Rails) is that, without Rails, Ruby is worthless. In other words, the framework makes Ruby rather than Ruby making the framework. PHP is simple and stands on its own, which is why millions use it. Removing simplicity goes against the very foundation upon which PHP is built. PHP 5 really made the language solid - it took the best of the best, built on it with tons of additional functionality, and yet maintained the things that make it simple to use such as short tags (it also introduced serious Zend core performance improvements).

Cornelius said...

I don't know if this is still up to date, but according to them, they concluded there won't be any <?php =

Good news for you is, they decided to keep php short tags :-)

Thomas Hruska said...

Cornelius - At the top of the page of the meeting notes, it says "Paris, November 11th and 12th, 2005". Visiting his root directory (removing the 'meeting-notes.html' from the URL) shows a list of PHP 4.4.x builds. You got my hopes up though. The links in this blog entry are from April 2009.

Post a Comment