<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>DGRMM.net: PHP vs Ruby, Why Rails just isn't the same in any other language</title>
    <link>http://typo.dgrmm.net/articles/2006/01/22/PHP-vs-RubyOnRails</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>David and Becky's little domain</description>
    <item>
      <title>PHP vs Ruby, Why Rails just isn't the same in any other language</title>
      <description>&lt;p&gt;I just looked at another front runner to Rails, called CakePHP.  In &lt;a href="http://wiki.cakephp.org/tutorials:blog_tutorial_-_1"&gt;this example&lt;/a&gt; there is a fundamental concept that shows how beautiful Ruby is compared to &lt;span class="caps"&gt;PHP&lt;/span&gt;.&lt;/p&gt;


	&lt;p&gt;The view, as done by &lt;span class="caps"&gt;PHP&lt;/span&gt;:&lt;/p&gt;


&lt;pre&gt;
 &amp;lt;td&amp;gt;&amp;lt;?php echo $post['Post']['id']; ?&amp;gt;&amp;lt;/td&amp;gt;
 &amp;lt;td&amp;gt;
  &amp;lt;?php echo $html-&amp;gt;link( $post['Post']['title'], 
          "/posts/view/{$post['Post']['id']}" ); ?&amp;gt;
 &amp;lt;/td&amp;gt;
&lt;/pre&gt;

	&lt;p&gt;Now, that &lt;code&gt;&amp;lt;?php echo&lt;/code&gt; stuff is rather verbose, and the method to access attributes is way too long.  The equivalent section in Ruby:&lt;/p&gt;


&lt;pre&gt;
 &amp;lt;td&amp;gt;&amp;lt;%= @post.id %&amp;gt;&amp;lt;/td&amp;gt;
 &amp;lt;td&amp;gt;
  &amp;lt;%= link_to @post.title, :action =&amp;gt; 'view', :id =&amp;gt; @post %&amp;gt;
 &amp;lt;/td&amp;gt;
&lt;/pre&gt;

	&lt;p&gt;Now, tell me, which one is easier on the eye?&lt;/p&gt;</description>
      <pubDate>Sun, 22 Jan 2006 16:55:00 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:c1941ded815bbea62cdbaa1ad634690a</guid>
      <author>David Morton</author>
      <link>http://typo.dgrmm.net/articles/2006/01/22/PHP-vs-RubyOnRails</link>
      <category>Rails</category>
    </item>
    <item>
      <title>"PHP vs Ruby, Why Rails just isn't the same in any other language" by dgm</title>
      <description>&lt;p&gt;gah.  Something&amp;#8217;s wrong with the comment system here, it isn&amp;#8217;t supposed to mangle that so much.&lt;/p&gt;</description>
      <pubDate>Tue, 24 Jan 2006 00:19:30 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:</guid>
      <link>http://typo.dgrmm.net/articles/2006/01/22/PHP-vs-RubyOnRails#comment-51</link>
    </item>
    <item>
      <title>"PHP vs Ruby, Why Rails just isn't the same in any other language" by dgm</title>
      <description>&lt;p&gt;For instance, how would you do this in a template language?&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
&amp;amp;lt;% for post in @posts %&amp;amp;gt;
&amp;amp;lt;tr class="tablerow&amp;amp;lt;%= cycle ["1","2","3"] %&amp;amp;gt;"&amp;amp;gt;
  &amp;amp;lt;td&amp;amp;gt;&amp;amp;lt;%= post.title %&amp;amp;gt;&amp;amp;lt;/td&amp;amp;gt;
  &amp;amp;lt;td&amp;amp;gt;&amp;amp;lt;%= distance_of_time_in_words(post.posted_on %&amp;amp;gt;&amp;amp;lt;/td&amp;amp;gt;
  &amp;amp;lt;td&amp;amp;gt;&amp;amp;lt;%= truncate post.body %&amp;amp;gt;&amp;amp;lt;/td&amp;amp;gt;
&amp;amp;lt;/tr&amp;amp;gt;
&amp;amp;lt;% end %&amp;amp;gt;
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;The loop, the helper functions&amp;#8230; they all belong in the view, because the have to do with the way it is displayed.  The controller or model do not need to be concerned with these details.&lt;/p&gt;


	&lt;p&gt;This way, we can have powerful helper functions to help: cycle through row colors to color the table, truncate a long entry to make it shorter, and format a date string to say &amp;#8220;1 hour ago&amp;#8221;.   These functions are already built into rails. :)&lt;/p&gt;</description>
      <pubDate>Tue, 24 Jan 2006 00:14:17 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:</guid>
      <link>http://typo.dgrmm.net/articles/2006/01/22/PHP-vs-RubyOnRails#comment-50</link>
    </item>
    <item>
      <title>"PHP vs Ruby, Why Rails just isn't the same in any other language" by dgm</title>
      <description>&lt;p&gt;rel=’nofollow&amp;#8217; tells google not to follow the link, and thus renders the link useless for spambots to use to boost page rank.&lt;/p&gt;</description>
      <pubDate>Mon, 23 Jan 2006 23:59:28 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:</guid>
      <link>http://typo.dgrmm.net/articles/2006/01/22/PHP-vs-RubyOnRails#comment-49</link>
    </item>
    <item>
      <title>"PHP vs Ruby, Why Rails just isn't the same in any other language" by dgm</title>
      <description>&lt;p&gt;no, I disagree.  You are still jumping in and out of a programming language, but now you are defining yet another language.  So now, in addition to php/html/css/ whatever, now I have to learn a templating language?  And it isn&amp;#8217;t as powerful as one I already use in the project?&lt;/p&gt;


	&lt;p&gt;Also, ho do you set or name those variables?  In smarty, I have dozens of lines setting them:  $smarty-&amp;gt;assign(&amp;#8220;post_id&amp;#8221;, 1);&lt;/p&gt;


	&lt;p&gt;Sometimes you can get sneaky by assigning an array, but still, that&amp;#8217;s a lot of excess typing.&lt;/p&gt;


	&lt;p&gt;In Rails, I assign all those in one call:&lt;/p&gt;


	&lt;p&gt;&amp;lt;pre&amp;gt;
@post=Post.find(:first)
&amp;lt;/pre&amp;gt;&lt;/p&gt;


	&lt;p&gt;or something like that.  That&amp;#8217;s all.  Including another templating language just means more work and more typing.  It violates the DRY principle.  I hate repeating myself. :)&lt;/p&gt;</description>
      <pubDate>Mon, 23 Jan 2006 23:58:27 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:</guid>
      <link>http://typo.dgrmm.net/articles/2006/01/22/PHP-vs-RubyOnRails#comment-48</link>
    </item>
    <item>
      <title>"PHP vs Ruby, Why Rails just isn't the same in any other language" by Tim Morton</title>
      <description>&lt;p&gt;Hello?  what&amp;#8217;s this &amp;#8220;rel=&amp;#8217;nofollow&amp;#8217;&amp;#8221;?  I didn&amp;#8217;t put that in there&amp;#8230;&lt;/p&gt;</description>
      <pubDate>Mon, 23 Jan 2006 17:34:46 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:</guid>
      <link>http://typo.dgrmm.net/articles/2006/01/22/PHP-vs-RubyOnRails#comment-47</link>
    </item>
    <item>
      <title>"PHP vs Ruby, Why Rails just isn't the same in any other language" by Tim Morton</title>
      <description>&lt;p&gt;Hmm, both are kind of icky&amp;#8230;  I absolutely detest this jumping in and out of programming language.  If you&amp;#8217;re working with some right-brained designer type, they just aren&amp;#8217;t going to get it.  Here&amp;#8217;s how I would rather see it&amp;#8230;&lt;/p&gt;


	&lt;p&gt;&amp;lt;td&amp;gt;{[post_id]}&amp;lt;/td&amp;gt;
&amp;lt;td&amp;gt;&amp;lt;a href=&amp;#8221;/posts/view/{[post_id]}&amp;#8221; rel=&amp;#8221;nofollow&amp;#8221;&amp;gt;{[post_title]}&amp;lt;/a&amp;gt;
&amp;lt;/td&amp;gt;&lt;/p&gt;


	&lt;p&gt;Now for someone who only understands html, that&amp;#8217;s pretty doggone understandable.  They don&amp;#8217;t even have to have a clue where the data comes from; all they need is a variable name.&lt;/p&gt;</description>
      <pubDate>Mon, 23 Jan 2006 17:33:14 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:</guid>
      <link>http://typo.dgrmm.net/articles/2006/01/22/PHP-vs-RubyOnRails#comment-46</link>
    </item>
  </channel>
</rss>
