<?xml version="1.0" encoding="UTF-8"?>
<feed xml:lang="en-US" xmlns="http://www.w3.org/2005/Atom">
  <title>GeekyStuff - Home</title>
  <id>tag:www.geekystuff.net,2010:mephisto/</id>
  <generator uri="http://mephistoblog.com" version="0.8.0">Mephisto Drax</generator>
  <link href="http://www.geekystuff.net/feed/atom.xml" rel="self" type="application/atom+xml"/>
  <link href="http://www.geekystuff.net/" rel="alternate" type="text/html"/>
  <updated>2009-08-04T18:57:16Z</updated>
  <entry xml:base="http://www.geekystuff.net/">
    <author>
      <name>knordquist</name>
    </author>
    <id>tag:www.geekystuff.net,2009-07-01:23</id>
    <published>2009-07-01T16:00:00Z</published>
    <updated>2009-08-04T18:57:16Z</updated>
    <category term="Merb, Datamapper and Me"/>
    <category term="php"/>
    <category term="Web Development"/>
    <category term="php"/>
    <category term="ruby"/>
    <category term="vs"/>
    <link href="http://www.geekystuff.net/2009/7/1/ruby-vs-php-my-two-cents" rel="alternate" type="text/html"/>
    <title>Ruby vs. PHP (My two Cents)</title>
<content type="html">
            &lt;p&gt;Which is &#8220;better&#8221; for developing web apps &#8211; Ruby or &lt;span class=&quot;caps&quot;&gt;PHP&lt;/span&gt;?  I recently saw a question on LinkedIn which inspired me to add my two cents to the discussion&#8230;&lt;/p&gt;


	&lt;p&gt;The key difference in the languages (Ruby vs. &lt;span class=&quot;caps&quot;&gt;PHP&lt;/span&gt;) are the level of &#8220;object-orientation,&#8221; and (obviously) syntax.  Ruby was designed from the start (~1993) to be an object-oriented language (EVERYTHING is an object) while &lt;span class=&quot;caps&quot;&gt;PHP&lt;/span&gt; was, until recently (v5.0 &#8211; 2004), a procedural language (an example would be &lt;span class=&quot;caps&quot;&gt;PHP&lt;/span&gt; v4.x&#8217;s use of the class name as a method for initialization vs. &lt;span class=&quot;caps&quot;&gt;PHP 5&lt;/span&gt;.x&#8217;s use of __construct).  As a long-time &lt;span class=&quot;caps&quot;&gt;PHP&lt;/span&gt; programmer who migrated to Ruby in 2006, I prefer Ruby&#8217;s implementation of OO over &lt;span class=&quot;caps&quot;&gt;PHP&lt;/span&gt;&#8217;s.  I also prefer Ruby&#8217;s syntax &lt;span class=&quot;caps&quot;&gt;AND&lt;/span&gt; coding best-practices over &lt;span class=&quot;caps&quot;&gt;PHP&lt;/span&gt;&#8217;s.&lt;/p&gt;


	&lt;p&gt;There are many good Model, View, Controller (MVC) web frameworks for both languages.  &lt;span class=&quot;caps&quot;&gt;PHP&lt;/span&gt; has CakePHP, Code Igniter, Akelos, Symfony, Zend, etc&#8230;  Here is an excellent list of web frameworks for &lt;span class=&quot;caps&quot;&gt;PHP&lt;/span&gt;: &lt;a href=&quot;http://www.phpwact.org/php/mvc_frameworks&quot;&gt;http://www.phpwact.org/php/mvc_frameworks&lt;/a&gt;.  Ruby&#8217;s &lt;span class=&quot;caps&quot;&gt;MVC&lt;/span&gt; frameworks include: Rails, Merb, Sinatra, Ramaze, Nitro, etc&#8230;  Here is an excellent list of Ruby web frameworks: &lt;a href=&quot;http://accidentaltechnologist.com/ruby/10-alternative-ruby-web-frameworks/&quot;&gt;http://accidentaltechnologist.com/ruby/10-alternative-ruby-web-frameworks/&lt;/a&gt;.&lt;/p&gt;


	&lt;p&gt;In my opinion, there are two keys to selecting a web framework.  First is the Object Relational Mapper (ORM) &#8211; how the data is abstracted, and testing.  In my early days writing &lt;span class=&quot;caps&quot;&gt;PHP&lt;/span&gt; code, I found myself writing a lot of (repetitive) &lt;span class=&quot;caps&quot;&gt;SQL&lt;/span&gt; queries to access data.  With an &lt;span class=&quot;caps&quot;&gt;ORM&lt;/span&gt;, it is easier because the queries are abstracted out.  While this may be &#8220;slower&#8221; than directly accessing the data with &lt;span class=&quot;caps&quot;&gt;SQL&lt;/span&gt; queries, it saves a &lt;span class=&quot;caps&quot;&gt;LOT&lt;/span&gt; of programming time.  The bonus to using an &lt;span class=&quot;caps&quot;&gt;ORM&lt;/span&gt; is one can &lt;span class=&quot;caps&quot;&gt;ALWAYS&lt;/span&gt; write a custom query if needed.  Testing is also &lt;span class=&quot;caps&quot;&gt;HIGHLY&lt;/span&gt; recommended and attractive&#8230;  before I became a test-aware, I cannot tell you how many times my code would break after I made (what I thought) was a small fix&#8230;  this can be avoided by testing the public-facing code.  Do not commit (version control) or deploy unless all tests pass!&lt;/p&gt;


	&lt;p&gt;My specific recommendation for a &lt;span class=&quot;caps&quot;&gt;PHP&lt;/span&gt;-based web framework would be Symfony (&lt;a href=&quot;http://www.symfony-project.org/&quot;&gt;http://www.symfony-project.org/&lt;/a&gt;) because it uses Doctrine &lt;span class=&quot;caps&quot;&gt;ORM&lt;/span&gt; (&lt;a href=&quot;http://www.doctrine-project.org/&quot;&gt;http://www.doctrine-project.org/&lt;/a&gt;), is packaged to be used as a library (ala &lt;span class=&quot;caps&quot;&gt;PEAR&lt;/span&gt;) &#8211; meaning one code base can natively support many instances, and has a decent test suite.  For a Ruby web framework, I prefer Merb (&lt;a href=&quot;http://merbivore.com&quot;&gt;http://merbivore.com&lt;/a&gt;) because it is &#8220;lighter&#8221; than Rails, is &lt;span class=&quot;caps&quot;&gt;ORM&lt;/span&gt; agnostic (you can choose from Datamapper (&lt;a href=&quot;http://datamapper.org&quot;&gt;http://datamapper.org&lt;/a&gt;), Sequel (&lt;a href=&quot;http://sequel.rubyforge.org/&quot;&gt;http://sequel.rubyforge.org/&lt;/a&gt;), or ActiveRecord (&lt;a href=&quot;http://ar.rubyonrails.org/&quot;&gt;http://ar.rubyonrails.org/&lt;/a&gt;)), supports threading (concurrent processing), and natively supports testing (Rspec &#8211; &lt;a href=&quot;http://rspec.info/&quot;&gt;http://rspec.info/&lt;/a&gt;).&lt;/p&gt;


	&lt;p&gt;If you are a &lt;span class=&quot;caps&quot;&gt;PHP&lt;/span&gt; programmer, I would recommend you start learning Ruby and use Merb as your web framework.  While it seems there is a relatively steep learning curve, you will find your development time will dramatically drop in the long-term using Ruby / Merb / Datamapper.&lt;/p&gt;
          </content>  </entry>
</feed>
