<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: The Standard PHP Library: Worse gets better</title>
	<atom:link href="http://www.sitepoint.com/blogs/2004/09/13/the-standard-php-library-worse-gets-better/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.sitepoint.com/blogs/2004/09/13/the-standard-php-library-worse-gets-better/</link>
	<description>News, opinion, and fresh thinking for web developers and designers. The official podcast of sitepoint.com.</description>
	<lastBuildDate>Sat, 07 Nov 2009 23:35:20 -0500</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Panasonic Youth &#187; Blog Archive &#187; Adventures in PHP</title>
		<link>http://www.sitepoint.com/blogs/2004/09/13/the-standard-php-library-worse-gets-better/comment-page-1/#comment-19924</link>
		<dc:creator>Panasonic Youth &#187; Blog Archive &#187; Adventures in PHP</dc:creator>
		<pubDate>Wed, 26 Apr 2006 04:08:23 +0000</pubDate>
		<guid isPermaLink="false">2027109095#comment-19924</guid>
		<description>[...] The lack of any consistency for across the libraries is well known and been written about by many. Then you have some great functions like these two: [...]</description>
		<content:encoded><![CDATA[<p>[...] The lack of any consistency for across the libraries is well known and been written about by many. Then you have some great functions like these two: [...]</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Captain Proton</title>
		<link>http://www.sitepoint.com/blogs/2004/09/13/the-standard-php-library-worse-gets-better/comment-page-1/#comment-1052</link>
		<dc:creator>Captain Proton</dc:creator>
		<pubDate>Tue, 30 Nov 1999 00:00:00 +0000</pubDate>
		<guid isPermaLink="false">2027109095#comment-1052</guid>
		<description>&lt;p&gt;I think the &#039;negative comments&#039; towards PHP are more aimed at the internal code structure, instead of at the resulting product. PHP as a product may be good (open for debate of course), but the code behind it may be a hacked piece of unelegant spaghetti code (note that I am not saying that it actually &lt;i&gt;is&lt;/i&gt;, I don&#039;t know what the code looks like).&lt;/p&gt;

&lt;p&gt;One of the things I can criticise PHP on is the lack of consistency. Some examples:&lt;br /&gt;
- in_array(needle, haystack) but strpos(haystack, needle)&lt;br /&gt;
- no naming convention for functions: money_format or addslashes &lt;br /&gt;
- PHP 5&#039;s function parameter type hints, they work for classes but not for built-in types like strings and integers&lt;/p&gt;

&lt;p&gt;&lt;br /&gt;
PHP is definitely a pragmatic language: it was built and bolted upon to support whatever features were &quot;needed by the community&quot;. No matter what Zend may claim, there is no clear goal: things just evolve the way they do. Whether that is a good thing or a bad thing is open for discussion.&lt;/p&gt;

&lt;p&gt;Consistency in a language is very important IMHO. PHP&#039;s lack of consistency inevitably leads to bugs or at least more development time. How many times haven&#039;t you accidentally used strpos(needle, haystack) instead of strpos(haystack, needle) and spent hours trying to find the error? Okay, maybe not hours ;), but things like that are annoying.&lt;/p&gt;

&lt;p&gt;I love PHP and what it does but it&#039;s a terrible language from the point of language design. And I actually dislike PHP 5 more because of the extra inconsistency it has introduced. I believe that either a language should be dynamically typed or strongly typed,  but not something in between, which is the case now with these half implemented type hints.&lt;/p&gt;

&lt;p&gt;That&#039;s it for my rant :)&lt;/p&gt;

</description>
		<content:encoded><![CDATA[<p>I think the &#8216;negative comments&#8217; towards PHP are more aimed at the internal code structure, instead of at the resulting product. PHP as a product may be good (open for debate of course), but the code behind it may be a hacked piece of unelegant spaghetti code (note that I am not saying that it actually <i>is</i>, I don&#8217;t know what the code looks like).</p>
<p>One of the things I can criticise PHP on is the lack of consistency. Some examples:<br />
- in_array(needle, haystack) but strpos(haystack, needle)<br />
- no naming convention for functions: money_format or addslashes <br />
- PHP 5&#8217;s function parameter type hints, they work for classes but not for built-in types like strings and integers</p>
<p>
PHP is definitely a pragmatic language: it was built and bolted upon to support whatever features were &#8220;needed by the community&#8221;. No matter what Zend may claim, there is no clear goal: things just evolve the way they do. Whether that is a good thing or a bad thing is open for discussion.</p>
<p>Consistency in a language is very important IMHO. PHP&#8217;s lack of consistency inevitably leads to bugs or at least more development time. How many times haven&#8217;t you accidentally used strpos(needle, haystack) instead of strpos(haystack, needle) and spent hours trying to find the error? Okay, maybe not hours ;), but things like that are annoying.</p>
<p>I love PHP and what it does but it&#8217;s a terrible language from the point of language design. And I actually dislike PHP 5 more because of the extra inconsistency it has introduced. I believe that either a language should be dynamically typed or strongly typed,  but not something in between, which is the case now with these half implemented type hints.</p>
<p>That&#8217;s it for my rant :)</p>]]></content:encoded>
	</item>
	<item>
		<title>By: terry chay</title>
		<link>http://www.sitepoint.com/blogs/2004/09/13/the-standard-php-library-worse-gets-better/comment-page-1/#comment-1053</link>
		<dc:creator>terry chay</dc:creator>
		<pubDate>Tue, 30 Nov 1999 00:00:00 +0000</pubDate>
		<guid isPermaLink="false">2027109095#comment-1053</guid>
		<description>&lt;p&gt;Most of the inconsistency in the function and method signatures comes from the underlying C functions that are implemented. In the PHP world, as you know, the resolution is PHP.net which makes searching for the correct signature very easy even to us vi guys. It&#039;s not the best, but I don&#039;t think anyone has ever claimed that PHP is a remotely &quot;clean&quot; language.&lt;/p&gt;

&lt;p&gt;PHP5 is dynamically typed. Type hints are entirely optional and are implemented is the same you would do a bunch of asserts() after receiving the parameters. It really is a &quot;choose your poison&quot; thing. This is far different than a parse/compile-time check of parameters that strong typing has! Of course, you may be wondering why bother at all. I suppose that putting the type information in the function declaration is cleaner (and nicer for PHPDoc) than putting a bunch of asserts(). *shrug*&lt;/p&gt;

&lt;p&gt;My beef with PHP is PEAR vs CPAN. Most of this is due to lack of namespacing. However, I&#039;m a patient fellow. Then again, I had to wait four years for a working DOM parser in PHP...&lt;/p&gt;

</description>
		<content:encoded><![CDATA[<p>Most of the inconsistency in the function and method signatures comes from the underlying C functions that are implemented. In the PHP world, as you know, the resolution is PHP.net which makes searching for the correct signature very easy even to us vi guys. It&#8217;s not the best, but I don&#8217;t think anyone has ever claimed that PHP is a remotely &#8220;clean&#8221; language.</p>
<p>PHP5 is dynamically typed. Type hints are entirely optional and are implemented is the same you would do a bunch of asserts() after receiving the parameters. It really is a &#8220;choose your poison&#8221; thing. This is far different than a parse/compile-time check of parameters that strong typing has! Of course, you may be wondering why bother at all. I suppose that putting the type information in the function declaration is cleaner (and nicer for PHPDoc) than putting a bunch of asserts(). *shrug*</p>
<p>My beef with PHP is PEAR vs CPAN. Most of this is due to lack of namespacing. However, I&#8217;m a patient fellow. Then again, I had to wait four years for a working DOM parser in PHP&#8230;</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Big Fat Bob</title>
		<link>http://www.sitepoint.com/blogs/2004/09/13/the-standard-php-library-worse-gets-better/comment-page-1/#comment-1054</link>
		<dc:creator>Big Fat Bob</dc:creator>
		<pubDate>Tue, 30 Nov 1999 00:00:00 +0000</pubDate>
		<guid isPermaLink="false">2027109095#comment-1054</guid>
		<description>&lt;p&gt;Yo&lt;/p&gt;

&lt;p&gt;&gt; Consistency in a language is very important IMHO.&lt;/p&gt;

&lt;p&gt;I&#039;d have to agree with you here, also noting what you said&lt;/p&gt;

&lt;p&gt;&gt; no naming convention for functions: money_format or addslashes &lt;/p&gt;

&lt;p&gt;I have noticed this as well, and is the lack of standards&lt;/p&gt;

&lt;p&gt;&gt; PHP 5&#039;s function parameter type hints, they work for classes but not for built-in types like strings and integers&lt;/p&gt;

&lt;p&gt;Prior to actually using PHP 5 I had assumed that we could hint &#039;strings&#039; though this isn&#039;t possible and I&#039;m shocked at this being ignored&lt;/p&gt;

&lt;p&gt;All said PHP is a good language though on the point of standards, PHP I feel has yet a long way to go, if the language it&#039;s self isn&#039;t consistent :(&lt;/p&gt;

&lt;p&gt;I&#039;m now getting to like PHP 5 though maybe in a few years PHP will adhere to one standard, thus we won&#039;t have this&lt;/p&gt;

&lt;p&gt;&gt; - in_array(needle, haystack) but strpos(haystack, needle) &lt;/p&gt;

</description>
		<content:encoded><![CDATA[<p>Yo</p>
<p>> Consistency in a language is very important IMHO.</p>
<p>I&#8217;d have to agree with you here, also noting what you said</p>
<p>> no naming convention for functions: money_format or addslashes </p>
<p>I have noticed this as well, and is the lack of standards</p>
<p>> PHP 5&#8217;s function parameter type hints, they work for classes but not for built-in types like strings and integers</p>
<p>Prior to actually using PHP 5 I had assumed that we could hint &#8217;strings&#8217; though this isn&#8217;t possible and I&#8217;m shocked at this being ignored</p>
<p>All said PHP is a good language though on the point of standards, PHP I feel has yet a long way to go, if the language it&#8217;s self isn&#8217;t consistent :(</p>
<p>I&#8217;m now getting to like PHP 5 though maybe in a few years PHP will adhere to one standard, thus we won&#8217;t have this</p>
<p>> &#8211; in_array(needle, haystack) but strpos(haystack, needle) </p>]]></content:encoded>
	</item>
	<item>
		<title>By: arborint</title>
		<link>http://www.sitepoint.com/blogs/2004/09/13/the-standard-php-library-worse-gets-better/comment-page-1/#comment-1055</link>
		<dc:creator>arborint</dc:creator>
		<pubDate>Tue, 30 Nov 1999 00:00:00 +0000</pubDate>
		<guid isPermaLink="false">2027109095#comment-1055</guid>
		<description>&lt;p&gt;I think consistency is important, but with humans consistent does not always clearer. Sometimes inconsistent actually makes more sense. &lt;/p&gt;

&lt;p&gt;You ask &quot;what else should the SPL be doing?&quot; Well if &quot;worse is better&quot; and due to SPL &quot;worse getting better&quot; then I think SPL should &quot;get worse.&quot; &lt;/p&gt;

&lt;p&gt;The whole GoF/Smalltalk/Java way is about half right for PHP. It&#039;s also half wrong. &lt;/p&gt;

&lt;p&gt;Which is clearer this:&lt;/p&gt;

&lt;p&gt;// Fetch the &quot;aggregate structure&quot;&lt;br /&gt;
$dh = opendir(&#039;/home/harryf/files&#039;);&lt;br /&gt;
// Iterate over the structure&lt;br /&gt;
while ( $file = readdir($dh) ) {&lt;br /&gt;
   // do stuff with the file here&lt;br /&gt;
}&lt;/p&gt;

&lt;p&gt;Or this:&lt;/p&gt;

&lt;p&gt;&lt;?php&lt;br /&gt;
// A magic class... (explained in a moment)&lt;br /&gt;
class DirectoryReader extends DirectoryIterator {&lt;br /&gt;
 function __construct($path) {&lt;br /&gt;
   parent::__construct($path);&lt;br /&gt;
 }&lt;/p&gt;

&lt;p&gt; function current() {&lt;br /&gt;
   return parent::getFileName();&lt;br /&gt;
 }&lt;/p&gt;

&lt;p&gt; function valid() {&lt;br /&gt;
   if ( parent::valid() ) {&lt;br /&gt;
     if ( !parent::isFile() ) {&lt;br /&gt;
       parent::next();&lt;br /&gt;
       return $this-&gt;valid();&lt;br /&gt;
     }&lt;br /&gt;
     return TRUE;&lt;br /&gt;
   }&lt;br /&gt;
   return FALSE;&lt;br /&gt;
 }&lt;/p&gt;

&lt;p&gt; function rewind() {&lt;br /&gt;
   parent::rewind();&lt;br /&gt;
 }&lt;br /&gt;
}&lt;/p&gt;

&lt;p&gt;// Create a directory reader for the current directory&lt;br /&gt;
$Reader = new DirectoryReader(&#039;./&#039;);&lt;/p&gt;

&lt;p&gt;// Loop through the files in the directory ?!?&lt;br /&gt;
foreach ( $Reader as $Item ) {&lt;br /&gt;
 echo $Item.&#039;&lt;br&gt;&#039;;&lt;br /&gt;
}&lt;br /&gt;
?&gt;&lt;/p&gt;

&lt;p&gt;The OOP Iterator produces a nice code snippet at the end, but OOP makes you produce the big pile of code above it. GoF stuff is intellectually satisfying, but the total code is bigger and not necessarily clearer.&lt;/p&gt;

&lt;p&gt;I feel strongly that PHP programmers need to come up with a different model for patterns for PHP than the Smalltalk crowd developed. There is plenty of overlap, but the differences are significant. The shared-nothing idea goes along with the fact that a PHP site is a meta application where a small separate portion of the application is executed each request. It is not a compiled-and-linked-to-a-library thing. Events, the request, and threads are all very different as well. If you squint they are similar (and maybe converging). Worst of all, you can force the development ideal of one onto the other, be they are not the same. &lt;/p&gt;

&lt;p&gt;I think something like SPL is an opportunity to define what the PHP Way is. That is a real challenge but we have plenty of smart programmers. Or, SPL could just be warmed-over J2EE -- solving problems like looping that I just don&#039;t hear PHP programmers complaining about. Give me a standard &quot;PHP Way&quot; Front/Request/Page Controller and you have my attention; give me an Iterator and I will doze off until the class bell rings. &lt;/p&gt;

</description>
		<content:encoded><![CDATA[<p>I think consistency is important, but with humans consistent does not always clearer. Sometimes inconsistent actually makes more sense. </p>
<p>You ask &#8220;what else should the SPL be doing?&#8221; Well if &#8220;worse is better&#8221; and due to SPL &#8220;worse getting better&#8221; then I think SPL should &#8220;get worse.&#8221; </p>
<p>The whole GoF/Smalltalk/Java way is about half right for PHP. It&#8217;s also half wrong. </p>
<p>Which is clearer this:</p>
<p>// Fetch the &#8220;aggregate structure&#8221;<br />
$dh = opendir(&#8217;/home/harryf/files&#8217;);<br />
// Iterate over the structure<br />
while ( $file = readdir($dh) ) {<br />
   // do stuff with the file here<br />
}</p>
<p>Or this:</p>
<p>< ?php<br />
// A magic class&#8230; (explained in a moment)<br />
class DirectoryReader extends DirectoryIterator {<br />
 function __construct($path) {<br />
   parent::__construct($path);<br />
 }</p>
<p> function current() {<br />
   return parent::getFileName();<br />
 }</p>
<p> function valid() {<br />
   if ( parent::valid() ) {<br />
     if ( !parent::isFile() ) {<br />
       parent::next();<br />
       return $this->valid();<br />
     }<br />
     return TRUE;<br />
   }<br />
   return FALSE;<br />
 }</p>
<p> function rewind() {<br />
   parent::rewind();<br />
 }<br />
}</p>
<p>// Create a directory reader for the current directory<br />
$Reader = new DirectoryReader(&#8217;./&#8217;);</p>
<p>// Loop through the files in the directory ?!?<br />
foreach ( $Reader as $Item ) {<br />
 echo $Item.&#8217;<br />&#8216;;<br />
}<br />
?></p>
<p>The OOP Iterator produces a nice code snippet at the end, but OOP makes you produce the big pile of code above it. GoF stuff is intellectually satisfying, but the total code is bigger and not necessarily clearer.</p>
<p>I feel strongly that PHP programmers need to come up with a different model for patterns for PHP than the Smalltalk crowd developed. There is plenty of overlap, but the differences are significant. The shared-nothing idea goes along with the fact that a PHP site is a meta application where a small separate portion of the application is executed each request. It is not a compiled-and-linked-to-a-library thing. Events, the request, and threads are all very different as well. If you squint they are similar (and maybe converging). Worst of all, you can force the development ideal of one onto the other, be they are not the same. </p>
<p>I think something like SPL is an opportunity to define what the PHP Way is. That is a real challenge but we have plenty of smart programmers. Or, SPL could just be warmed-over J2EE &#8212; solving problems like looping that I just don&#8217;t hear PHP programmers complaining about. Give me a standard &#8220;PHP Way&#8221; Front/Request/Page Controller and you have my attention; give me an Iterator and I will doze off until the class bell rings. </p>]]></content:encoded>
	</item>
</channel>
</rss>
