<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Path Dependent &#187; rails</title>
	<atom:link href="http://pathdependent.com/tag/rails/feed/" rel="self" type="application/rss+xml" />
	<link>http://pathdependent.com</link>
	<description>Programming, Complex Systems, Trading, and Introspection</description>
	<lastBuildDate>Tue, 20 Jul 2010 23:09:10 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>JSON as a Universal DB Model DSL</title>
		<link>http://pathdependent.com/2009/12/30/json-as-a-universal-db-model-dsl/</link>
		<comments>http://pathdependent.com/2009/12/30/json-as-a-universal-db-model-dsl/#comments</comments>
		<pubDate>Wed, 30 Dec 2009 15:20:25 +0000</pubDate>
		<dc:creator>John Nelson</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[json]]></category>
		<category><![CDATA[model]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[web development]]></category>

		<guid isPermaLink="false">http://pathdependent.com/?p=402</guid>
		<description><![CDATA[I write web applications rarely and reluctantly. I am not the most qualified to initiate a project based on the following ideas. If I did, it would likely  fall into a state of disrepair once my ephemeral attention has shifted back to playing with stock prices. However, I think it is a good idea. I [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fpathdependent.com%2F2009%2F12%2F30%2Fjson-as-a-universal-db-model-dsl%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fpathdependent.com%2F2009%2F12%2F30%2Fjson-as-a-universal-db-model-dsl%2F" height="61" width="51" /></a></div><p>I write web applications rarely and reluctantly. I am not the most qualified to initiate a project based on the following ideas. If I did, it would likely  fall into a state of disrepair once my ephemeral attention has shifted back to <a href="http://pathdependent.com/2009/10/29/perpetual_motion/">playing with stock prices</a>. However, I think it is a good idea. I am hoping someone who has both the time and interest codes it up. This is a new level of lazy.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> user_model <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span>
    <span style="color: #006600; font-style: italic;">// column name , generalized type,   , validation rule,   hidden?</span>
    <span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'first_name'</span>  <span style="color: #339933;">,</span> <span style="color: #3366CC;">'text'</span>              <span style="color: #339933;">,</span> <span style="color: #3366CC;">'name_regex'</span>              <span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
    <span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'last_name'</span>   <span style="color: #339933;">,</span> <span style="color: #3366CC;">'text'</span>              <span style="color: #339933;">,</span> <span style="color: #3366CC;">'name_regex'</span>              <span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
    <span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'middle_name'</span> <span style="color: #339933;">,</span> <span style="color: #3366CC;">'text'</span>              <span style="color: #339933;">,</span> <span style="color: #3366CC;">'name_regex'</span>              <span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
    <span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'birth_date'</span>  <span style="color: #339933;">,</span> <span style="color: #3366CC;">'date'</span>              <span style="color: #339933;">,</span> <span style="color: #3366CC;">'over_18'</span>                 <span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
    <span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'location'</span>    <span style="color: #339933;">,</span> <span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'double'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'double'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">,</span> undefined<span style="color: #339933;">,</span>        <span style="color: #339933;">,</span>   <span style="color: #003366; font-weight: bold;">true</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
    <span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'addresses'</span><span style="color: #339933;">,</span>  <span style="color: #339933;">,</span> <span style="color: #3366CC;">'has_many'</span>          <span style="color: #339933;">,</span>                           <span style="color: #009900;">&#93;</span>
<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Basically, from a Rails perspective, replace your ruby database migration DSL with code that parses the above JSON (e.g. user_model.json) and creates the appropriate schema. Replace your ActiveRecord validations with the validations from the json model. (Depending on your language, there may be differences in REGEX syntax. Having some well defined common REGEX definitions, such as EMAIL_VALIDATION, might be appropriate.) On the client side, you can display most forms automagically, based on the order defined in the json model (if it is in fact an array.) Furthermore, you can also run client side validations before submission. (If your validations are so weak that sharing them remotely represents a security risk, you are probably doing something wrong.) It might also remove the need for many controllers. A lot of CRUD is so generic that it might be possible to have a single /:model/:action/* controller. Scaffolding is not DRY. Finally, as the lingua franca, sharing model definitions outside your project&#8217;s language is simplified.</p>
<p>Any takers?</p>
]]></content:encoded>
			<wfw:commentRss>http://pathdependent.com/2009/12/30/json-as-a-universal-db-model-dsl/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Going Back to PHP</title>
		<link>http://pathdependent.com/2009/10/26/going-back-to-php/</link>
		<comments>http://pathdependent.com/2009/10/26/going-back-to-php/#comments</comments>
		<pubDate>Mon, 26 Oct 2009 19:51:26 +0000</pubDate>
		<dc:creator>John Nelson</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[web development]]></category>

		<guid isPermaLink="false">http://pathdependent.com/?p=137</guid>
		<description><![CDATA[I consider myself a programming polyglot. I am proficient in five to seven languages and am competent in many more. Consequently, like many programming polyglots, I am a bit of a snob. PHP programmers tend to be unilingual or bilingual (Javascript). They are unenlightened. If you asked the average PHP programmer to explain a closure, [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fpathdependent.com%2F2009%2F10%2F26%2Fgoing-back-to-php%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fpathdependent.com%2F2009%2F10%2F26%2Fgoing-back-to-php%2F" height="61" width="51" /></a></div><p>I consider myself a programming polyglot. I am proficient in five to seven languages and am competent in many more. Consequently, like many programming polyglots, I am a bit of a snob. <a href="http://php.net/index.php">PHP</a> programmers tend to be unilingual or bilingual (Javascript). They are unenlightened. If you asked the average PHP programmer to explain a closure, they would probably express bewilderment. Brutes! Like I said, I am a bit of a snob (and the preceding text was satirical&#8230;mostly).</p>
<p>As is the case with <a href="http://en.wikipedia.org/wiki/Progressivism_in_the_United_States">much snobbery</a>, this is ill-advised. Prior to PHP, I remember writing applications through CGI, <a href="http://perl.apache.org/">mod_perl</a>, or full-blow C extensions to Apache httpd. It was not very productive. Enter, PHP. From the beginning, PHP was designed as a template language to make web development easy. As such, additions to the language and its tool set were evaluated against a fitness function that emphasized ease of use and productivity for web development. At the time, it was the strongest solution to a problem of increasing prevalence.</p>
<p>Fast forward a few years. I had been out of the web development scene completely when a bout of temporary insanity inspired me to attempt <a href="http://pathdependent.com/2008/01/09/starting-an-online-dating-website/">building an online dating site</a> (thanks, <a href="http://www.nytimes.com/2008/01/13/business/13digi.htm">Markus Frind</a>). Since I used Ruby extensively for non-webdev, Rails was my obvious framework choice.</p>
<p>Does Rails have advantages that cannot be replicated in PHP? Of course! The most glaring advantage of Rails over PHP is the fact that PHP is not Ruby. <a href="http://www.ruby-lang.org/en/">Ruby</a> is lovely language. Seriously. Ruby allows you to think in code. It is incredibly productive. You can take very complex abstractions and implement them in Ruby with ease. However, web development is not very complex. Most web development is CRUD. Sure, Ruby might be slow (although 1.9 is looking nice) but most applications really do not require high performance. And when scalability does become an issue, Rails is rarely the bottleneck.</p>
<p>Do I miss <a href="http://docs.rubygems.org/">ruby gems</a>? Sure, but <a href="http://pear.php.net/">Pear</a> works. Moreover, integration with PHP is often easier than it is with rails. When was the last time you noticed that popular api or library lacked a PHP interface? Most sites release official PHP libraries (<a href="http://aws.amazon.com/s3/">s3</a>, <a href="http://aws.amazon.com/ec2/">ec2</a>, <a href="http://developers.facebook.com/">facebook</a>, <a href="http://code.google.com/apis/gdata/articles/php_client_lib.html">gdata</a>, &#8230;)</p>
<p>Conversely, PHP has one several advantages over Rails. Most notably, <a href="http://www.loudthinking.com/posts/23-the-immediacy-of-php">immediacy</a>. Deployment via SCP is <em>very</em> satisfying. Moreover, PHP now has many rapid-development frameworks that employ MVC and active record patterns (e.g. <a href="http://cakephp.org/">CakePHP</a>). While you don&#8217;t have the elegant sexiness of Ruby, you have almost everything else.</p>
<p>Do PHP programmers tend to be weak programmers who produce mediocre code? Maybe. If so, it can probably be attributed to the law of large numbers. There is a virtual army of PHP programmers; there are very few <a href="http://www.loudthinking.com/">DHHs</a>. For large-scale, very complex problems<a href="http://thread.gmane.org/gmane.comp.version-control.git/57643/focus=57918"> it may be better to use a language that naturally excludes poor to mediocre programmers</a>, but this is not true for web development. Besides, there is <a href="http://web.archive.org/web/20080103072111/http://www.zedshaw.com/rants/rails_is_a_ghetto.html">no shortage of criticisms of the rails</a> community.</p>
<p>Finally, there is nothing to stop you from using PHP for the CRUD front-end and Ruby or some other language to do more complex heavy lifting (e.g. spidering, categorization, etc). It seems to have worked well for facebook.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Hello, Old Friend&quot;</span><span style="color: #339933;">;</span></pre></div></div>

<p><strong>UPDATE(OCT-27-2009 @ 1:39)</strong></p>
<div style="margin-left:2em;">I mentioned below and repeated in the comments section that I have used <a href="http://www.capify.org/index.php/Capistrano">Capistrano</a> (a site which, given the current context, ironically uses PHP) and <a href="http://www.modrails.com/">Passenger</a>, but, for reasons I could not qualify, I thought PHP was simpler. Mark just helped finalize the thought for me: PHP is usually preinstalled and ready for rapid deployment &#8212; i.e. immediate initial deployment. <a href="http://heroku.com/">Heroku</a> is wonderful, but not every hosting service is Heroku. If you want an application with diverse end-users, PHP is more likely to be eligible for simplistic initial deployment. It may seem like a minor issue, but in my experience, it is not.</div>
<p><strong>END_UPDATE</strong><br />
<em>This post was motivated by an open-source project I am currently coding. It is not yet released but for the purposes of this footnote, pretend it will have a deployment pattern similar to <a href="http://wordpress.org/">Wordpress</a>. I started writing it in Rails. However, after speaking with several people who will be end-users, I realized that the most important factor would be ease of deployment. While <a href="http://www.modrails.com/">Phusion</a> is a game-changer for deploying Rails applications, I think PHP is still easier for most web developers.</em></p>
<p><em>Also, for the sake of disclosure, I should make it clear that I am not an expert web developer. As you might notice from this blog, most of my work is in complex systems. Most of my time is spent writing code in C or C++ with Ruby acting as glue.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://pathdependent.com/2009/10/26/going-back-to-php/feed/</wfw:commentRss>
		<slash:comments>29</slash:comments>
		</item>
	</channel>
</rss>
