<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.0.1" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
	<title>Comments on: How’s that for less code?</title>
	<link>http://lesscode.org/2006/01/07/hows-that-for-less-code/</link>
	<description>AAaaaaahhhhrrrrrrr!</description>
	<pubDate>Mon, 17 Sep 2007 09:11:16 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.0.1</generator>

	<item>
		<title>by: Aristotle Pagaltzis</title>
		<link>http://lesscode.org/2006/01/07/hows-that-for-less-code/#comment-19388</link>
		<pubDate>Sun, 26 Nov 2006 11:53:57 +0000</pubDate>
		<guid>http://lesscode.org/2006/01/07/hows-that-for-less-code/#comment-19388</guid>
					<description>&lt;p&gt;Cliff: &lt;a href=&quot;http://plasmasturm.org/log/393/&quot; title=&quot;In which I write about PHP for the first and the last time&quot; rel=&quot;&quot;&gt;I think the language itself &lt;em&gt;is&lt;/em&gt; to blame&lt;/a&gt;.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Cliff: <a href="http://plasmasturm.org/log/393/" title="In which I write about PHP for the first and the last time" rel="">I think the language itself <em>is</em> to blame</a>.</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Cliff Wells</title>
		<link>http://lesscode.org/2006/01/07/hows-that-for-less-code/#comment-19373</link>
		<pubDate>Sun, 26 Nov 2006 03:22:07 +0000</pubDate>
		<guid>http://lesscode.org/2006/01/07/hows-that-for-less-code/#comment-19373</guid>
					<description>&lt;p&gt;It really irks me when PHP programmers explain away crappy code examples by saying &quot;it was just an example&quot; or &quot;I was just testing&quot;.  When you consider that manually escaping code (as is so often seen) is incorrect, insecure and TAKES TWICE AS MUCH CODE as doing it right (using prepare/execute) I have to call bullshit.  Someone is either lying or ignorant or both.&lt;/p&gt;

&lt;p&gt;There are tons of beautiful PHP apps out there, most of them plagued with serious security holes because most programmers learn from example and most PHP examples to be found on the net are badly flawed. &lt;/p&gt;

&lt;p&gt;I tend to agree that it's possible to write crappy code in any language, but PHP seems to have more than its fair share.  Some people claim this is because it's so popular and I'm sure that's part of it, but I'll assert that it has more security holes &lt;em&gt;per deployment&lt;/em&gt; than any other language.  Worse, most of them are SQL injection and remote code execution exploits.
I attribute this partially to poor ideas in PHP's implementation (certain settings in php.ini were patently bad ideas), but mostly I attribute it to poor examples for others to learn from.  If you don't want to teach well, then don't teach.  If you make a mistake, don't make excuses, fix it.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>It really irks me when PHP programmers explain away crappy code examples by saying &#8220;it was just an example&#8221; or &#8220;I was just testing&#8221;.  When you consider that manually escaping code (as is so often seen) is incorrect, insecure and TAKES TWICE AS MUCH CODE as doing it right (using prepare/execute) I have to call bullshit.  Someone is either lying or ignorant or both.</p>
<p>There are tons of beautiful PHP apps out there, most of them plagued with serious security holes because most programmers learn from example and most PHP examples to be found on the net are badly flawed. </p>
<p>I tend to agree that it&#8217;s possible to write crappy code in any language, but PHP seems to have more than its fair share.  Some people claim this is because it&#8217;s so popular and I&#8217;m sure that&#8217;s part of it, but I&#8217;ll assert that it has more security holes <em>per deployment</em> than any other language.  Worse, most of them are SQL injection and remote code execution exploits.<br />
I attribute this partially to poor ideas in PHP&#8217;s implementation (certain settings in php.ini were patently bad ideas), but mostly I attribute it to poor examples for others to learn from.  If you don&#8217;t want to teach well, then don&#8217;t teach.  If you make a mistake, don&#8217;t make excuses, fix it.</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: The Cave &#187; Blog Archive &#187; Less is More</title>
		<link>http://lesscode.org/2006/01/07/hows-that-for-less-code/#comment-1386</link>
		<pubDate>Sun, 26 Mar 2006 18:22:29 +0000</pubDate>
		<guid>http://lesscode.org/2006/01/07/hows-that-for-less-code/#comment-1386</guid>
					<description>&lt;p&gt;[...] &amp;#8216;Java&amp;#8217; (language, libraries, community&amp;#8230;) need to fix the mess they&amp;#8217;ve created over the past decade: This is a total of a whopping 117 lines of very liberally spaced Python code that defines all three database tables and fully implements every feature of both sample applications. [...]&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>[&#8230;] &#8216;Java&#8217; (language, libraries, community&#8230;) need to fix the mess they&#8217;ve created over the past decade: This is a total of a whopping 117 lines of very liberally spaced Python code that defines all three database tables and fully implements every feature of both sample applications. [&#8230;]</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Patrick Mineault</title>
		<link>http://lesscode.org/2006/01/07/hows-that-for-less-code/#comment-1135</link>
		<pubDate>Fri, 03 Mar 2006 17:32:10 +0000</pubDate>
		<guid>http://lesscode.org/2006/01/07/hows-that-for-less-code/#comment-1135</guid>
					<description>&lt;p&gt;The current version of the &lt;a href=&quot;http://www.amfphp.org/examples/pizzaservice/pizzaService.phps&quot; rel=&quot;nofollow&quot;&gt;pizza service&lt;/a&gt; on the amfphp website includes the methodTable as an external file which reduces the code to 113 lines. The methodTable file itself is generated by the service browser so I would hardly count that towards the total. As for the security flaw, it has been fixed by proper escaping. I don't think Justin and the rest of the gang ever meant for the pizzaService to be a model in implementation. It was originally created as a simple showcase for a conference talk, where the quality of the code didn't matter all that much.&lt;/p&gt;

&lt;p&gt;Now as for your claim that 'amfphp is a framework', I want to stress that this is false. Amfphp is, and will always be, a Remoting gateway, that exposes vanilla php classes to the outside, enforcing security. One of amfphp's design goals was that you could integrate it with whatever you're currently using, so you don't have to learn to code again. Most amfphp examples onlines use plain mysql, because that's what a lot of people use in PHP, and everyone's familiar with these functions. Nothing is stopping you from using any of the other databases that amfphp supports which there days includes ADO, FrontBase, Informix, ms-sql, Oracle, generic odbc, PDO, PEAR::DB, Postgres and SQLite. There's been nice reports on using it with Creole also.&lt;/p&gt;

&lt;p&gt;Again, I want to stress, amfphp &lt;em&gt;is not a framework&lt;/em&gt;. The fact that it can be &lt;a href=&quot;http://cakeforge.org/projects/cakeamfphp/&quot; rel=&quot;nofollow&quot;&gt;used as a module&lt;/a&gt; in Cake (a Rails clone for PHP) proves it. Note that amfphp's approach is not universal. People who wanted a cleaner API and a more 'frameworky' approach created &lt;a href=&quot;http://www.osflash.org/sabreamf&quot; rel=&quot;nofollow&quot;&gt;SabreAMF&lt;/a&gt;. I talked to the developer to get him to work in amfphp instead and it turned out that our goals were irreconcilable. This will allow amfphp-enabled classes (that is, classes that set a methodTable) to be used as JSON services for JavaScript, or for XML-RPC, or to generate SOAP services, etc.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>The current version of the <a href="http://www.amfphp.org/examples/pizzaservice/pizzaService.phps">pizza service</a> on the amfphp website includes the methodTable as an external file which reduces the code to 113 lines. The methodTable file itself is generated by the service browser so I would hardly count that towards the total. As for the security flaw, it has been fixed by proper escaping. I don&#8217;t think Justin and the rest of the gang ever meant for the pizzaService to be a model in implementation. It was originally created as a simple showcase for a conference talk, where the quality of the code didn&#8217;t matter all that much.</p>
<p>Now as for your claim that &#8216;amfphp is a framework&#8217;, I want to stress that this is false. Amfphp is, and will always be, a Remoting gateway, that exposes vanilla php classes to the outside, enforcing security. One of amfphp&#8217;s design goals was that you could integrate it with whatever you&#8217;re currently using, so you don&#8217;t have to learn to code again. Most amfphp examples onlines use plain mysql, because that&#8217;s what a lot of people use in PHP, and everyone&#8217;s familiar with these functions. Nothing is stopping you from using any of the other databases that amfphp supports which there days includes ADO, FrontBase, Informix, ms-sql, Oracle, generic odbc, PDO, PEAR::DB, Postgres and SQLite. There&#8217;s been nice reports on using it with Creole also.</p>
<p>Again, I want to stress, amfphp <em>is not a framework</em>. The fact that it can be <a href="http://cakeforge.org/projects/cakeamfphp/">used as a module</a> in Cake (a Rails clone for PHP) proves it. Note that amfphp&#8217;s approach is not universal. People who wanted a cleaner API and a more &#8216;frameworky&#8217; approach created <a href="http://www.osflash.org/sabreamf">SabreAMF</a>. I talked to the developer to get him to work in amfphp instead and it turned out that our goals were irreconcilable. This will allow amfphp-enabled classes (that is, classes that set a methodTable) to be used as JSON services for JavaScript, or for XML-RPC, or to generate SOAP services, etc.</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Bob Ippolito</title>
		<link>http://lesscode.org/2006/01/07/hows-that-for-less-code/#comment-936</link>
		<pubDate>Sun, 08 Jan 2006 23:32:04 +0000</pubDate>
		<guid>http://lesscode.org/2006/01/07/hows-that-for-less-code/#comment-936</guid>
					<description>&lt;p&gt;It's not flawed -- the PHP example is using AMFPHP, which is a framework for developing flash remoting services.  It's not &quot;Just PHP&quot;, there's a large body of code behind it.&lt;/p&gt;

&lt;p&gt;Comparing PHP-the-language to any other language is silly anyway, because PHP includes the kitchen sink and the house to go with it as far as built-in functions and extensions go.&lt;/p&gt;

&lt;p&gt;PHP also does a very bad job at choosing how to expose what it offers.  It makes it hard, or at least non-obvious, to write correct code.  EVERY SINGLE DATABASE QUERY in the cited example is susceptible to SQL injection attack, where people simply don't write shit code like that in environments that offer a sane means of SQL quoting.  Since everything else is already there, it encourages people to just use the raw MySQL API calls rather than bringing in an abstraction.  That's also stupid because it takes 5x more code to do all the quoting by hand.  People are too lazy to bother with that, so they develop big festering security holes like this one.  Even worse, this is example code that people will cut and paste into their own applications.  PHP programming is a disease.&lt;/p&gt;

&lt;p&gt;Anyhow, TG is actually doing &lt;em&gt;very&lt;/em&gt; little in this case besides providing a buzzword and easy means of getting up and running.  TG is serving as shim for CherryPy to make HTTP requests transactional with the database, and as a script to create the SQL tables.  It also ensures that SQLObject and CherryPy are known to be installed.&lt;/p&gt;

&lt;p&gt;It &lt;em&gt;could've&lt;/em&gt; been written as raw Python with BaseHTTPServer (or CGI) and the minimum DB-API wrapper in the same amount of code, but that's stupid and it's not the point of lesscode.  Abstractions that work are good.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>It&#8217;s not flawed &#8212; the PHP example is using AMFPHP, which is a framework for developing flash remoting services.  It&#8217;s not &#8220;Just PHP&#8221;, there&#8217;s a large body of code behind it.</p>
<p>Comparing PHP-the-language to any other language is silly anyway, because PHP includes the kitchen sink and the house to go with it as far as built-in functions and extensions go.</p>
<p>PHP also does a very bad job at choosing how to expose what it offers.  It makes it hard, or at least non-obvious, to write correct code.  EVERY SINGLE DATABASE QUERY in the cited example is susceptible to SQL injection attack, where people simply don&#8217;t write shit code like that in environments that offer a sane means of SQL quoting.  Since everything else is already there, it encourages people to just use the raw MySQL API calls rather than bringing in an abstraction.  That&#8217;s also stupid because it takes 5x more code to do all the quoting by hand.  People are too lazy to bother with that, so they develop big festering security holes like this one.  Even worse, this is example code that people will cut and paste into their own applications.  PHP programming is a disease.</p>
<p>Anyhow, TG is actually doing <em>very</em> little in this case besides providing a buzzword and easy means of getting up and running.  TG is serving as shim for CherryPy to make HTTP requests transactional with the database, and as a script to create the SQL tables.  It also ensures that SQLObject and CherryPy are known to be installed.</p>
<p>It <em>could&#8217;ve</em> been written as raw Python with BaseHTTPServer (or CGI) and the minimum DB-API wrapper in the same amount of code, but that&#8217;s stupid and it&#8217;s not the point of lesscode.  Abstractions that work are good.</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Scott Yang</title>
		<link>http://lesscode.org/2006/01/07/hows-that-for-less-code/#comment-926</link>
		<pubDate>Sun, 08 Jan 2006 09:54:17 +0000</pubDate>
		<guid>http://lesscode.org/2006/01/07/hows-that-for-less-code/#comment-926</guid>
					<description>&lt;p&gt;It is not comparing languages like Python, PHP and Java -- it is actually comparing frameworks. It is comparing TurboGears, a Python framework that is especially designed for CRUD-type web applications using MVC and ORM, with a Java app implemented on top of J2EE, which always manage to (1) confuse the programmers (2) flood the managers with buzzwords.&lt;/p&gt;

&lt;p&gt;(Sorry I did use J2EE in my previous job, and understood the complexity also gives it lots of flexibility)&lt;/p&gt;

&lt;p&gt;My point is, your 117 lines of Python code simply won't work without TurboGears. TG basically takes care all the complexity so that you can write &quot;less code&quot;, but as Mr Coffee has suggested you can also write less code with appropriate framework in Java. It doesn't include database schema either -- it includes an object relation mapping that doesn't work well if another application written in another language also needs to access the same database.&lt;/p&gt;

&lt;p&gt;And the PHP example? It does everything (DB connectivity, SQL query, etc) WITHOUT a framework to build on.&lt;/p&gt;

&lt;p&gt;So IMHO, the comparison is flawed.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>It is not comparing languages like Python, PHP and Java &#8212; it is actually comparing frameworks. It is comparing TurboGears, a Python framework that is especially designed for CRUD-type web applications using MVC and ORM, with a Java app implemented on top of J2EE, which always manage to (1) confuse the programmers (2) flood the managers with buzzwords.</p>
<p>(Sorry I did use J2EE in my previous job, and understood the complexity also gives it lots of flexibility)</p>
<p>My point is, your 117 lines of Python code simply won&#8217;t work without TurboGears. TG basically takes care all the complexity so that you can write &#8220;less code&#8221;, but as Mr Coffee has suggested you can also write less code with appropriate framework in Java. It doesn&#8217;t include database schema either &#8212; it includes an object relation mapping that doesn&#8217;t work well if another application written in another language also needs to access the same database.</p>
<p>And the PHP example? It does everything (DB connectivity, SQL query, etc) WITHOUT a framework to build on.</p>
<p>So IMHO, the comparison is flawed.</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Bob Ippolito</title>
		<link>http://lesscode.org/2006/01/07/hows-that-for-less-code/#comment-925</link>
		<pubDate>Sat, 07 Jan 2006 22:38:17 +0000</pubDate>
		<guid>http://lesscode.org/2006/01/07/hows-that-for-less-code/#comment-925</guid>
					<description>&lt;p&gt;Does that include configuration and database schema?  Does it support several different RDBMS?  Does it also do the PizzaService example?  Does it have all of the same exception handling sludge?  Does it wrap at 79 columns?  ;)&lt;/p&gt;

&lt;p&gt;The Python version is about 85 lines for all that when using long lines and without all the newlines introduced specifically for readability's sake.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Does that include configuration and database schema?  Does it support several different RDBMS?  Does it also do the PizzaService example?  Does it have all of the same exception handling sludge?  Does it wrap at 79 columns?  ;)</p>
<p>The Python version is about 85 lines for all that when using long lines and without all the newlines introduced specifically for readability&#8217;s sake.</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Mr Coffee</title>
		<link>http://lesscode.org/2006/01/07/hows-that-for-less-code/#comment-924</link>
		<pubDate>Sat, 07 Jan 2006 19:36:11 +0000</pubDate>
		<guid>http://lesscode.org/2006/01/07/hows-that-for-less-code/#comment-924</guid>
					<description>&lt;p&gt;I rewrote the Java version. It is now just a little under 100 lines of code. This was achieved by using Spring, a more modern framework. Does that make Java superior again? Whee.&lt;/p&gt;

&lt;p&gt;Coffeetime.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>I rewrote the Java version. It is now just a little under 100 lines of code. This was achieved by using Spring, a more modern framework. Does that make Java superior again? Whee.</p>
<p>Coffeetime.</p>
]]></content:encoded>
				</item>
</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.336 seconds -->
<!-- Cached page served by WP-Cache -->
