<?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>Zen and the Art of Programming &#187; Ruby</title>
	<atom:link href="http://programmingzen.com/category/ruby/feed/" rel="self" type="application/rss+xml" />
	<link>http://programmingzen.com</link>
	<description>Meditations on programming, startups, and technology</description>
	<lastBuildDate>Wed, 09 May 2012 07:52:58 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>New Release of the Ruby Driver and Rails Adapter for DB2</title>
		<link>http://programmingzen.com/2012/05/09/new-release-of-the-ruby-driver-and-rails-adapter-for-db2/</link>
		<comments>http://programmingzen.com/2012/05/09/new-release-of-the-ruby-driver-and-rails-adapter-for-db2/#comments</comments>
		<pubDate>Wed, 09 May 2012 07:45:23 +0000</pubDate>
		<dc:creator>Antonio Cangiano</dc:creator>
				<category><![CDATA[DB2]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://programmingzen.com/?p=1466</guid>
		<description><![CDATA[The API team at IBM recently released a new update for the ibm_db gem, which includes both the Ruby driver and the Rails adapter for DB2 (and Informix). This coincides with the release of the latest major upgrade to DB2 LUW (Linux/Unix/Windows), which is now up to version 10.1. ibm_db 2.5.10 adds support for Rails [...]
Possibly related posts:<ol>
<li><a href='http://programmingzen.com/2009/09/03/installing-the-ruby-driver-for-db2-on-mac-os-x-snow-leopard/' rel='bookmark' title='Installing the Ruby driver for DB2 on Mac OS X Snow Leopard'>Installing the Ruby driver for DB2 on Mac OS X Snow Leopard</a></li>
<li><a href='http://programmingzen.com/2011/05/11/installing-ruby-on-rails-and-db2-on-ubuntu-11-04/' rel='bookmark' title='Installing Ruby on Rails and DB2 on Ubuntu 11.04'>Installing Ruby on Rails and DB2 on Ubuntu 11.04</a></li>
<li><a href='http://programmingzen.com/2010/01/21/db2-support-for-rubyrails-turns-2-0/' rel='bookmark' title='DB2 support for Ruby/Rails turns 2.0'>DB2 support for Ruby/Rails turns 2.0</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>The API team at IBM recently released a new update for the <a href="http://rubygems.org/gems/ibm_db">ibm_db gem</a>, which includes both the Ruby driver and the Rails adapter for <a href="http://db2express.com/download/?S_TACT=ACDB201">DB2</a> (and Informix). This coincides with the release of the latest major upgrade to DB2 LUW (Linux/Unix/Windows), which is now up to version 10.1.</p>
<p>ibm_db 2.5.10 adds support for Rails 3.2 and fixes a few minor bugs that have been reported by the community. New features such as Time Travel Queries are supported seamlessly.</p>
<p>The biggest news is the simplified installation process. You now only need to set the DB2&#8242;s instance user home, and the gem installation process will take care of determining both which architecture (e.g., 32 vs 64 bit) and libraries to use.</p>
<p>All it really takes now to install ibm_db on a Linux/Unix/Mac box is something along the lines of:</p>
<pre class="highlight">$ sudo -s
$ export IBM_DB_HOME=/home/db2inst1/sqllib
$ gem install ibm_db</pre>
<p>Windows users don&#8217;t even have to worry about setting up the home directory. It will work both on Windows 32 and 64 bit systems, but unlike with *nix systems, Ruby and ibm_db will run in 32 bit mode only.</p>
<p>To try out DB2 with Ruby/Rails, I recommend you download and install <a href="http://db2express.com/download/?S_TACT=ACDB201">DB2 Express-C</a> for free.</p>
<p>Possibly related posts:<ol>
<li><a href='http://programmingzen.com/2009/09/03/installing-the-ruby-driver-for-db2-on-mac-os-x-snow-leopard/' rel='bookmark' title='Installing the Ruby driver for DB2 on Mac OS X Snow Leopard'>Installing the Ruby driver for DB2 on Mac OS X Snow Leopard</a></li>
<li><a href='http://programmingzen.com/2011/05/11/installing-ruby-on-rails-and-db2-on-ubuntu-11-04/' rel='bookmark' title='Installing Ruby on Rails and DB2 on Ubuntu 11.04'>Installing Ruby on Rails and DB2 on Ubuntu 11.04</a></li>
<li><a href='http://programmingzen.com/2010/01/21/db2-support-for-rubyrails-turns-2-0/' rel='bookmark' title='DB2 support for Ruby/Rails turns 2.0'>DB2 support for Ruby/Rails turns 2.0</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://programmingzen.com/2012/05/09/new-release-of-the-ruby-driver-and-rails-adapter-for-db2/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>RubyMotion brings serious Ruby development to the iOS world</title>
		<link>http://programmingzen.com/2012/05/03/rubymotion-brings-serious-ruby-development-to-the-ios-world/</link>
		<comments>http://programmingzen.com/2012/05/03/rubymotion-brings-serious-ruby-development-to-the-ios-world/#comments</comments>
		<pubDate>Thu, 03 May 2012 16:40:09 +0000</pubDate>
		<dc:creator>Antonio Cangiano</dc:creator>
				<category><![CDATA[Cocoa and Objective-C]]></category>
		<category><![CDATA[iOS Development]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://programmingzen.com/?p=1463</guid>
		<description><![CDATA[For the past several months I&#8217;ve been involved with, but unable to publicly discuss, an exciting project called RubyMotion. My friend Laurent Sansonetti, creator of MacRuby, has now officially launched a serious alternative to Objective-C for iPhone and iPad development. RubyMotion is not a bridge; it actually generates native applications that are as fast as the [...]
Possibly related posts:<ol>
<li><a href='http://programmingzen.com/2008/04/20/is-the-enteprise-world-rails-ready/' rel='bookmark' title='Is the Enterprise world Rails ready?'>Is the Enterprise world Rails ready?</a></li>
<li><a href='http://programmingzen.com/2010/06/17/would-you-use-a-mac-mini-as-your-development-machine/' rel='bookmark' title='Would you use a Mac mini as your development machine?'>Would you use a Mac mini as your development machine?</a></li>
<li><a href='http://programmingzen.com/2011/09/20/mobile-development-marketshare/' rel='bookmark' title='Mobile Development Marketshare Among Hacker News&#8217; Participants'>Mobile Development Marketshare Among Hacker News&#8217; Participants</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>For the past several months I&#8217;ve been <a href="http://www.rubymotion.com/about/">involved</a> with, but unable to publicly discuss, an exciting project called <a href="http://www.rubymotion.com/">RubyMotion</a>. My friend Laurent Sansonetti, creator of MacRuby, has now officially launched a serious alternative to Objective-C for iPhone and iPad development.</p>
<p>RubyMotion is not a bridge; it actually generates native applications that are as fast as the ones written in Objective-C . You can check out <a href="http://arstechnica.com/business/news/2012/05/exclusive-building-ruby-ios-applications-with-rubymotion.ars">Ars Technica&#8217;s exclusive article</a> for more details on the project and watch the Pragmatic Studio&#8217;s 50 minute <a href="http://pragmaticstudio.com/screencasts/rubymotion">free screencast</a> about it to get a better idea of how RubyMotion works in practice.</p>
<p><a href="http://www.rubymotion.com/"><img style="display: block; margin-left: auto; margin-right: auto;" title="rubymotion.png" src="http://programmingzen.com/wp-content/uploads/2012/05/rubymotion.png" alt="RubyMotion" width="600" height="367" border="0" /></a>For a limited time you can buy RubyMotion at an <a href="http://sites.fastspring.com/hipbyte/product/rubymotion">early bird discount</a> rate of 25% off. It&#8217;s such a productive and affordable solution, that I&#8217;m sure it will quickly become popular among Ruby developers who are interested in iOS development and testing, as well as among existing iOS developers.</p>
<p>Many of the questions you may have can likely be found in the <a href="http://www.rubymotion.com/support/#faq">FAQ</a> section, but feel free to ask any additional questions here. Enjoy it.</p>
<p>Possibly related posts:<ol>
<li><a href='http://programmingzen.com/2008/04/20/is-the-enteprise-world-rails-ready/' rel='bookmark' title='Is the Enterprise world Rails ready?'>Is the Enterprise world Rails ready?</a></li>
<li><a href='http://programmingzen.com/2010/06/17/would-you-use-a-mac-mini-as-your-development-machine/' rel='bookmark' title='Would you use a Mac mini as your development machine?'>Would you use a Mac mini as your development machine?</a></li>
<li><a href='http://programmingzen.com/2011/09/20/mobile-development-marketshare/' rel='bookmark' title='Mobile Development Marketshare Among Hacker News&#8217; Participants'>Mobile Development Marketshare Among Hacker News&#8217; Participants</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://programmingzen.com/2012/05/03/rubymotion-brings-serious-ruby-development-to-the-ios-world/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Speeding up queries by a factor of 100 or more with DB2 Text Search</title>
		<link>http://programmingzen.com/2011/07/19/getting-started-with-db2-text-search/</link>
		<comments>http://programmingzen.com/2011/07/19/getting-started-with-db2-text-search/#comments</comments>
		<pubDate>Tue, 19 Jul 2011 17:11:42 +0000</pubDate>
		<dc:creator>Antonio Cangiano</dc:creator>
				<category><![CDATA[Databases]]></category>
		<category><![CDATA[DB2]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://programmingzen.com/?p=1397</guid>
		<description><![CDATA[During a recent Rails project at IBM we had to deal with a large table consisting of customers. The table is made up of legacy enterprise data, and contains close to a million records. Among many other fields, the table Customers includes a column name defined as VARCHAR. name is used to store company names. [...]
No related posts.]]></description>
			<content:encoded><![CDATA[<p>
	During a recent Rails project at IBM we had to deal with a large table consisting of customers. The table is made up of legacy enterprise data, and contains close to a million records.
</p>
<p>
	Among many other fields, the table <code>Customers</code> includes a column <code>name</code> defined as <code>VARCHAR</code>. <code>name</code> is used to store company names.
</p>
<p>
	One of the requirements for the project was to implement a Google Suggest-like feature. That is, when the user enters a few characters for the customer&#8217;s name, they should be prompted, via AJAX, with a list of possible suggestions containing that string (or at least beginning with that string.)
</p>
<p>
	The naive approach would be to use a simple <code>LIKE</code> predicate, to generate queries such as:
</p>
<div class="highlight">
<pre><span class="k">SELECT</span> <span class="n">name</span>
<span class="k">FROM</span>   <span class="n">Customers</span>
<span class="k">WHERE</span>  <span class="n">name</span> <span class="k">LIKE</span> <span class="s1">&#39;%micro%&#39;</span>
<span class="k">ORDER</span>  <span class="k">BY</span> <span class="n">name</span>
</pre>
</div>
<p>
	One of the main problems with this approach is performance. Using <code>LIKE</code> this way doesn&#8217;t allow us to take advantage of indexes that are defined on the column <code>name</code>.
</p>
<p>
	Unsurprisingly, on a modest server, such a query takes about 25 seconds. A UI that isn&#8217;t able to respond for 25 seconds will feel like an eternity for the end user, of course, so a simple query like this obviously cannot be seen as a viable solution.
</p>
<p>
	Enter DB2 Text Search. You may be familiar with other full text search engines such as Ferret, Lucene, or Sphinx. <a href="http://db2express.com/download/?S_TACT=ACDB201">DB2 V9.7.4</a> ships with an extremely powerful full text search engine that has plenty of useful features, including excellent integration with native XML columns.
</p>
<p>
	Using the <a href="http://db2express.com/download/?S_TACT=ACDB201">free edition of DB2</a> (DB2 Express-C) which includes Text Search, we were able to implement the autocomplete functionality we were after in a heartbeat, thanks to a query like the following:
</p>
<div class="highlight">
<pre><span class="k">SELECT</span> <span class="n">name</span>
<span class="k">FROM</span>   <span class="n">Customers</span>
<span class="k">WHERE</span>  <span class="k">CONTAINS</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="s1">&#39;micro&#39;</span><span class="p">)</span> <span class="o">=</span> <span class="mi">1</span>
<span class="k">ORDER</span>  <span class="k">BY</span> <span class="n">name</span>
</pre>
</div>
<p>
	This query was executed in mere fractions of a second for most searches, and behaved exactly as needed. In fact, not only did we match strings that began with the searched token, but also ones that contained it elsewhere (e.g., <code>micro</code> would match both <code>Microsoft</code> and <code>Sun Microsystems</code>.) The results where ordered alphabetically, but could have easily been ordered by relevance via the <code>SCORE</code> function, also available via DB2 Text Search.
</p>
<p>
	As usual, it&#8217;s a matter of using the right tool for the right job, and DB2 Text Search was created exactly for these kind of scenarios.</p>
<p>
	Let&#8217;s briefly look at how you can also go about setting up and playing with it on Linux.
</p>
<h3>Installing DB2 Text Search</h3>
<p>
	To start with, you&#8217;ll need to have a 64bit Linux distro, and then follow these simple steps.
</p>
<p>
	Download <a href="http://db2express.com/download/?S_TACT=ACDB201">DB2 Express-C</a>. Make sure you grab the <code>db2exc_974_LNX_x86_64.tar.gz</code> file and not the Light edition.
</p>
<p>
	Next, install DB2 by following <a href="http://programmingzen.com/2011/05/11/installing-ruby-on-rails-and-db2-on-ubuntu-11-04/">these steps</a> (the <em>Installing DB2</em> section in particular.) Make sure you select a custom installation, and that you select everything including DB2 Text Search (which is not checked by default).
</p>
<p>
	After you&#8217;ve started DB2 with <code>db2start</code> via the instance user (e.g., <code>db2inst1</code>,) launch the text search server by running:
</p>
<pre class="highlight">
db2ts start for text
</pre>
<p>
	To enable text search for an existing database, run:
</p>
<pre class="highlight">
db2ts enable database for text connect to mydb
</pre>
<p>
	Next, you&#8217;ll need to create a text search index and populate it. For example:
</p>
<pre class="highlight">
db2ts "create index customer_name for text on customers(name) connect to mydb"
db2ts "update index customer_name for text connect to mydb"
</pre>
<p>
	That&#8217;s it. From now on you&#8217;ll be able to use functions such as <code>CONTAINS</code> to quickly search for your data.
</p>
<p>
	Such a function can also be easily invoked in Rails:
</p>
<div class="highlight">
<pre><span class="no">Customer</span><span class="o">.</span><span class="n">where</span><span class="p">(</span><span class="s2">&quot;CONTAINS(name, ?) = 1&quot;</span><span class="p">,</span> <span class="nb">name</span><span class="p">)</span>
</pre>
</div>
<p>
	Or wrapping it a little in a model:
</p>
<div class="highlight">
<pre><span class="k">class</span> <span class="nc">Customer</span> <span class="o">&lt;</span> <span class="no">ActiveRecord</span><span class="o">::</span><span class="no">Base</span>
  <span class="c1"># ... </span>
  <span class="k">def</span> <span class="nc">self</span><span class="o">.</span><span class="nf">search</span><span class="p">(</span><span class="nb">name</span><span class="p">,</span> <span class="n">max_res</span> <span class="o">=</span> <span class="mi">10</span><span class="p">)</span>
    <span class="n">where</span><span class="p">(</span><span class="s1">&#39;CONTAINS(name, ?) = 1&#39;</span><span class="p">,</span> <span class="nb">name</span><span class="p">)</span><span class="o">.</span>
    <span class="n">order</span><span class="p">(</span><span class="s1">'name'</span><span class="p">)</span><span class="o">.</span>
    <span class="n">limit</span><span class="p">(</span><span class="n">max_res</span><span class="p">)</span>
  <span class="k">end</span>
<span class="k">end</span>
</pre>
</div>
<p>
Which can then be invoked as follows:
</p>
<div class="highlight">
<pre>
<span class="no">Customer</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="s2">&quot;micro&quot;</span><span class="p">)</span>
</pre>
</div>
<p>
	(Technically we wouldn&#8217;t have needed <code>limit</code>, so long as we passed <code>RESULTLIMIT</code> to the <code>CONTAINS</code> function.)
</p>
<p>
	You can read more about <a href="http://publib.boulder.ibm.com/infocenter/db2luw/v9r7/index.jsp?topic=/com.ibm.db2.luw.admin.ts.doc/doc/c0051296.html">DB2 Text Search</a> at the Information Center.</p>
<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://programmingzen.com/2011/07/19/getting-started-with-db2-text-search/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>10 Ruby One Liners to Impress Your Friends</title>
		<link>http://programmingzen.com/2011/06/02/10-ruby-one-liners-to-impress-your-friends/</link>
		<comments>http://programmingzen.com/2011/06/02/10-ruby-one-liners-to-impress-your-friends/#comments</comments>
		<pubDate>Thu, 02 Jun 2011 20:53:08 +0000</pubDate>
		<dc:creator>Antonio Cangiano</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Scala]]></category>

		<guid isPermaLink="false">http://programmingzen.com/?p=1383</guid>
		<description><![CDATA[Someone came up with a list of 10 one-liner examples that are meant to showcase Scala’s expressiveness. A CoffeeScript version quickly emerged, so I thought I’d publish a Ruby one. I find Ruby’s syntax to be a bit cleaner than Scala&#8217;s, but the substance (at least as far as these examples are concerned) is relatively [...]
No related posts.]]></description>
			<content:encoded><![CDATA[<p>Someone came up with <a href="http://solog.co/47/10-scala-one-liners-to-impress-your-friends/" target="_blank">a list of 10 one-liner examples</a> that are meant to showcase Scala’s expressiveness. <a href="http://ricardo.cc/2011/06/02/10-CoffeeScript-One-Liners-to-Impress-Your-Friends.html" target="_blank">A CoffeeScript version</a> quickly emerged, so I thought I’d publish a Ruby one. I find Ruby’s syntax to be a bit cleaner than Scala&#8217;s, but the substance (at least as far as these examples are concerned) is relatively similar.</p>
<h4>Multiply each item in a list by 2</h4>
<pre class="highlight">(1..10).map { |n| n * 2 }</pre>
<h4>Sum a list of numbers</h4>
<pre class="highlight">(1..1000).inject { |sum, n| sum + n }</pre>
<p>Or using the (built in) Symbol#to_proc syntax that&#8217;s been available since Ruby 1.8.7:</p>
<pre class="highlight">(1..1000).inject(&#038;:+)</pre>
<p>Or even just passing a symbol directly:</p>
<pre class="highlight">(1..1000).inject(:+)</pre>
<h4>Verify if tokens exist in a string</h4>
<pre class="highlight">words = ["scala", "akka", "play framework", "sbt", "typesafe"]
tweet = "This is an example tweet talking about scala and sbt."

words.any? { |word| tweet.include?(word) }</pre>
<h4>Reading a file</h4>
<pre class="highlight">file_text = File.read("data.txt")
file_lines = File.readlines("data.txt")</pre>
<p>The latter includes &#8220;\n&#8221; at the end of each element of the array, which can be trimmed by appending <code>.map { |str| str.chop }</code> or by using the alternative version:</p>
<pre class="highlight">File.read("data.txt").split(/\n/)</pre>
<h4>Happy Birthday</h4>
<pre class="highlight">4.times { |n| puts "Happy Birthday #{n==2 ? "dear Tony" : "to You"}" }</pre>
<h4>Filter a list of numbers</h4>
<pre class="highlight">[49, 58, 76, 82, 88, 90].partition { |n| n > 60 }</pre>
<h4>Fetch and parse an XML web service</h4>
<pre class="highlight">require 'open-uri'
require 'hpricot'

results = Hpricot(open("http://search.twitter.com/search.atom?&#038;q=scala"))</pre>
<p>This example requires open-uri and hpricot or equivalent libraries (you could use builtin ones if you wish). It&#8217;s not too much code, but Scala clearly wins here.</p>
<h4>Find minimum (or maximum) in a list</h4>
<pre class="highlight">[14, 35, -7, 46, 98].min
[14, 35, -7, 46, 98].max</pre>
<h4>Parallel Processing</h4>
<pre class="highlight">require 'parallel'

Parallel.map(lots_of_data) do |chunk|
  heavy_computation(chunk)
end</pre>
<p>Unlike Scala, multicore support is not built-in. It requires <a href="https://github.com/grosser/parallel">parallel</a> or a similar gem.</p>
<h4>Sieve of Eratosthenes</h4>
<p>The Scala one liner is very clever, but entirely unreadable. A simpler implementation that is no longer a one-liner in Ruby would be:</p>
<pre class="highlight">index = 0
while primes[index]**2 <= primes.last
      prime = primes[index]
      primes = primes.select { |x| x == prime || x % prime != 0 }
      index += 1
end
p primes
</pre>
<p>This last example is <a href="http://stackoverflow.com/questions/241691/sieve-of-eratosthenes-in-ruby" target="_blank">straight from StackOverflow</a>. Not the prettiest code ever, but you get the idea.</p>
<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://programmingzen.com/2011/06/02/10-ruby-one-liners-to-impress-your-friends/feed/</wfw:commentRss>
		<slash:comments>20</slash:comments>
		</item>
		<item>
		<title>Installing Ruby on Rails and DB2 on Ubuntu 11.04</title>
		<link>http://programmingzen.com/2011/05/11/installing-ruby-on-rails-and-db2-on-ubuntu-11-04/</link>
		<comments>http://programmingzen.com/2011/05/11/installing-ruby-on-rails-and-db2-on-ubuntu-11-04/#comments</comments>
		<pubDate>Wed, 11 May 2011 21:10:56 +0000</pubDate>
		<dc:creator>Antonio Cangiano</dc:creator>
				<category><![CDATA[DB2]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://programmingzen.com/?p=1372</guid>
		<description><![CDATA[In this tutorial I&#8217;ll show you how to create a complete Ruby on Rails setup for DB2 on Ubuntu. Following my step-by-step instructions, you&#8217;ll be able to install the following components: Ruby 1.8.7 Rubygems Ruby on Rails DB2 Express-C 9.7.4 The official Ruby driver and Rails adapter for DB2 Installing Ruby We are going to [...]
Possibly related posts:<ol>
<li><a href='http://programmingzen.com/2007/11/11/installing-db2-95-on-ubuntu-710/' rel='bookmark' title='Installing DB2 9.5 on Ubuntu 7.10'>Installing DB2 9.5 on Ubuntu 7.10</a></li>
<li><a href='http://programmingzen.com/2007/12/26/installing-django-with-postgresql-on-ubuntu/' rel='bookmark' title='Installing Django with PostgreSQL on Ubuntu'>Installing Django with PostgreSQL on Ubuntu</a></li>
<li><a href='http://programmingzen.com/2009/09/10/installing-and-configuring-db2-express-c-9-7-on-ubuntu-9-04-server/' rel='bookmark' title='Installing and configuring DB2 Express-C 9.7 on Ubuntu 9.04 Server'>Installing and configuring DB2 Express-C 9.7 on Ubuntu 9.04 Server</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>In this tutorial I&#8217;ll show you how to create a complete Ruby on Rails setup for DB2 on Ubuntu. Following my step-by-step instructions, you&#8217;ll be able to install the following components:</p>
<ul>
<li>Ruby 1.8.7</li>
<li>Rubygems</li>
<li>Ruby on Rails</li>
<li><a href="http://db2express.com/download/?S_TACT=ACDB201">DB2 Express-C 9.7.4</a></li>
<li><a href="https://rubyforge.org/projects/rubyibm/">The official Ruby driver and Rails adapter for DB2</a></li>
</ul>
<h3 id="installing_ruby">Installing Ruby</h3>
<p>We are going to install Ruby 1.8.7 using the Debian packages that are available in the default repositories:</p>
<pre class="highlight">$ sudo apt-get install ruby-full</pre>
<p>Next we&#8217;ll build Rubygems from scratch, so as to obtain a recent version and be able to update it to the latest one via the gem system itself:</p>
<pre class="highlight">$ cd /tmp/
$ wget http://production.cf.rubygems.org/rubygems/rubygems-1.7.2.tgz
$ tar xvfz rubygems-1.7.2.tgz
$ cd rubygems-1.7.2
$ sudo ruby setup.rb
$ sudo gem update --system</pre>
<p>You can now verify that Rubygems is correctly installed:</p>
<pre class="highlight">$ gem -v
1.8.1</pre>
<p>Note: If you plan to have multiple versions of Ruby, you&#8217;ll probably want to look into RVM.</p>
<h3 id="installing_rails">Installing Rails</h3>
<p>We are not going to install the Rails package that ships with Ubuntu, because this is also quite obsolete at this stage. Instead, we&#8217;ll use the newly installed gem command:</p>
<pre class="highlight">$ sudo gem install rails</pre>
<p>(Add the <code>--no-rdoc --no-ri</code> flags if you don&#8217;t care about the local documentation. This will speed up the installation process.)</p>
<p>You can verify the installed version by running:</p>
<pre class="highlight">$ rails -v
Rails 3.0.7</pre>
<p></p>
<h3 id="installing_db2">Installing DB2</h3>
<p>We can now download and install <a href="http://db2express.com/download/?S_TACT=ACDB201">DB2 Express-C 9.7.4</a>. <a href="http://db2express.com/download/?S_TACT=ACDB201">Download the .tar.gz installation file</a> to a location that&#8217;s convenient for you. Then proceed to unpack it:</p>
<pre class="highlight">$ cd ~/Downloads/
$ tar xvfz db2exc_974_LNX_x86.tar.gz
$ cd expc</pre>
<p>We&#8217;ll install one required library and then proceed with the setup:</p>
<pre class="highlight">$ sudo apt-get install libaio1
$ sudo ./db2setup</pre>
<p>Follow the GUI wizard on screen to continue with the installation. Pay close attention to two steps:</p>
<ul>
<li>When prompted <strong>select a custom installation</strong>, and when choosing the components, select all of them We&#8217;ll need the <strong>Application Development Tools</strong> in order to build the Ruby driver later on. (And these are unchecked by default.)</li>
<li>When asked if you&#8217;d like to <strong>create an instance user</strong>, go with that option. It greatly simplifies the setup process.</li>
</ul>
<p>When the setup of DB2 is completed, you should receive a confirmation message informing you about the successful installation.</p>
<p>For good measure, add the following line to your <code>~/.bashrc</code> file:</p>
<pre class="highlight">. /home/db2inst1/sqllib/db2profile</pre>
<p>This ensures that even your regular, non-DB2, user will be able to connect and interact with the database.</p>
<h3 id="installing_the_ibm_db_gem">Installing the ibm_db gem</h3>
<p>The last step we need to take is to install the ibm_db gem, which includes the IBM released (and supported) open source driver for Ruby, as well as the adapter for Rails. You&#8217;ll need these in order to use Rails with DB2.</p>
<p>Open a new shell and run:</p>
<pre class="highlight">$ sudo -s
$ export IBM_DB_INCLUDE=/home/db2inst1/sqllib/include
$ export IBM_DB_LIB=/home/db2inst1/sqllib/lib
$ . /home/db2inst1/sqllib/db2profile
$ gem install ibm_db
$ exit</pre>
<p>At the time of writing, this installs ibm_db-2.5.6.</p>
<h3 id="a_quick_sanity_test">A quick sanity test</h3>
<p>To ensure that all is well with your setup, run the following command:</p>
<pre class="highlight">$ rails new db2test -d ibm_db
$ cd db2test</pre>
<p>Now, edit <code>config/database.yml</code> so that the development section uses the same password you specified for the <code>db2inst1</code> user during the installation of DB2. Change the database name to something like <code>db2test</code>. The section should look like the example below:</p>
<pre class="highlight">development:
	adapter: ibm_db
	username: db2inst1
	password: secret
	database: db2test</pre>
<p>Create the database <code>db2test</code> by running:</p>
<pre class="highlight">$ su - db2inst1
$ db2start
$ db2 create db db2test
$ exit</pre>
<p>Depending on your hardware specs, the infrequent operation of creating a database can take quite a long time (e.g., minutes).</p>
<p>We will now install/attach the required gems for this project:</p>
<pre class="highlight">$ bundle install</pre>
<p>For the sake of a quick example, we&#8217;ll use scaffold to generate some super-basic code. We&#8217;ll then run migrations, and the built-in web server:</p>
<pre class="highlight">$ rails g scaffold Subject name:string
$ rake db:migrate
$ rails s</pre>
<p>Visit <code>http://localhost:3000/subjects</code> and you should see a scaffold interface you can use to create, edit, show, and destroy subjects, as I&#8217;ve done in the screenshot below.</p>
<p align="center"><a href="http://programmingzen.com/wp-content/uploads/2011/05/subjects-sample.png"><img src="http://programmingzen.com/wp-content/uploads/2011/05/subjects-sample.png" alt="subjects-sample" title="subjects-sample" width="401" height="349" class="aligncenter size-full wp-image-1373" /></a></p>
<p>Note: As you develop, you&#8217;ll probably want to use a better web server such as mongrel, unicorn, or thin. You can easily do so by editing your <code>Gemfile</code> and installing the gem via <code>bundle</code>.</p>
<h3 id="if_you_need_help">Getting help</h3>
<p>IBM is the only database vendor to officially provide and support its Ruby driver and Rails adapter. While commercial 24/7 DB2 support is certainly available and relatively inexpensive (i.e., <a href="http://www.db2teamblog.com/2010/12/treat-yourself-to-db2-this-holiday.html">cheaper than MySQL</a>), your first line of defense is posing your questions in the <a href="https://rubyforge.org/forum/forum.php?forum_id=9503">support forum</a> over at Rubyforge. Alternatively, if the question is DB2-specific and not related to Ruby or Rails, you can use the <a href="http://www.ibm.com/developerworks/forums/forum.jspa?forumID=805">DB2 Express-C forum</a> over at developerWorks instead.</p>
<p>Possibly related posts:<ol>
<li><a href='http://programmingzen.com/2007/11/11/installing-db2-95-on-ubuntu-710/' rel='bookmark' title='Installing DB2 9.5 on Ubuntu 7.10'>Installing DB2 9.5 on Ubuntu 7.10</a></li>
<li><a href='http://programmingzen.com/2007/12/26/installing-django-with-postgresql-on-ubuntu/' rel='bookmark' title='Installing Django with PostgreSQL on Ubuntu'>Installing Django with PostgreSQL on Ubuntu</a></li>
<li><a href='http://programmingzen.com/2009/09/10/installing-and-configuring-db2-express-c-9-7-on-ubuntu-9-04-server/' rel='bookmark' title='Installing and configuring DB2 Express-C 9.7 on Ubuntu 9.04 Server'>Installing and configuring DB2 Express-C 9.7 on Ubuntu 9.04 Server</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://programmingzen.com/2011/05/11/installing-ruby-on-rails-and-db2-on-ubuntu-11-04/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Interview with Michael Hartl, author of the Rails 3 Tutorial</title>
		<link>http://programmingzen.com/2011/03/09/interview-with-michael-hartl-author-of-the-rails-3-tutorial/</link>
		<comments>http://programmingzen.com/2011/03/09/interview-with-michael-hartl-author-of-the-rails-3-tutorial/#comments</comments>
		<pubDate>Wed, 09 Mar 2011 18:00:06 +0000</pubDate>
		<dc:creator>Antonio Cangiano</dc:creator>
				<category><![CDATA[Books]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://programmingzen.com/?p=1316</guid>
		<description><![CDATA[The following is an interview with Michael Hartl, author of the popular Rails 3 Tutorial. I want to thank Michael for his time and answers. Be sure to read until the end; as per Monday&#8217;s post, I&#8217;m doing a Twitter giveaway for this interview, too. 1. How did you go from Theoretical Physics to Ruby [...]
No related posts.]]></description>
			<content:encoded><![CDATA[<p>The following is an interview with Michael Hartl, author of the popular <a href="http://zfer.us/hUnNL">Rails 3 Tutorial</a>. I want to thank Michael for his time and answers. Be sure to read until the end; as per Monday&#8217;s post, I&#8217;m doing a Twitter giveaway for this interview, too.</p>
<p><strong>1. How did you go from Theoretical Physics to Ruby Programming?</strong></p>
<p><img src="http://programmingzen.com/wp-content/uploads/2011/03/michael_hartl.jpg" alt="Michael Hartl" title="Michael Hartl" width="150" height="150" class="alignright size-full wp-image-1317" />I have a background in computational physics, and I learned Perl and then Python to avoid the pain of C/C++ as much as possible. (The core simulation code for my work was in C/C++ for speed, but I had lots of scripting needs as well, and using C/C++ for scripting would have been horrible.) That led naturally to experimenting with web programming, and I ended up writing my own half-baked web framework in Python. After Rails came out, I switched to Ruby, and haven&#8217;t looked back. (I generally prefer Ruby, but Python is also nice. I&#8217;ll remain silent on Perl. <img src='http://programmingzen.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> )</p>
<p><strong>2. There wasn&#8217;t a lack of Ruby and Rails books when you started working on the <a href="http://zfer.us/hUnNL">Rails Tutorial</a>. What motivated you to create it?</strong></p>
<p>There were lots of Rails books, but there weren&#8217;t any that took the approach I wanted to take, namely, a single substantial sample application with features and pacing carefully chosen for pedagogical purposes. My first book, RailsSpace, filled that niche, but it was out-of-date, and I also perceived an opportunity with the (then-upcoming) release of Rails 3. I figured that <a href="http://zfer.us/hUnNL">a full-length tutorial book aimed at Rails 3</a> could find a broad audience.</p>
<p><strong>3. What would you say was your biggest challenge in preparing the tutorial?</strong></p>
<p>On a long-term project of this sort, it can be difficult to balance writing with the need to pay the bills. For a while at the beginning, I alternated between doing contract work and writing, and that takes its toll. Not only does contract work take time, but there is a also a big context switch when changing over to writing mode. Doing contract work was necessary given my financial situation at the time, but in the future I expect to be able to focus solely on writing and screencasting.</p>
<p><strong>4. You chose an approach rarely taken by traditional publishers, by producing a free HTML version of the Rails Tutorial, while providing a DRM-free PDF version and supplementary video lessons for a fee. How is the market treating you? Is it an approach that you&#8217;d recommend to fellow programmers?</strong></p>
<p>The market response has been great. The free HTML version has attracted lots of referrals and inbound links, which was its main strategic purpose, and it has also generated lots of good karma. Meanwhile, many people are happy to buy the PDF, which is easy to put on an iPad and can be read offline. Readers have also reported that having the PDF gives them a sense of ownership, and they also like knowing that they are supporting the Rails Tutorial project financially.</p>
<p>I have recommended this approach to other programmers (most recently in a talk at the Los Angeles Ruby Conference). Having a free HTML version is a business strategy, not charity, though it does feel good—I&#8217;ve gotten email from many readers, especially in poorer countries, thanking me for making the book available for free online.</p>
<p><strong>5. The book is also <a href="/recommends/?0321743121">in print</a> through the excellent Ruby series by Addison-Wesley. Did they reach out to you after the huge success of your online tutorial/video course or was there a plan of world domination all along?</strong></p>
<p>Partnering with a major publisher was part of the initial plan for world domination, but I didn&#8217;t think it was strictly necessary. The publisher and I attempted to get a deal in place before I wrote the book, but were unable to come to terms. After I finished the book, we got back in touch and worked out the details of a publication agreement. It&#8217;s an unusual arrangement, and I&#8217;m thankful to Addison-Wesley for being willing to try it out. Please go out and <a href="/recommends/?0321743121">buy the print edition</a> to reward them for their support of the Ruby community!</p>
<p><strong>6. Do you have any advice for people starting out with Rails (other than reading your book and watching your screencasts, of course)?</strong></p>
<p>Web development is hard, so be prepared for some challenges and occasional frustration. It&#8217;s especially good to pick a project you care about; that will help keep you motivated when the going gets tough.</p>
<p><strong>7. If you had a magic wand, what would you change in the Ruby/Rails ecosystem? And how can we make it happen without said magic wand?</strong></p>
<p>I&#8217;d make Ruby and Rails installation easier; the barrier to entry in some cases is still forbiddingly high. For example, a while back I spent a couple of hours just getting Ruby to compile after an upgrade to OS X Snow Leopard. (There was a subtle issue related to the location of the readline library headers.) Paradoxically, I think in the early years this may have benefited Rails by insuring that the typical Rails developer was both determined and highly skilled, but the Rails community has matured now to the point where lowering that barrier should be a priority. Happily, Engine Yard has hired the awesome Wayne E. Seguin (best known as the author of Ruby Version Manager, or RVM) to work on exactly this problem. The initial result, the <a href="http://railsinstaller.org/">Rails Installer</a> for Windows, looks promising, and I&#8217;m excited to see where that project goes from here.</p>
<p><strong>8. What&#8217;s next for you?</strong></p>
<p>My O(n) Rails Tutorial workload is minimal right now, which is a good sign, but I have a large O(1) work queue to complete. For example, I&#8217;m preparing a free screencast for buyers of the print edition, and I&#8217;ve committed to making the HTML book available for translation. Once that work queue cycles down to zero, I&#8217;m going to take a little time off, and then I&#8217;ll probably start making some more Rails- and Ruby-related products. Interested readers should subscribe to the <a href="http://news.railstutorial.org/">Rails Tutorial news feed</a> to be notified when future products are available. In addition, anyone who buys the <a href="http://zfer.us/hUnNL">Rails Tutorial PDF/screencast bundle</a> will likely be pleasantly surprised by exclusive coupon codes when the time comes. (Well, they won&#8217;t be surprised now, but you get the idea. <img src='http://programmingzen.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> )</p>
<p><strong>Book giveaway</strong>: I will randomly draw one person from among those who share (retweet) this interview on Twitter, and personally ship that person a free printed copy of the Rails 3 Tutorial. All you have to do to be entered in this giveaway is to <a href="http://twitter.com/share/?text=Interview%20with%20Michael%20Hartl,%20author%20of%20the%20Rails%203%20Tutorial.%20Retweet%20for%20a%20chance%20to%20win%20a%20copy:&#038;url=http://su.pr/198gFQ&#038;via=acangiano">tweet about this post</a>. I will announce the winner on Friday morning on <a href="http://twitter.com/acangiano">my twitter account</a> (follow me!) and in the comments below.</p>
<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://programmingzen.com/2011/03/09/interview-with-michael-hartl-author-of-the-rails-3-tutorial/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Eloquent Ruby Review</title>
		<link>http://programmingzen.com/2011/03/07/eloquent-ruby-review/</link>
		<comments>http://programmingzen.com/2011/03/07/eloquent-ruby-review/#comments</comments>
		<pubDate>Mon, 07 Mar 2011 18:00:25 +0000</pubDate>
		<dc:creator>Antonio Cangiano</dc:creator>
				<category><![CDATA[Books]]></category>
		<category><![CDATA[In-Depth Book Reviews]]></category>
		<category><![CDATA[Reviews]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://programmingzen.com/?p=1311</guid>
		<description><![CDATA[In 2007 Russ Olsen published Design Patterns in Ruby (US &#124; UK &#124; CA). Right around that time there were several other Ruby books hitting the shelves (as Rails was really reaching the peak of its popularity), however Olsen’s book managed to distinguish itself as a highly valuable resource for readers who wanted to better [...]
No related posts.]]></description>
			<content:encoded><![CDATA[<p>In 2007 Russ Olsen published <a href="/recommends/?0321490452">Design Patterns in Ruby</a> (<a href="/recommends/?0321490452">US</a> | <a href="http://www.amazon.co.uk/gp/product/0321490452?ie=UTF8&#038;tag=zenruby-21&#038;linkCode=as2&#038;camp=1634&#038;creative=6738&#038;creativeASIN=0321490452">UK</a> | <a href="http://www.amazon.ca/gp/product/0321490452?ie=UTF8&#038;tag=zenrubyca-20&#038;linkCode=as2&#038;camp=15121&#038;creative=330641&#038;creativeASIN=0321490452">CA</a>). Right around that time there were several other Ruby books hitting the shelves (as Rails was really reaching the peak of its popularity), however Olsen’s book managed to distinguish itself as a highly valuable resource for readers who wanted to better understand how to apply design patterns to Ruby programming (in an organic rather than dogmatic manner.)</p>
<p>Those who read the <a href="/recommends/?0201633612">Gang of Four</a> (<a href="/recommends/?0201633612">US</a> | <a href="http://www.amazon.co.uk/gp/product/0201633612?ie=UTF8&#038;tag=zenruby-21&#038;linkCode=as2&#038;camp=1634&#038;creative=6738&#038;creativeASIN=0201633612">UK</a> | <a href="http://www.amazon.ca/gp/product/0201633612?ie=UTF8&#038;tag=zenrubyca-20&#038;linkCode=as2&#038;camp=15121&#038;creative=330641&#038;creativeASIN=0201633612">CA</a>) several years before, may have expected a highly technical reference book with examples translated from C++ to Ruby (whenever patterns applied to Ruby as well). And in theory Olsen’s book was very much like that, as it was a list of 14 design patterns extracted from the Gang of Four and applied to Ruby.</p>
<p>In practice though, Design Patterns in Ruby really wasn’t anything like Design Patterns: Elements of Reusable Object-Oriented Software. To start with, it wasn’t much of a reference. It was more akin to a cookbook of recipes that related to the idiomatic use of Ruby patterns.</p>
<p>Upon starting that book, readers may have expected a cold, dry, tough-to-fully grasp treatment of the topic at hand. Instead they were greeted with a tone that was friendly and entertaining; you could read and absorb the whole thing in a matter of days. While some people may have thought this book was aimed only at Ruby experts, it turned out to be incredibly accessible to, and suitable for, Ruby beginners as well.</p>
<p><a href="/recommends/?0321584104">Eloquent Ruby</a> (<a href="/recommends/?0321584104">USA</a> | <a href="http://www.amazon.co.uk/gp/product/0321584104?ie=UTF8&#038;tag=zenruby-21&#038;linkCode=as2&#038;camp=1634&#038;creative=6738&#038;creativeASIN=0321584104">UK</a> | <a href="http://www.amazon.ca/gp/product/0321584104?ie=UTF8&#038;tag=zenrubyca-20&#038;linkCode=as2&#038;camp=15121&#038;creative=330641&#038;creativeASIN=0321584104">CA</a>), Olsen’s newest book, doesn’t veer much from the same description. This time the focus is not on specific design patterns, but rather on the style and essence of Ruby as a whole.</p>
<div align="center"><a href="/recommends/?0321584104"><img class="r_product_image" style="border:0px !important;" src="http://programmingzen.com/wp-content/uploads/2011/03/eloquent-ruby1.jpg"></a></div>
<p>In the three plus years that separate Olsen’s two books, we’ve witnessed the language and its community mature as we’ve moved away from Ruby 1.8, and we’ve seen plenty of new tools and idioms emerge. Eloquent Ruby tries to capture the essence of writing beautiful Ruby code in this modern idiomatic manner, by focusing on Ruby 1.9 (while providing footnotes for those who are still using 1.8).</p>
<p>There is a certain “Ruby way” of approaching problems and elements of style that reveals if a developer is an experienced Ruby programmer or not. This book will no doubt help you better understand not only the “how” but also the “why” of this distinctive Ruby way.</p>
<p>The 31 short chapters in Eloquent Ruby are logically organized and easy to follow, but can be read independently from one another, too. By focusing on practical examples, these chapters cover everything from basic style considerations to object oriented design, and delve into such topics as testing, metaprogramming, DSL, packaging and deploying gems, different Ruby implementations available, and monkey patching considerations.</p>
<p>This useful book assumes that its readers have a basic knowledge of Ruby, yet aren’t complete and total experts yet (and indeed such experienced Ruby users may not pick up too much new information from this book). For those who consider themselves to be novice to moderately well versed Ruby programmers, this book is a delightful read that’s likely to help you further your Ruby skill set considerably. </p>
<p>I would classify Eloquent Ruby as a “second Ruby book”, to be read after you’ve worked your way through a canonical introduction. Yet, if you’re a bright developer who’s coming from a different language, you may consider jumping right into it as your first Ruby book. </p>
<p>This great title is called “Eloquent Ruby”, but I feel it could just as easily have been called Idiomatic Ruby, Elegant Ruby, or Beautiful Ruby &#8211; as all of those descriptions fit it to a tee, too.</p>
<p><strong>Book giveaway</strong>: I will randomly draw one person from among those who share (retweet) this review on Twitter, and personally ship that person a free copy of <a href="/recommends/?0321584104">Eloquent Ruby</a>. All you have to do to be entered in this giveaway is to <a href="http://twitter.com/share/?text=Eloquent Ruby Review. Retweet for a chance to win a copy:&#038;url=http://programmingzen.com/2011/03/07/eloquent-ruby-review/&#038;via=acangiano">tweet about this post</a>. I will announce the winner tomorrow morning on <a href="http://twitter.com/acangiano">my twitter account</a> and in the comments below.</p>
<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://programmingzen.com/2011/03/07/eloquent-ruby-review/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>The recommended Ruby and Rails book pages have been updated</title>
		<link>http://programmingzen.com/2010/12/20/the-recommended-ruby-and-rails-book-pages-have-been-updated/</link>
		<comments>http://programmingzen.com/2010/12/20/the-recommended-ruby-and-rails-book-pages-have-been-updated/#comments</comments>
		<pubDate>Mon, 20 Dec 2010 21:00:39 +0000</pubDate>
		<dc:creator>Antonio Cangiano</dc:creator>
				<category><![CDATA[Books]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://programmingzen.com/?p=1277</guid>
		<description><![CDATA[During the holiday lull I managed to finally update the Ruby and Rails book pages. The Ruby page includes a few new titles and sees a few existing ones get the axe, as I took the major emphasis on Ruby 1.9 into consideration when updating this list of books. The Rails page is a complete [...]
No related posts.]]></description>
			<content:encoded><![CDATA[<p>During the holiday lull I managed to finally update the <a href="http://programmingzen.com/ruby-and-rails-recommended-books/">Ruby</a> and <a href="http://programmingzen.com/rails-books/">Rails book pages</a>. The <a href="http://programmingzen.com/ruby-and-rails-recommended-books/">Ruby page</a> includes a few new titles and sees a few existing ones get the axe, as I took the major emphasis on Ruby 1.9 into consideration when updating this list of books.</p>
<p>The <a href="http://programmingzen.com/rails-books/">Rails page</a> is a complete rewrite as I&#8217;ve removed any trace of Rails 2 books. I outlined a useful path of Rails books to follow based on the few available titles that are up-to-date with the latest version of the framework.</p>
<p>It&#8217;s likely that more books on the subject will come out in the next few  months and as they do, I will update the list accordingly. That said, the existing Rails 3 books (or those that are just about to be released) are very valid, useful ones.</p>
<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://programmingzen.com/2010/12/20/the-recommended-ruby-and-rails-book-pages-have-been-updated/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>StreamSend is looking for a senior (Rails) web developer</title>
		<link>http://programmingzen.com/2010/09/24/streamsend-is-looking-for-a-senior-rails-web-developer/</link>
		<comments>http://programmingzen.com/2010/09/24/streamsend-is-looking-for-a-senior-rails-web-developer/#comments</comments>
		<pubDate>Fri, 24 Sep 2010 21:26:43 +0000</pubDate>
		<dc:creator>Antonio Cangiano</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://programmingzen.com/?p=1254</guid>
		<description><![CDATA[This is just a quick heads up for my US readers. Given the tough economy we&#8217;re all battling, I thought you might be interested in learning about a great employment opportunity. My friends at StreamSend are looking for a senior web developer (preferably one with Rails experience, however they don&#8217;t discriminate as long as you [...]
No related posts.]]></description>
			<content:encoded><![CDATA[<p>This is just a quick heads up for my US readers. Given the tough economy we&#8217;re all battling, I thought you might be interested in learning about a great employment opportunity. My friends at <a href="http://www.streamsend.com/">StreamSend</a> are looking for a senior web developer (preferably one with Rails experience, however they don&#8217;t discriminate as long as you can learn quickly and have enough web development expertise to satisfy their requirements).</p>
<p>Based in San Francisco and Sacramento, StreamSend is made up of a group of really cool guys who &#8220;get&#8221; both Agile development and how to treat their employees. If you are looking for a great (and well paid) job in an economically stable (they&#8217;ve been around since 1998) and rapidly growing company, <a href="http://streamsend.jobscore.com/jobs/streamsend/senior-web-application-engineer/abCxF0-zCr3O4deJe4aGWH">apply here</a>.</p>
<p>If you follow this blog regularly you know that I normally don&#8217;t post job ads, but I can personally vouch for this position.</p>
<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://programmingzen.com/2010/09/24/streamsend-is-looking-for-a-senior-rails-web-developer/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>The Great Ruby Shootout (July 2010)</title>
		<link>http://programmingzen.com/2010/07/19/the-great-ruby-shootout-july-2010/</link>
		<comments>http://programmingzen.com/2010/07/19/the-great-ruby-shootout-july-2010/#comments</comments>
		<pubDate>Mon, 19 Jul 2010 18:12:31 +0000</pubDate>
		<dc:creator>Antonio Cangiano</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Ruby Benchmark Suite]]></category>

		<guid isPermaLink="false">http://programmingzen.com/?p=1233</guid>
		<description><![CDATA[The Great Ruby Shootout measures the performance of several Ruby implementations by testing them against a series of synthetic benchmarks. Recently I ran Mac and Windows shootouts as well, which tested a handful of implementations. However this article reports on the results of extensive benchmark testing of eight different Ruby implementations on Linux. The setup [...]
No related posts.]]></description>
			<content:encoded><![CDATA[<p>The Great Ruby Shootout measures the performance of several Ruby implementations by testing them against a series of synthetic benchmarks. Recently I ran <a href="http://programmingzen.com/2010/05/16/benchmarking-macruby-0-6/">Mac</a> and <a href="http://programmingzen.com/2010/06/28/the-great-ruby-shootout-windows-edition/">Windows</a> shootouts as well, which tested a handful of implementations. However this article reports on the results of extensive benchmark testing of eight different Ruby implementations on Linux.</p>
<p><strong>The setup</strong></p>
<p>For this shootout I included a subset of the <a href="http://github.com/acangiano/ruby-benchmark-suite">Ruby Benchmark Suite</a>. I opted to primarily exclude tests that were executed in fractions of a second in most VMs, focusing instead of more substantial benchmarks (several of which came from the <a href="http://shootout.alioth.debian.org/">Computer Language Benchmarks Game</a>). The best times and least memory allocations out of five runs are reported here for each benchmark.</p>
<p>All tests were run on Ubuntu 10.4 LTS x86_64, on an Intel Core 2 Quad Q6600 2.40 GHz, 8 GB DDR2 RAM, with two 500 GB 7200 rpm disks.</p>
<p><strong>8 implementations</strong></p>
<p>The implementations tested were:</p>
<ul>
<li>Ruby 1.8.7 p299</li>
<li>Ruby 1.9.1 p378</li>
<li>Ruby 1.9.2 RC2</li>
<li>IronRuby 1.0 (Mono 2.4.4)</li>
<li>JRuby 1.5.1 (Java HotSpot(TM) 64-Bit Server VM 1.6.0_20)</li>
<li>MagLev (rev 23832)</li>
<li>Ruby Enterprise Edition 2010.02</li>
<li>Rubinius 1.0.1</li>
</ul>
<p>JRuby was run with the &#8211;fast and &#8211;server optimization flags.</p>
<p><strong>Disclaimer</strong></p>
<p>Synthetic benchmarks cannot predict how fast your programs will be when dealing with a particular implementation. They provide an (entertaining) educated guess, but you shouldn’t draw overly definitive conclusions from them. The values reported here should be assumed to be characteristic of server-side &mdash; and long running &mdash; processes; they should be taken with a grain of salt.</p>
<p><strong>Time Results</strong></p>
<p>Please find below the execution times for the selected tests. Timeouts indicate that the execution of a single iteration for a given test took more than 300 seconds and had to be interrupted. Bold, green values indicate the best performer out of each test.</p>
<p><em>Warning: The bm_primes.rb benchmark was originally written to aid the development of the Prime class. As such in 1.9.2 it was rewritten in C, which makes it a poor representation of implementation performance. This benchmark will removed in the future.</em> </p>
<p align="center"><img src="http://programmingzen.com/wp-content/uploads/2010/07/linux-time-table1.png" alt="Time Table on Linux" /></p>
<p>If you are not interested in the individual test results, the information presented in the table above is summarized directly below:</p>
<pre class="highlight">
  Ruby 1.9.2         JRuby
Min.   : 0.013   Min.   : 0.382
1st Qu.: 3.258   1st Qu.: 3.051
Median : 4.543   Median : 4.997
Mean   : 9.262   Mean   : 9.180
3rd Qu.: 8.573   3rd Qu.: 8.969
Max.   :45.009   Max.   :48.850

    MagLev         Ruby 1.9.1
Min.   : 0.351   Min.   : 0.015
1st Qu.: 2.140   1st Qu.: 3.387
Median : 6.069   Median : 6.205
Mean   : 9.100   Mean   :10.860
3rd Qu.: 9.266   3rd Qu.:11.559
Max.   :51.221   Max.   :46.849

 Ruby 1.8.7         IronRuby
Min.   : 0.708   Min.   :  3.601
1st Qu.: 5.102   1st Qu.: 10.505
Median : 8.380   Median : 12.912
Mean   :18.785   Mean   : 26.539
3rd Qu.:24.793   3rd Qu.: 36.115
Max.   :75.653   Max.   :135.204

   Rubinius           REE
Min.   : 0.484   Min.   : 0.584
1st Qu.: 3.087   1st Qu.: 4.343
Median : 9.636   Median : 6.660
Mean   :13.232   Mean   :15.036
3rd Qu.:17.674   3rd Qu.:21.336
Max.   :73.050   Max.   :61.960
</pre>
<p>For the sake of convenience, I also produced a box plot from the successful data points:</p>
<p align="center"><img src="http://programmingzen.com/wp-content/uploads/2010/07/linux-time-plot.png" alt="Box plot of times"/></p>
<p>There are a few considerations based on these results that I feel are worth mentioning:</p>
<ul>
<li>As you can see Ruby 1.9, JRuby and MagLev converge towards a similar performance level according to these tests.</li>
<li>Ruby 1.9.2 manages to squeeze in a bit of extra speed when compared to Ruby 1.9.1 (which is a welcome improvement).</li>
<li>Ruby 1.9 seems to be either much faster than Ruby 1.8 or roughly as fast, depending on the test. This appears to be in line with what I&#8217;ve seen in real world programs. There are programs that will only receive a 10-20% boost from 1.9, while others improve drastically. The results really depends on what a program spends its time doing.</li>
<li>Performance wise, Rubinius is really starting to be a much more serious contender.</li>
<li>Ruby Enterprise Edition is slightly faster than Ruby 1.8.7, to the extent where this is clearly visible in almost all of the tests.</li>
<li>IronRuby running on Mono was the worse of the lot.</li>
</ul>
<p><strong>Memory Results</strong></p>
<p>The following table shows the approximate memory consumption for each implementation when running each benchmark:</p>
<p align="center"><img src="http://programmingzen.com/wp-content/uploads/2010/07/linux-memory-table.png" alt="Memory allocation on Linux" /></p>
<p>Summarized:</p>
<pre class="highlight">
  Ruby 1.9.2        Ruby 1.9.1
Min.   :  4.320   Min.   :  4.580
1st Qu.:  4.378   1st Qu.:  4.695
Median :  6.285   Median :  6.920
Mean   : 20.795   Mean   : 15.669
3rd Qu.: 10.162   3rd Qu.: 11.383
Max.   :171.500   Max.   :100.570

   Ruby 1.8            REE
Min.   :  3.040   Min.   :  8.220
1st Qu.:  4.290   1st Qu.:  9.682
Median :  7.745   Median : 15.565
Mean   : 20.698   Mean   : 27.014
3rd Qu.: 11.273   3rd Qu.: 38.620
Max.   :103.520   Max.   :125.910

  Rubinius           MagLev
Min.   : 37.63   Min.   : 81.74
1st Qu.: 39.78   1st Qu.: 82.52
Median : 45.48   Median : 83.53
Mean   : 65.70   Mean   : 96.29
3rd Qu.: 58.22   3rd Qu.: 98.10
Max.   :215.33   Max.   :175.85   

    JRuby
Min.   : 49.04
1st Qu.: 71.23
Median :176.72
Mean   :169.41
3rd Qu.:209.04
Max.   :404.06
</pre>
<p>And finally, in graph form:</p>
<p align="center"><img src="http://programmingzen.com/wp-content/uploads/2010/07/linux-memory-plot1.png" alt="Memory Box Plot" /></p>
<p>A few considerations on memory:</p>
<ul>
<li>Memory readings for IronRuby were not available, so they were not included.</li>
<li>Ruby 1.9.2 uses the least amount of memory (as one might expect).</li>
<li>JRuby was by far the most memory intensive of the group.</li>
<li>Ruby Enterprise Edition used less memory than 1.8.7 in a few tests, but overall was more memory hungry than 1.8.7. This is really odd and entirely unexpected.</li>
</ul>
<p><strong>Linux Vs. Windows</strong></p>
<p>This shootout and the Windows one were both performed on the same machine, thus we can compare how the same implementation perform under different operating systems. The only adjustment that’s required is the timeout. Every result longer than 60 seconds from this shootout needs to be considered a timeout, because the previous shootout did so as well.</p>
<p>It is commonly believed that Ruby performs much better on Linux than on Windows (with the exception of IronRuby). Let&#8217;s find out if these test results confirm that notion.</p>
<p>Ruby 1.8.7:</p>
<p align="center"><img src="http://programmingzen.com/wp-content/uploads/2010/07/lin-win-187-table.png" alt="Ruby 1.8.7 on Linux and Windows" /></p>
<p>Ruby 1.9.2:</p>
<p align="center"><img src="http://programmingzen.com/wp-content/uploads/2010/07/lin-win-192-table.png" alt="Ruby 1.9.2 on Linux and Windows" /></p>
<p>JRuby:</p>
<p align="center"><img src="http://programmingzen.com/wp-content/uploads/2010/07/lin-win-jruby-table.png" alt="JRuby on Linux and Windows" /></p>
<p>Finally, in chart form (yellow entries are on Windows as indicated by the labels containing W):</p>
<p align="center"><img src="http://programmingzen.com/wp-content/uploads/2010/07/lin-win-plot.png" alt="Ruby on Linux Vs. Windows" /></p>
<p>To use a beloved MythBusters expression, this myth is confirmed.</p>
<p><strong>Note</strong>: As requested by a few commenters, here is a comparison of IronRuby as well (.NET 4.0 Vs. Mono 2.4.4):</p>
<p align="center"><img src="http://programmingzen.com/wp-content/uploads/2010/07/lin-win-ir-table.png" alt="Ruby 1.8.7 on Linux and Windows" /></p>
<p><strong>Conclusion</strong></p>
<p>In conclusion, let me just state that it’s nice to see several implementations getting faster. Ruby 1.9.2, JRuby, MagLev and Rubinius are all becoming serious competitors and working their respective ways closer to a similar performance level. If you think these benchmark shootouts are becoming boring, then the results are becoming more stable and predictable. I suspect that as time goes on, performance will not be the real distinguishing factor when choosing a Ruby implementation, other features will be.</p>
<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://programmingzen.com/2010/07/19/the-great-ruby-shootout-july-2010/feed/</wfw:commentRss>
		<slash:comments>32</slash:comments>
		</item>
	</channel>
</rss>

