<?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>devgrind &#187; api</title>
	<atom:link href="http://devgrind.com/tag/api/feed/" rel="self" type="application/rss+xml" />
	<link>http://devgrind.com</link>
	<description>thinking outside the { }</description>
	<lastBuildDate>Tue, 04 May 2010 17:25:24 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Use quote_value in Rails 2</title>
		<link>http://devgrind.com/2008/04/03/use-quote_value-in-rails-2/</link>
		<comments>http://devgrind.com/2008/04/03/use-quote_value-in-rails-2/#comments</comments>
		<pubDate>Thu, 03 Apr 2008 19:28:33 +0000</pubDate>
		<dc:creator>Arne</dc:creator>
				<category><![CDATA[api]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[wtf]]></category>

		<guid isPermaLink="false">http://devgrind.com/?p=42</guid>
		<description><![CDATA[This is just a note to all who, like me, wonder why the heck ActiveRecord&#8217;s quote method in model classes doesn&#8217;t work anymore in Rails 2.x: quote seemingly has been replaced by quote_value, though this is not listed on the deprecation page. So if you get an error that says undefined method `quote&#8217; for your [...]]]></description>
			<content:encoded><![CDATA[<p>This is just a note to all who, like me, wonder why the heck ActiveRecord&#8217;s <tt>quote</tt> method in model classes doesn&#8217;t work anymore in Rails 2.x: <tt>quote</tt> seemingly has been replaced by <tt>quote_value</tt>, though this is not listed on the deprecation page. So if you get an error that says <i>undefined method `quote&#8217;</i> for your model class, replace the calls to <tt>quote</tt> by <tt>quote_value</tt>.</p>
]]></content:encoded>
			<wfw:commentRss>http://devgrind.com/2008/04/03/use-quote_value-in-rails-2/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>APIs and DSLs</title>
		<link>http://devgrind.com/2007/04/26/apis-and-dsls/</link>
		<comments>http://devgrind.com/2007/04/26/apis-and-dsls/#comments</comments>
		<pubDate>Thu, 26 Apr 2007 20:11:51 +0000</pubDate>
		<dc:creator>Arne</dc:creator>
				<category><![CDATA[api]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[dsl]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://devgrind.com/2007/04/26/apis-and-dsls/</guid>
		<description><![CDATA[Today I stumbled upon Josh Bloch&#8217;s talk How To Design A Good API and Why it Matters at Google Tech Talks. Its loaded with profound wisdom and advice from one of the masters of API design.
He explains that API design is very similar to language design, and I immediately thought that this particularly holds for [...]]]></description>
			<content:encoded><![CDATA[<p>Today I stumbled upon Josh Bloch&#8217;s talk <a href="http://video.google.com/videoplay?docid=-3733345136856180693">How To Design A Good API and Why it Matters</a> at Google Tech Talks. Its loaded with profound wisdom and advice from one of the masters of API design.</p>
<p>He explains that API design is very similar to language design, and I immediately thought that this particularly holds for APIs which are designed as domain-specific languages, which is one of Ruby&#8217;s strengths (read <a href="http://www.oreillynet.com/ruby/blog/2005/12/what_is_a_dsl.html">this article</a> from Oreillynet.com to learn more about DSLs).</p>
<p>A few slides later he talks about characteristics of good APIs:</p>
<blockquote>
<ul>
<li>Easy to learn</li>
<li>Easy to use, even without documentation</li>
<li>Hard to misuse</li>
<li>Easy to read and maintain code that uses it</li>
<li>Sufficiently powerful to satisfy requirements</li>
<li>Easy to evolve</li>
<li>Appropriate to audience</li>
</ul>
</blockquote>
<p>To achieve all these properties for an API is certainly non-trivial, but at least some of them get easier if you design APIs as a domain-specific languages: As the term says, a DSL provides a language that is tailored for a particular domain, in addition DSLs are generally declarative and hide language aspects that are irrelevant. Such a language is obviously easier to learn, use and to read than a mere API, and is more appropriate to its audience. In the end, these are known strengths of <a href="http://en.wikipedia.org/wiki/Declarative_language">declarative languages</a>. Here&#8217;s an example taken from the <a href="http://manuals.rubyonrails.com/read/chapter/100">Capistrano manual</a> (Capistrano is a Ruby DSL for remote software deployment):<br />
[ruby]<br />
desc &#8220;Start the spinner daemon&#8221;<br />
task :spinner, :roles => :app do<br />
  run &#8220;#{current_path}/script/spin&#8221;<br />
end</p>
<p>desc &#8220;Used only for deploying when the spinner isn&#8217;t running&#8221;<br />
task :cold_deploy do<br />
  transaction do<br />
    update_code<br />
    symlink<br />
  end</p>
<p>  spinner<br />
end<br />
[/ruby]<br />
Though this doesn&#8217;t hide imperative aspects completely, I think it&#8217;s a good example of how a DSL feels &#8211; just as if it wasn&#8217;t Ruby but a different language.
</p>
<p>So, is it safe to conclude that DSLs are the better APIs?</p>
]]></content:encoded>
			<wfw:commentRss>http://devgrind.com/2007/04/26/apis-and-dsls/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
