<?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>Talk Like A Duck</title>
    <link>http://talklikeaduck.denhaven2.com</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>In Ruby, it's not the dog, it's the tricks!</description>
    <item>
      <title>O Canada!</title>
      <description>I&amp;#8217;ve got quite a few Canadian friends, only partly due to my being an &lt;a href="http://en.wikipedia.org/wiki/Object_Technology_International"&gt;&lt;span class="caps"&gt;OTI&lt;/span&gt; alumnus&lt;/a&gt;. So it seems appropriate, albeit completely off-topic, to wish them all a happy &lt;a href="http://en.wikipedia.org/wiki/Canada_Day"&gt;F&#234;te du Canada&lt;/a&gt;, and a Canada Day Joyeux!
&lt;p&gt;I&amp;#8217;m a little surprised that neither the &lt;a href="http://www.google.com"&gt;American&lt;/a&gt; nor the &lt;a href="http://www.google.ca"&gt;Canadian&lt;/a&gt; google sites seem to have acknowledged today&amp;#8217;s date at least as of this writing.&lt;/p&gt;</description>
      <pubDate>Tue, 01 Jul 2008 07:13:00 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:fa898b00-f257-48f5-b55f-4713ce75a921</guid>
      <author>Rick DeNatale</author>
      <link>http://talklikeaduck.denhaven2.com/articles/2008/07/01/o-canada</link>
      <trackback:ping>http://talklikeaduck.denhaven2.com/articles/trackback/505</trackback:ping>
    </item>
    <item>
      <title>Lord Love a Duck!</title>
      <description>From &lt;a href="http://frogsmoke.com/2008/06/21/w-extra-duck/"&gt;one of the many non-Ruby blogs I follow&lt;/a&gt; comes &lt;a href="http://www.flickr.com/photos/misty69/sets/72157603743580096/"&gt;this collection of strange duck-types.&lt;/a&gt;
&lt;p&gt;A bit off the beaten track for this blog, but, &amp;#8220;if it quacks&amp;#8230;!&amp;#8221;&lt;/p&gt;</description>
      <pubDate>Sat, 21 Jun 2008 08:08:00 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:3781a442-c9fc-4ecb-a2fd-913bb485fa32</guid>
      <author>Rick DeNatale</author>
      <link>http://talklikeaduck.denhaven2.com/articles/2008/06/21/lord-love-a-duck</link>
      <category>humor</category>
      <trackback:ping>http://talklikeaduck.denhaven2.com/articles/trackback/504</trackback:ping>
    </item>
    <item>
      <title>Speaking Tomorrow at Raleigh Ruby Brigade</title>
      <description>&lt;p&gt;I&amp;#8217;ll be giving a talk on &amp;#8220;The Fall and Rise of Dynamic Languages&amp;#8221; 
&lt;a href="http://ruby.meetup.com/3/calendar/7849490/?a=nr1p_grp"&gt;tomorrow at 7:00 p.m., at Red Hat HQ to the Raleigh Ruby Brigade.&lt;/a&gt;
&lt;p&gt;Originally this was going to be a slightly revamped talk I gave some months ago to the local Agile group, with a slight change of emphasis from the history of agile methods to focus more on Ruby and other dynamic languages.  It&amp;#8217;s morphed into a  completely different talk.&lt;/p&gt;
&lt;p&gt;I plan to take a journey from the 1970s to today, and compare and contrast static and dynamic languages, and examine the recent resurgence in interest in dynamic languages and virtual machines.  Along the way, I&amp;#8217;ll have a few things to say about whether or not the recent news from RailsConf about MagLev is hype or reality.&lt;/p&gt;
&lt;p&gt;If you&amp;#8217;re in the area, please come by.  Luckily the salmonella scare will probably keep the supply of (rotten) tomatoes to a minimum, so I should be fairly safe.&lt;/p&gt;&lt;/p&gt;</description>
      <pubDate>Mon, 16 Jun 2008 15:16:00 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:da0fd57b-ad59-4688-921d-cbe802890a48</guid>
      <author>Rick DeNatale</author>
      <link>http://talklikeaduck.denhaven2.com/articles/2008/06/16/speaking-tomorrow-at-raleigh-ruby-brigade</link>
      <category>site_news</category>
      <category>ruby</category>
      <category>smalltalk</category>
      <category>javascript</category>
      <category>talks</category>
      <trackback:ping>http://talklikeaduck.denhaven2.com/articles/trackback/503</trackback:ping>
    </item>
    <item>
      <title>How Did You Get Started in Programming</title>
      <description>&lt;p&gt;Joe O&amp;#8217;Brien wrote an article about &lt;a href="http://objo.com/2008/6/7/how-did-you-get-started-in-programming"&gt;How he got started in programming.&lt;/a&gt;According to Joe, this is a meme started by &lt;a href="http://michaeleatonconsulting.com/blog/"&gt;Michael Eaton,&lt;/a&gt; and &lt;a href="http://www.codinggeekette.com/2008/06/sarahs-steps-into-software-development.aspx"&gt;Sarah Dutkiewicz.&lt;/a&gt; It seemed like fun, so here&amp;#8217;s my story, in the same form used by Michael and Sarah.&lt;/p&gt;
&lt;h2&gt;How old were you when you started programming?&lt;/h2&gt;
&lt;p&gt;I would have been 18 or 19.  It was my freshman year in college (1970/71), but I can&amp;#8217;t recall whether it was first or second semester, and my birthday is in December.&lt;/p&gt;
&lt;h2&gt;How did you get started in programming?&lt;/h2&gt;
&lt;p&gt;Let me go back just a little bit. When I was in high school, I was very interested in music.  I&amp;#8217;d played in various rock and blues bands since junior high.  My high school in Connecticut was part of a program which taught electronic music.  This was a time when synthesizers were just coming to the fore.  Walter (now Wendy) Carlos&amp;#8217; album &amp;#8220;Switched on Bach&amp;#8221; had come out in 1968 when I was a high-school sophomore.&lt;/p&gt;
&lt;p&gt;So I started at the University of Connecticut in the fall of 1970 and enrolled in the Electrical Engineering School, with the sole intention of becoming the next Robert Moog.  All I really wanted to learn was how to design voltage-controlled oscilators and amplifiers.&lt;/p&gt;
&lt;p&gt;One of the courses which all freshman engineers at UConn had to take was a 100 level CE course which consisted of one-half semester of &amp;#8220;Engineering Graphics&amp;#8221; i.e drafting on a board with a T-Square, Triangles and French-curves, and one-half semester of Fortran I programming on an &lt;span class="caps"&gt;IBM 1620&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;That course got me hooked on programming, and my musical career ended in a hurry.&lt;/p&gt;
&lt;h2&gt;What was your first language?&lt;/h2&gt;
&lt;p&gt;As I mentioned it was Fortran I, but I quickly became one of those guys who wanted to dabble with every programming language I could get my hands on.&lt;/p&gt;
&lt;h2&gt;What was the first real program you wrote?&lt;/h2&gt;
&lt;p&gt;It&amp;#8217;s been so long that I can&amp;#8217;t really remember.  One of the things I remember from school was writing a compiler as a class project.  I also remember a computer architecture (hardware) course, taught by grad student with a recent math MS, who I baffled by designing a computer for the term project which had a very simple hardware design, because it was micro-programmed so the main part of the design was actually firmware.  The poor guy didn&amp;#8217;t really know what to make of it.&lt;/p&gt;
&lt;h2&gt;What languages have you used since you started programming?&lt;/h2&gt;
&lt;p&gt;This is probably not a complete list but:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;PL/I&lt;/li&gt;&lt;li&gt;Snobol&lt;/li&gt;&lt;li&gt;Lisp 1.5&lt;/li&gt;&lt;li&gt;Formac&lt;/li&gt;&lt;li&gt;1620 Assembler Language&lt;/li&gt;&lt;li&gt;&lt;span class="caps"&gt;PDP 8&lt;/span&gt;/5 Assembler Language&lt;/li&gt;&lt;li&gt;&lt;span class="caps"&gt;IBM&lt;/span&gt; System/360/370 Assembler Language&lt;/li&gt;&lt;li&gt;&lt;span class="caps"&gt;APL&lt;/span&gt;&lt;/li&gt;&lt;li&gt;PL/S &amp;#8211; an &lt;span class="caps"&gt;IBM&lt;/span&gt; internal mid-level language akin to C but with a PL/I like syntax, and a later variant PL/AS&lt;/li&gt;&lt;li&gt;Basic &amp;#8211; on the &lt;span class="caps"&gt;APPLE&lt;/span&gt; ][&lt;/li&gt;&lt;li&gt;&lt;span class="caps"&gt;UCSD&lt;/span&gt; Pascal&lt;/li&gt;&lt;li&gt;C&lt;/li&gt;&lt;li&gt;Class-C, an object oriented C variant similar to Objective-C which I invented for use within &lt;span class="caps"&gt;IBM&lt;/span&gt;&lt;/li&gt;&lt;li&gt;Object Pascal (using MacApp)&lt;/li&gt;&lt;li&gt;C++ (as little as possible)&lt;/li&gt;&lt;li&gt;Smalltalk &amp;#8211; my first real love&lt;/li&gt;&lt;li&gt;Java &amp;#8211; mostly because I had no choice&lt;/li&gt;&lt;li&gt;Ruby &amp;#8211; my current love&lt;/li&gt;&lt;li&gt;JavaScript &amp;#8211; which I&amp;#8217;ve decided is my language of the year for 2008.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;If you knew then what you know now, would you have started programming?&lt;/h2&gt;
&lt;p&gt;Only because I can&amp;#8217;t figure out how to become a real Rock Star.&lt;/p&gt;
&lt;h2&gt;If there is one thing you learned along the way that you would tell new developers, what would it be?&lt;/h2&gt;
&lt;p&gt;Try to get a broad a picture as possible of programming, try to use your knowledge of other languages enhance your learning of new ones instead of inhibiting yourself by misunderstanding how the languages differ from the ones you&amp;#8217;ve already used,&lt;/p&gt;
&lt;h2&gt;What&amp;#8217;s the most fun you&amp;#8217;ve ever had &amp;#8230; programming?&lt;/h2&gt;
&lt;p&gt;The most enjoyable aspects of programming are the social ones.  I was doing pair programming before anyone had coined the term.  I remember sessions where two or three guys were working on something, one working the keyboard, one the mouse, and maybe a third kibitzing.  Beyond that it&amp;#8217;s great to hang out with other programmers whether at local groups or at a conference like &lt;span class="caps"&gt;OOPSLA&lt;/span&gt; or RubyConf and talk about the craft of programming, maybe over a beer or two.&lt;/p&gt;</description>
      <pubDate>Sat, 07 Jun 2008 23:14:00 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:3bc15a36-f91e-4fa5-b630-6fb171d7f249</guid>
      <author>Rick DeNatale</author>
      <link>http://talklikeaduck.denhaven2.com/articles/2008/06/07/how-did-you-get-started-in-programming</link>
      <category>war_stories</category>
      <trackback:ping>http://talklikeaduck.denhaven2.com/articles/trackback/502</trackback:ping>
    </item>
    <item>
      <title>Solving the Final Google Treasure Hunt Problem in Ruby</title>
      <description>For the past four weeks, Google has been running the &lt;a href="http://treasurehunt.appspot.com/"&gt;2008 Google Treasure Hunt&lt;/a&gt;. Each Monday a new question
was asked, requiring a &amp;#8216;simple&amp;#8217; answer.  Actually, each question was parameterized, and the parameters were &amp;#8216;randomly&amp;#8217; generated for each participant.
&lt;p&gt;For each of the four questions, I wrote a Ruby program to find the answer.&lt;/p&gt;
&lt;p&gt;The final question was probably the hardest, and although it&amp;#8217;s still &amp;#8216;alive&amp;#8217;, the spoilers have already started to appear on the internets. &lt;a href="http://www.catonmat.net/blog/solving-google-treasure-hunt-prime-number-problem-four/"&gt;Peter Krumins has posted a solution using unix shell commands,&lt;/a&gt; so I figured I&amp;#8217;d show my Ruby solution&lt;/p&gt;
&lt;h2&gt;The Problem&lt;/h2&gt;
&lt;p&gt;As Peter describes the problem is to find the smallest prime number which can be expressed as a sum of several different numbers of consecutive primes. Here&amp;#8217;s the question as Google posed it to me:&lt;/p&gt;
&lt;quote&gt;Find the smallest number that can be expressed as
&lt;p&gt;the sum of 3 consecutive prime numbers,&lt;/p&gt;
&lt;p&gt;the sum of 5 consecutive prime numbers,&lt;/p&gt;
&lt;p&gt;the sum of 275 consecutive prime numbers,&lt;/p&gt;
&lt;p&gt;the sum of 1167 consecutive prime numbers,&lt;/p&gt;
&lt;p&gt;and is itself a prime number.&lt;/p&gt;
&lt;p&gt;
For example, 41 is the smallest prime number that can be expressed as
the sum of 3 consecutive primes (11 + 13 + 17 = 41) and
the sum of 6 consecutive primes (2 + 3 + 5 + 7 + 11 + 13 = 41).&lt;/p&gt;&lt;/quote&gt;
&lt;p&gt;Note that I&amp;#8217;ve got a different set of four numbers of consecutive primes than Peter&amp;#8217;s&lt;/p&gt;
&lt;h2&gt;The Approach&lt;/h2&gt;
&lt;p&gt;I always try to do &amp;#8216;the simplest thing that could possibly work.&amp;#8217;  Like Peter I had no desire to write a prime number generator.  A little googling found me the same source of prime numbers.  I figured as a first guess that the answer would probably lie somewhere within the first million prime numbers, so I downloaded &lt;a href="http://primes.utm.edu/lists/small/millions/primes1.zip"&gt;that list,&lt;/a&gt; and examined the list in Textmate.&lt;/p&gt;
&lt;p&gt;As Peter notes, the file has two lines of header, and then several primes in sequence on each line.  I just deleted the header lines in Textmate and then wrote a class which would read the file and return each prime number in sequence:&lt;/p&gt;
&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;class PrimeReader
  def initialize(file)
    @file = file
    read_line
    yield self
  end

  def next
    read_line if @numbers.empty?
    @numbers.shift.to_i
  end

  def read_line
    @numbers = @file.readline.split(' ')
  end
end&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This should be fairly explanatory. PrimeReader reads the file as necessary and hands out each prime number.&lt;/p&gt;
&lt;p&gt;Now that I had a source of consecutive primes it was time to write the code to search for the answer.  Here&amp;#8217;s the outer loop:&lt;/p&gt;
&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_ruby "&gt;&lt;span class="ident"&gt;processor&lt;/span&gt; &lt;span class="punct"&gt;=&lt;/span&gt; &lt;span class="constant"&gt;Processor&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;new&lt;/span&gt;

&lt;span class="constant"&gt;File&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;open&lt;/span&gt;&lt;span class="punct"&gt;(&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;&lt;span class="expr"&gt;#{File.dirname(__FILE__)}&lt;/span&gt;/primes1.txt&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;)&lt;/span&gt; &lt;span class="keyword"&gt;do&lt;/span&gt; &lt;span class="punct"&gt;|&lt;/span&gt;&lt;span class="ident"&gt;f&lt;/span&gt;&lt;span class="punct"&gt;|&lt;/span&gt;
  &lt;span class="constant"&gt;PrimeReader&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;new&lt;/span&gt;&lt;span class="punct"&gt;(&lt;/span&gt;&lt;span class="ident"&gt;f&lt;/span&gt;&lt;span class="punct"&gt;)&lt;/span&gt; &lt;span class="keyword"&gt;do&lt;/span&gt; &lt;span class="punct"&gt;|&lt;/span&gt; &lt;span class="ident"&gt;primes&lt;/span&gt; &lt;span class="punct"&gt;|&lt;/span&gt;
    &lt;span class="keyword"&gt;until&lt;/span&gt; &lt;span class="ident"&gt;processor&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;test&lt;/span&gt;&lt;span class="punct"&gt;(&lt;/span&gt;&lt;span class="ident"&gt;primes&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;next&lt;/span&gt;&lt;span class="punct"&gt;)&lt;/span&gt;
    &lt;span class="keyword"&gt;end&lt;/span&gt;
  &lt;span class="keyword"&gt;end&lt;/span&gt;
&lt;span class="keyword"&gt;end&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The real work is done, in the unimaginatively named Processor.  
The loop reads lines from the PrimeReader until the processor finds the desired prime or end of file generates an exception.&lt;/p&gt;
&lt;p&gt;And here&amp;#8217;s the Processor class:&lt;/p&gt;
&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;class Processor
  def initialize
    @counts = [3, 5, 275, 1167].reverse
    # @counts = [3,6]
    @sums = @counts.inject({}) { |hash, count| hash[count] = []; hash}
    @processed = []
  end

  def test(prime)
    puts &amp;quot;testing #{1+@processed.length}: #{prime} &amp;quot;
    qualifies(prime) || process(prime)
  end

  def qualifies(prime)
    @sums.each_value do | sums |
      return false unless sums.include?(prime)
    end
    report(prime)
    true
  end

  def process(prime)
    @processed &amp;lt;&amp;lt; prime
    @counts.each do |count|
      calc_sum(count)
    end
    false
  end

  def calc_sum(count)
    if @processed.length &amp;gt;= count
      @sums[count] &amp;lt;&amp;lt; @processed[-count,count].inject(0) { |sum, p| sum + p}
    end
  end

  def report(found)
    puts &amp;quot;Found #{found}&amp;quot;
    @counts.each do | count|
      report_sum(count, found)
    end
  end

  def report_sum(count, found)
    sums = @sums[count]
    sum_start = sums.index(found)
    puts &amp;quot;#{found} = #{@processed[sum_start, count].join(&amp;quot; + &amp;quot;)}&amp;quot;
  end
end&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The approach I took was to compute the sums and save them in arrays which in turn are the values for each count used as a key in the hash @sums. I keep each prime in the array @processed which is used to calculate the sums.&lt;/p&gt;
&lt;p&gt;I hard coded the parameters in the initialize method, note the commented out assignment to counts, by changing the commenting I could test the code against the example given and show that my code found 41
as the lowest prime expressible by both 3 and 6 consecutive primes.&lt;/p&gt;
&lt;p&gt;The test method reports the number and value of each prime it examines, purely as a &amp;#8216;progress indicator.&amp;#8217; The statment &amp;#8220;qualifies(prime) || process(prime)&amp;#8221; will return true if qualifies returns a truthy value, otherwise it will invoke process which always returns false.&lt;/p&gt;
&lt;p&gt;The qualifies method returns true only if the array for each count contains the current prime, which is the essence of what we are seeking. Otherwise it returns false.&lt;/p&gt;
&lt;p&gt;The process method first appends the new prime to @processed, then calculates the sum for each count using the calc_sum method.  This method determines if we have enough primes in @processed to calculate the particular sum, and if so calculates the sum and appends it to the array for the count.&lt;/p&gt;
&lt;p&gt;Once the answer has been found, the report method prints it and the sums which total to it.  The sums are calculated in the report_sum method.  This method takes a slice out of the @processed array, consisting of the count elements starting at the index where the answer is found in the particular sums array. A bit of reflection will reveal that this is precisely the primes which add to the answer.&lt;/p&gt;
&lt;p&gt;In the case of my parameters, the answer, in case you are wondering is 5,181,901, which was confirmed by Google when I gave my answer. This is the 360,245th prime number by the way.&lt;/p&gt;
&lt;h2&gt;Performance&lt;/h2&gt;
&lt;p&gt;Although this might be a bit of a brute force approach, the performance was acceptable.&lt;/p&gt;
&lt;p&gt;The biggest feature of Ruby which makes this approach feasible is the copy-on-write nature of Ruby arrays.  In Ruby Array#slice (a.k.a. Array#[]) doesn&amp;#8217;t copy the elements of the array, it just creates a new Array with an offset from the beginning of the original array and the length of the result.  As long as neither Array is changed to affect one of the shared elements, nothing is copied, but when a shared element in the source or result array is changed, Ruby first does the copy to preserve the semantics.&lt;/p&gt;
&lt;p&gt;My code does a lot of slicing of the @processed array, but other than appending to the end of the @processed array, the accesses to that array and the slices are read-only, so nothing needs to be copied.&lt;/p&gt;</description>
      <pubDate>Sat, 07 Jun 2008 21:43:00 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:df213c29-f4d4-46f4-8a4a-a8e22fc115e4</guid>
      <author>Rick DeNatale</author>
      <link>http://talklikeaduck.denhaven2.com/articles/2008/06/07/solving-the-final-google-treasure-hunt-problem-in-ruby</link>
      <category>ruby</category>
      <trackback:ping>http://talklikeaduck.denhaven2.com/articles/trackback/501</trackback:ping>
    </item>
    <item>
      <title>What Would You Miss If You Had To Stop Using Ruby and Go Back to Smalltalk?</title>
      <description>&lt;p&gt;Last night, James Robertson from Cincom, &lt;a href="http://www.cincomsmalltalk.com/blog/blogView?showComments=true&amp;#38;printTitle=Seaside_with_the_Raleigh_Rubyists&amp;#38;entry=3388818661"&gt;presented Smalltalk and Seaside to the Raleigh Ruby Brigade.&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;It was an interesting deja-vu experience, since in my younger days, part of my job with &lt;span class="caps"&gt;IBM&lt;/span&gt; was evangelizing Smalltalk, much as James does today.  It was interesting to see what has and hasn&amp;#8217;t changed. For the most part the things about Smalltalk which were blessings and curses (or many times both) haven&amp;#8217;t changed.  The &lt;span class="caps"&gt;IDE&lt;/span&gt; is still powerful. It gets much of it&amp;#8217;s power from Smalltalk&amp;#8217;s model of how source code and run-time implementation objects like compiled-methods, classes and metaclasses interact, but the consequence is that there aren&amp;#8217;t really Smalltalk source files to use with popular editors like &lt;span class="caps"&gt;VIM&lt;/span&gt; or &lt;span class="caps"&gt;EMACS&lt;/span&gt; or Textmate.  The question came up about whether the Smalltalk &lt;span class="caps"&gt;IDE&lt;/span&gt; supported the notion of giving the code to an external editor, and the answer was that the size of a typical Smalltalk method, which is the unit of editing, was so small (10 lines is a long Smalltalk method) as to make it &amp;#8216;moot.&amp;#8217;  I used to get the same kind of questions and give pretty much the same answers.&lt;/p&gt;
&lt;p&gt;One area where Smalltalk really does excel is in it&amp;#8217;s debugging and inspection tools.  The same implementation object model which enables browser features, like finding all senders or implementers of a message using structural rather than textual searching, also allows live debugging, where you can not only inspect the run-time state at a breakpoint, or when an exception occurs, but actually make changes to the running code, and compile those changes, at which point the VM prunes the invocation stack down to the point of the change and allows you to restart from that point.  Protestations from &lt;span class="caps"&gt;TDD&lt;/span&gt;/BDD adherents that &lt;a href="http://talklikeaduck.denhaven2.com/articles/2007/10/18/true-confesssions"&gt;you don&amp;#8217;t need no steenking debugger&lt;/a&gt; if you follow &lt;span class="caps"&gt;TDD&lt;/span&gt; practice, the Smalltalk debugger was tool much favored by the very people, like Kent Beck, who invented &lt;span class="caps"&gt;TDD&lt;/span&gt;.  Many Rubyists who were around for more than a year or two had an anti-debugger attitude, generated more, I suspect, by the lack of a decent Ruby debugger than any real hatred of debuggers.&lt;/p&gt;
&lt;p&gt;Now that ruby-debug has been around for &lt;a href="http://datanoise.com/articles/2006/7/7/faster-debugger-for-ruby"&gt;almost two years&lt;/a&gt;, the situation is much better. Ruby has a fairly competent debugger which allows stepping through code.  It&amp;#8217;s still hampered by Ruby&amp;#8217;s rather simple run-time meta information, being forced to work on a line-by-line mode, rather than being able to step through individual expressions as can the Smalltalk debugger.  And we&amp;#8217;re still a long way from the live surgery capabilities I described. Perhaps as Ruby VM implementations mature we might see some of these advanced features emerge, perhaps this is something which the Rubinius implementers might also take as an inspiration from Smalltalk.  This is one of the main things I miss from my Smalltalk days.&lt;/p&gt;
&lt;p&gt;On the other hand, at this point in time, I&amp;#8217;m really much happier working in Ruby than  I think I would be were I somehow forced to work in Smalltalk again instead.  Much as I love it, Smalltalk is now my second favorite language.&lt;/p&gt;
&lt;p&gt;At one point last night, Brian Adkins asked me the question which is the title of this article.  I think it&amp;#8217;s a fair question, and I&amp;#8217;m not sure I know exactly, but let me try to answer it.&lt;/p&gt;
&lt;h2&gt;What I&amp;#8217;d miss from Ruby&lt;/h2&gt;
&lt;p&gt;I&amp;#8217;ve said this before, but one of the things I like about Ruby is that it is more dynamic than Smalltalk in ways which I like, and cuts back on other aspects of Smalltalk which I don&amp;#8217;t think are really that important.&lt;/p&gt;
&lt;p&gt;One of the things I like about Ruby is the &lt;a href="http://talklikeaduck.denhaven2.com/articles/2008/02/08/whose-variable-is-it-anyway"&gt;elimination of variable declarations.&lt;/a&gt; A good example of this was that during the Seaside demo last night, James showed how interfacing to the database requires attribute instance variables in model objects to be declared.  Now the &lt;span class="caps"&gt;IDE&lt;/span&gt; provides tools for helping with this, you get prompted with a list of column names and can add them one by one just by clicking buttons.  Contrast this with ActiveRecord where model objects just acquire instance variables dynamically at run-time.  Now I know that some prefer more explicit mappings, but personally I feel that the dynamic mapping provides much more capability for much less ceremony.&lt;/p&gt;
&lt;p&gt;The ways in which Ruby is more dynamic than Smalltalk seem to me to provide better facilities for building low-ceremony architectures and artifacts like Rails, Rake, etc.  There are more dynamic languages than Ruby to be sure, such as Self, and from what I can sense JavaScript, but Ruby seems to strike a very nice balance.&lt;/p&gt;
&lt;p&gt;Much has been made of the legacy of Smalltalk in pioneering metaprogramming, although some Lisp guys might quibble with that, and in truth, most Smalltalk metaprogramming was only used to support the &lt;span class="caps"&gt;IDE&lt;/span&gt; and never put to use by application programmers.  Alan Kay used to say that he was disappointed that no one seemed to make new classes of Behavior (which is the superclass of both Class and Metaclass in Smalltalk). I know he said this to some of us at an &lt;span class="caps"&gt;IBM&lt;/span&gt; internal conference, which at least led to Dave Smith and Jerry Archbald developing a &amp;#8220;behavior of behavior&amp;#8221; tutorial which ran for several years at &lt;span class="caps"&gt;OOPSLA&lt;/span&gt;.  But Rubyists have taken metaprogramming much further than I recall from my Smalltalk days.&lt;/p&gt;
&lt;p&gt;On the other end of the scale, Smalltalk as James pointed out, as I used to, has a very simple syntax, a few reserved words (self, super, nil, true, and false), three types of messages (unary, binary, and keyword),  two operators (:= for assignment, and &amp;#94; for return), and a few more things for defining block literals.&lt;/p&gt;
&lt;p&gt;Now when I was doing James&amp;#8217; job, this got mixed reactions. Some people took to syntax like:&lt;/p&gt;
&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_smalltalk "&gt;topLeft = Point x: 3+2*5 y: 15&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;While others found it just a little too strange, something which we Smalltalkers just couldn&amp;#8217;t get.&lt;/p&gt;
&lt;p&gt;Another thing which put off newcomers to Smalltalk was that, because of the simplicity of the language, and the lack of any form of operator precedence (remember the only operators are := and &amp;#94;), that subexpression 3+2*5 evaluates to 25 and not 13.&lt;/p&gt;
&lt;p&gt;Ruby trades off a little simplicity and does provide precedence between messages which seem like they should act as operators.&lt;/p&gt;
&lt;p&gt;I&amp;#8217;m not saying that Ruby is without quirks, just that different people react to different quirks in different ways.  If you don&amp;#8217;t like what you perceive to be the quirks of &lt;strong&gt;any&lt;/strong&gt; programming language, you won&amp;#8217;t be convinced, even by the most ardent supporter of those quirks.&lt;/p&gt;
&lt;p&gt;One of the interesting effects of the Smalltalk syntax was that, as we observed back in Smalltalk&amp;#8217;s heyday in the Enterprise (late &amp;#8216;80s-early &amp;#8216;90s), it seemed that a lot of &lt;span class="caps"&gt;COBOL&lt;/span&gt; programmers seemed to take to Smalltalk. We used to think that Smalltalk might actually become the 21st century &lt;span class="caps"&gt;COBOL&lt;/span&gt;, until the &amp;#8220;Enterprise&amp;#8221; got wooed away by EJBs and the like. The same things which made Smalltalk approachable by &lt;span class="caps"&gt;COBOL&lt;/span&gt; programmers made it seem weird to those who looked down on those &lt;span class="caps"&gt;COBOL&lt;/span&gt; programmers as &amp;#8220;trade-school&amp;#8221; programmers.&lt;/p&gt;
&lt;p&gt;Another much-touted feature of Smalltalk, is that everything is done by message sending, even control flow.  In Smalltalk a if/then/else control flow is achieved by sending an ifTrue:ifFalse: message to a boolean object as in:&lt;/p&gt;
&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_smalltalk "&gt; ^(x = 0) ifTrue:[a] ifFalse:[b]&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Smalltalk evaluates this as if the the expression (x = 0) is evaluated by sending the message with the selector = and argument 0, to the object referenced by x.  The result of that message, an object of course, is then sent the message with the selector ifTrue:ifFalse: and the arguments [a] and [b], which are two blocks.  What happens is up to that object.  Typically that object is either true (the sole instance of the class True) whose ifTrue:ifFalse: method evaluates the first argument, or false (the sole instance of the class False) whose ifTrue:ifFalse: method evaluates the second argument.  Very neat and conceptually clean.  It allows you to define your own control flow methods.&lt;/p&gt;
&lt;p&gt;Ruby on the other hand compiles if statements and their kind as tests and branches, much as a C compiler would.  We trade off a little flexibility for performance.&lt;/p&gt;
&lt;p&gt;But, in my experience, that flexibility rarely got used in Smalltalk.  Not only that but, in my day at least, the Smalltalk compilers would &lt;strong&gt;also&lt;/strong&gt; compile ifTrue:ifFalse: to a test of the result of the &amp;#8216;receiver&amp;#8217; and a branch.  In fact I just tried defining a FakeBoolean class with an ifTrue: method and when I try to use it I see this:&lt;/p&gt;
&lt;img src="http://talklikeaduck.denhaven2.com/files/2008-05-21_must_be_boolean.png" alt="must_be_boolean" height="326" width="326"&gt;
&lt;p&gt;That NonBooleanReceiver exception is like seeing the Wizard of Oz behind the curtain, this notion of no control flow, just messages is actually a bit of an illusion.&lt;/p&gt;
&lt;p&gt;Again, while Ruby doesn&amp;#8217;t even pretend to implement all control flow by messaging, it provides most of what the underlying Smalltalk mechanisms are really used for in the form of blocks used to implement iterators.&lt;/p&gt;
&lt;p&gt;There are other aspects of Smalltalk which are both blessings and curses.  The fact that Smalltalk has a persistent run-time image, containing all the development tools, which can be saved along with its state of execution, and restarted is quite powerful, alien to many programmers, and can drastically change your approach to deployment.  Back when I was doing Smalltalk we always struggled with issues like the footprint of the image, how to strip out the development tools before deployment, and start-up time.  Some of these problems might seem to be less severe with today&amp;#8217;s hardware, but they are still issues.&lt;/p&gt;
&lt;p&gt;I feel that I might be coming across a little too harshly on my old friend Smalltalk.  It still provides a great programming environment, and serves as a source of inspiration which shouldn&amp;#8217;t be overlooked, and I hope to see some of the powerful development tool features from Smalltalk appear with help from support in some of the emerging Ruby implementations.  I&amp;#8217;m glad to see that it seems to be making somewhat of a resurgence, along with dynamic languages in general.  But for me right now, while I wouldn&amp;#8217;t be unhappy if I had to go back to Smalltalk, but I feel happier with Ruby.&lt;/p&gt;</description>
      <pubDate>Wed, 21 May 2008 16:58:00 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:8d57cff0-8bf8-43fe-8b97-c7b98decd8f1</guid>
      <author>Rick DeNatale</author>
      <link>http://talklikeaduck.denhaven2.com/articles/2008/05/21/what-would-you-miss-if-you-had-to-stop-using-ruby-and-go-back-to-smalltalk</link>
      <category>ruby</category>
      <category>war_stories</category>
      <category>smalltalk</category>
      <category>seaside</category>
      <category>debugging</category>
      <trackback:ping>http://talklikeaduck.denhaven2.com/articles/trackback/500</trackback:ping>
    </item>
    <item>
      <title>On Ceremony and Training Wheels</title>
      <description>&lt;p&gt;The perennial topic of &lt;a href="http://www.nabble.com/Not-quite-getting-it.-td17281703.html"&gt;&lt;strong&gt;getting&lt;/strong&gt; duck-typing in ruby&lt;/a&gt; has come up again.  A ruby nuby wonders about the dangers of passing a &amp;#8220;giraffe&amp;#8221; object to a method expecting an &amp;#8220;order.&amp;#8221; Or asking an object to &amp;#8220;draw&amp;#8221;, expecting it to be a &amp;#8220;brush&amp;#8221; when it was really a &amp;#8220;cowboy.&amp;#8221;&lt;/p&gt;
&lt;p&gt;These are reasonable questions, coming from someone who is used to a high-ceremony language which gives at least the illusion of protection from such &amp;#8220;errors.&amp;#8221;  Note that method signatures in languages like Java can&amp;#8217;t really protect from a draw method doing different things in different classes.&lt;/p&gt;
&lt;p&gt;J. Cooper offered the following good advice:&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;Instead, look at it like this: how likely is a Giraffe able to do what
an Order does? If the Giraffe doesn&amp;#8217;t quack like an Order, than an
exception is going to be thrown automatically anyway.&lt;/p&gt;
&lt;p&gt;Just program in it, and see how often it ever actually bites you. Start
with small things, work your way up.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;The advice here is to tackle the problem of learning a language like Ruby with a certain amount of fearlessness.  This reminds me of learning to ride a bike.&lt;/p&gt;
&lt;p&gt;The traditional way of learning to ride a bicycle is to use training wheels, sometimes even progressively.  Your dad might have installed the training wheels so that they touched the ground, turning the bike into a kind of tricycle with an extra, overly large back wheel between the normal ones.  You think you&amp;#8217;re riding a bike, but you&amp;#8217;re really still on a trike.&lt;/p&gt;
&lt;p&gt;The next stage, is for dad to raise the training wheels a bit so that you need to start learning to balance properly, but you can&amp;#8217;t really tip too far. Now you&amp;#8217;re riding something that kind of acts like a bicycle, but which &amp;#8220;flops over&amp;#8221; into tricycle mode.&lt;/p&gt;
&lt;p&gt;If you never get past this stage, you never really learn to ride a bike.  In an analogy with programming in Ruby, training wheels are &lt;a href="http://talklikeaduck.denhaven2.com/articles/2007/10/22/chicken-typing-isnt-duck-typing"&gt;chicken typing&lt;/a&gt; devices.&lt;/p&gt;
&lt;p&gt;The truth is that bicycles and motorcycles operate quite differently than wheeled vehicles which keep three or more wheels on the ground, for one thing you steer by leaning, not with the handlebars or steering wheel.  Learning to fly an airplane gives even stronger examples of having to learn that your instincts are wrong, and that you have to train yourself to &amp;#8220;instinctively&amp;#8221; know not only that you turn by banking rather than with the rudder, but that you control altitude primarily with the throttle, not the elevators, speed primarily with the elevators not the throttle, and so forth.&lt;/p&gt;
&lt;p&gt;Now the use of training wheels, or flight simulators, might be considered a ceremony, although a necessary rite of passage for many learners.  Given the high cost of mistakes in learning, it&amp;#8217;s no doubt a good thing that student pilots get time in simulators and in dual control planes accompanied by a flight instructor before soloing.  Although the way most young birds learn to fly is to be throw out of the nest to &amp;#8220;sink&amp;#8221; or &amp;#8220;swim&amp;#8221; so to speak.&lt;/p&gt;
&lt;p&gt;In learning to program, it&amp;#8217;s hard to see a difference between a simulator and reality, so it&amp;#8217;s perfectly feasible to &amp;#8220;fly the plane&amp;#8221; from the start. The consequences of a mistake are no more dire than making a mistake in a flight simulator.  It&amp;#8217;s really just a matter of conquering fear, not to rely on chicken-typing, and the more mistakes you make and correct, the more quickly you come to grips with the differences in really using a dynamically typed language from earlier experiences.&lt;/p&gt;
&lt;p&gt;Some can do this easier than others.  For example, Alex, my 6-year old next-door neighbor recently jumped off his tricycle, and onto a bicycle (sans training wheels) and is now zooming around our cul-de-sac faster than ever before.&lt;/p&gt;
&lt;p&gt;So if you&amp;#8217;re struggling with how to program Ruby or a similar language because lacking ceremonial training wheels to &amp;#8220;bridge the gap&amp;#8221; from Java or a similar language.  Might I suggest that you just jump in like Alex and give it a whirl.&lt;/p&gt;
&lt;p&gt;Of course, it&amp;#8217;s rarely easy to be as fearless as a 6-year old!&lt;/p&gt;</description>
      <pubDate>Sun, 18 May 2008 10:15:00 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:d174206d-505d-465b-8cbd-435bd179a143</guid>
      <author>Rick DeNatale</author>
      <link>http://talklikeaduck.denhaven2.com/articles/2008/05/18/on-ceremony-and-training-wheels</link>
      <category>ruby</category>
      <category>ducks</category>
      <category>chickens</category>
      <category>ceremony</category>
      <trackback:ping>http://talklikeaduck.denhaven2.com/articles/trackback/499</trackback:ping>
    </item>
    <item>
      <title>Rails 2.1RC1 and the Enhanced Migrations Plugin</title>
      <description>At work, we use the Revolution on Rails &lt;a href="http://revolutiononrails.blogspot.com/2007/02/plugin-release-enhanced-rails.html"&gt;enhanced_migrations plugin&lt;/a&gt;.
&lt;p&gt;Yesterday I started the work of moving the app to Rails 2.1RC1.&lt;/p&gt;
&lt;p&gt;With version 2.1, Rails is moving to timestamp based migration names, instead of the traditional sequence numbering.  This effectively does the same thing as the enhanced_migrations plugin, but the implementation is slightly different, more on this in a bit.&lt;/p&gt;
&lt;p&gt;After installing or &lt;a href="http://railscasts.com/episodes/105"&gt;&lt;strong&gt;git&lt;/strong&gt;ting&lt;/a&gt; Rails 2.1 into my vendor/rails directory, I ran the rake task to run all of our tests and specs.&lt;/p&gt;
&lt;p&gt;Early on this task does a rake db:migrate, which attempted to run &lt;span class="caps"&gt;ALL&lt;/span&gt; of our migrations since Rails 2.1 looks in a different place to determine if a migration has been already run.&lt;/p&gt;
&lt;h2&gt;Implementation Differences&lt;/h2&gt;
&lt;p&gt;Until now Rails has tracked migrations using a single row, single column table in each database called schema_version. This table holds the number of the latest migration which has been run.&lt;/p&gt;
&lt;p&gt;The enhanced_migrations plugin uses a w table, named migrations_info, with one row for each migration which has been applied to the database.  The key used for this table is the migration number which the migration generator sets to Time.now.to_i. The only column besides the id is created_at. So the enhanced_migration plugin captures the time at which the migration was run against the database, which is different than the time it was generated.&lt;/p&gt;
&lt;p&gt;Rails 2.1 uses a table called schema_migrations, which also has a row per applied migration, but this table has a string key whose value is the migration number, in Rails 2.1, the migration number is also a utc timestamp but is a string in the the form &amp;#8220;yyyymmddhhmmss&amp;#8221;&lt;/p&gt;
&lt;p&gt;Blake Watters and I noticed that the timestamp forms can&amp;#8217;t overlap since enhanced migrations uses a 10-digit timestamp and Rails 2.1 uses a 14-digit one.  So we wrote a new migration 1_convert_migration_schema_to_rails21.rb&lt;/p&gt;
&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_ruby "&gt;&lt;span class="keyword"&gt;class &lt;/span&gt;&lt;span class="class"&gt;ConvertMigrationSchemaToRails21&lt;/span&gt; &lt;span class="punct"&gt;&amp;lt;&lt;/span&gt; &lt;span class="constant"&gt;ActiveRecord&lt;/span&gt;&lt;span class="punct"&gt;::&lt;/span&gt;&lt;span class="constant"&gt;Migration&lt;/span&gt;
  &lt;span class="keyword"&gt;def &lt;/span&gt;&lt;span class="method"&gt;self.up&lt;/span&gt;
    &lt;span class="ident"&gt;values&lt;/span&gt; &lt;span class="punct"&gt;=&lt;/span&gt; &lt;span class="ident"&gt;select_values&lt;/span&gt;&lt;span class="punct"&gt;('&lt;/span&gt;&lt;span class="string"&gt;select id from migrations_info&lt;/span&gt;&lt;span class="punct"&gt;')&lt;/span&gt;
    &lt;span class="ident"&gt;values&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;each&lt;/span&gt; &lt;span class="punct"&gt;{|&lt;/span&gt;&lt;span class="ident"&gt;value&lt;/span&gt;&lt;span class="punct"&gt;|&lt;/span&gt; &lt;span class="ident"&gt;execute&lt;/span&gt;&lt;span class="punct"&gt;(&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;replace into schema_migrations VALUES('&lt;span class="expr"&gt;#{id}&lt;/span&gt;')&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;)}&lt;/span&gt;
  &lt;span class="keyword"&gt;end&lt;/span&gt;

  &lt;span class="keyword"&gt;def &lt;/span&gt;&lt;span class="method"&gt;self.down&lt;/span&gt;
  &lt;span class="keyword"&gt;end&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;We then ran rake db:migrate:up &lt;span class="caps"&gt;VERSION&lt;/span&gt;=1&lt;/p&gt;
&lt;p&gt;This populated schema_migrations so that it now &amp;#8220;knew&amp;#8221; that all of our current migrations had already been run.&lt;/p&gt;
&lt;h2&gt;Not quite there&lt;/h2&gt;
&lt;p&gt;For many current users of enhanced_migrations, this might be enough. In our case it wasn&amp;#8217;t.  When I tried to run rake test again, it blew up in the prerequisite task db:test:clone_structure, complaining about bad sql syntax on an insert statement.  The insert statement which was logged looked perfectly fine. It was the second of a series of statements inserting rows into our new friend, the schema_migrations table.
The &lt;span class="caps"&gt;SQL&lt;/span&gt; in question looked like this:&lt;/p&gt; 
&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;INSERT INTO schema_migrations (version) VALUES ('0');
INSERT INTO schema_migrations (version) VALUES ('1');&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Followed by a similar line for each of our 500 or so migrations.&lt;/p&gt;
&lt;p&gt;The rake task for db:test:clone structure, basically breaks the file db/development_structure.sql into chunks delimited by empty lines, and &amp;#8216;plays&amp;#8217; them against the test database using ActiveRecord::Base.connection.execute.  After some head scratching over why this seemingly legal &lt;span class="caps"&gt;SQL&lt;/span&gt; was being rejected, it occurred to us that it was trying to execute all of these lines as one sql statement.&lt;/p&gt;
&lt;p&gt;So the next step was to figure out how to get db/development_structure.sql into a form which would cause the task to execute each sql statement individually.  This was a simple patch to rails, which once made, allowed rake db:test:prepare to run successfully, which in turn allowed me to actually move on to running the test suite and working out the problems caused by the changes to rails.&lt;/p&gt;
&lt;p&gt;I opened up &lt;a href="http://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/201-process-schema_migrations-inserts-individually-during-rake-db-test-clone_structure#ticket-201-2"&gt;ticket #201 on the Rails lighthouse&lt;/a&gt; which contains the Rails patch.&lt;/p&gt;</description>
      <pubDate>Thu, 15 May 2008 15:24:00 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:1c1affbf-7dca-4705-9248-099bdee52f3e</guid>
      <author>Rick DeNatale</author>
      <link>http://talklikeaduck.denhaven2.com/articles/2008/05/15/rails-2-1rc1-and-the-enhanced-migrations-plugin</link>
      <category>rails</category>
      <category>migrations</category>
      <category>rails2.1</category>
      <trackback:ping>http://talklikeaduck.denhaven2.com/articles/trackback/498</trackback:ping>
    </item>
    <item>
      <title>Big Dave on Video</title>
      <description>InfoQ recently published a &lt;a href="http://www.infoq.com/interviews/dave-thomas-programming-languages-soa-and-the-web"&gt;video interview with Dave Thomas (of &lt;span class="caps"&gt;OTI&lt;/span&gt; fame)&lt;/a&gt;.
&lt;p&gt;In his inimitable style, Dave covers lots of interesting topics in software development, both today and with a historical perspective.&lt;/p&gt;
&lt;p&gt;I agree with almost everything he says, and find the rest food for thought.&lt;/p&gt;
&lt;p&gt;His comments about Java as a platform are quite germane to the article I published yesterday.  If you&amp;#8217;ve been exposed to Big Dave before, you&amp;#8217;ll enjoy this, and if you haven&amp;#8217;t it&amp;#8217;s a good introduction.&lt;/p&gt;</description>
      <pubDate>Tue, 29 Apr 2008 22:24:00 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:57c38e47-d746-4687-9434-480b47fdcab7</guid>
      <author>Rick DeNatale</author>
      <link>http://talklikeaduck.denhaven2.com/articles/2008/04/29/big-dave-on-video</link>
      <category>BigDave</category>
      <category>java</category>
      <category>smalltalk</category>
      <category>ruby</category>
      <category>iconoclasts</category>
      <trackback:ping>http://talklikeaduck.denhaven2.com/articles/trackback/497</trackback:ping>
    </item>
    <item>
      <title>The Perils of Ruby</title>
      <description>Charlie Nutter just published an article which assesses &lt;a href="http://headius.blogspot.com/2008/04/promise-and-peril-for-alternative-ruby.html"&gt;the various implementations of Ruby&lt;/a&gt;. In all it&amp;#8217;s a quite even-handed description coming from one of the main proponents of JRuby.
&lt;p&gt;Charlie talks about each implementation and describes the perils each faces.&lt;/p&gt;
&lt;p&gt;These seem to be days of crisis for Ruby.  With so many implementations compatibility is a challenge.  Particularly since Ruby lacks a formal specification.  The Rubinius developers have been working hard to address this by developing, RubySpecs, a set of &lt;a href="http://rubinius.lighthouseapp.com/projects/5089/specs-overview"&gt;rspec style specifications for Ruby&lt;/a&gt;.  Matz has also convened a regular meeting of Ruby implementors via irc.  The &lt;a href="http://ruby-design.pbwiki.com/Design20080421"&gt;first meeting took place last week,&lt;/a&gt;and one of the decisions taken was to make RubySpec the officially blessed set of tests to be used by all implementors.&lt;/p&gt;
&lt;blockquote class="pullquote"&gt;Compatibility is &lt;strong&gt;hard&lt;/strong&gt;. I&amp;#8217;m not talking a little hard, I&amp;#8217;m talking monumentally hard. Ruby is a very flexible, complicated language to implement, and it ships with a number of very flexible, complicated core class implementations. Very little exists in the way of specifications and test kits. &amp;#8211; Charles Nutter&lt;/blockquote&gt;
&lt;h2&gt;Is Ruby Forking?&lt;/h2&gt;
&lt;p&gt;Currently there are two major &amp;#8220;official&amp;#8221; versions of Ruby. Ruby 1.8, which is in use for most production purposes, and Ruby 1.9 which introduces new features (e.g. integrated support for strings with different encodings), new language features (e.g. new syntax for hash literals which allows actual parameters to methods taking an options hash as the last argument to look like keyword parameters), and some incompatibilities.&lt;/p&gt;
&lt;p&gt;As Charlie points out the peril here is that Rubyists have a hard time figuring out which Ruby to target.  Ruby 1.9 isn&amp;#8217;t yet ready for production, but even when it is, will the advantages outweigh the cost of the &amp;#8216;porting&amp;#8217; needed to get past the incompatibilities.&lt;/p&gt;
&lt;p&gt;Some implementations are attempting to bridge the gap. JRuby is taking on some 1.9 features while maintaining compatibility with 1.8.  The recent preview release of Ruby 1.8.7, also introduces some 1.9 features to the 1.8.x code base, albeit with some initial incompatibilities, which hopefully will be worked out. RubySpec should help this.&lt;/p&gt;
&lt;p&gt;MacRuby, on the other hand, is taking another approach to 1.9 features.  MacRuby is a new Apple implementation of Ruby which uses the Objective-C run-time as a platform, much as JRUby and IronRuby use the Java &lt;span class="caps"&gt;JVM&lt;/span&gt;, and Microsoft &lt;span class="caps"&gt;DLR&lt;/span&gt;, as platforms.&lt;/p&gt;
&lt;p&gt;One of the ways in which MacRuby exploits 1.9 is the way they are mapping the new hash literal syntax I just mentioned.  Let&amp;#8217;s look a bit at that new syntax.&lt;/p&gt;
&lt;p&gt;At the risk of offending the &amp;#8220;Rails isn&amp;#8217;t Ruby crowd&amp;#8221;, I&amp;#8217;m going to take an example from ActiveRecord, because Rails tends to use option hash parameters quite a bit.  In Ruby 1.8 I might code:&lt;/p&gt;
&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;Book.find(:all, :order =&amp;gt; &amp;quot;title ASC&amp;quot;, :limit =&amp;gt; 10)&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;To get the first 10 books sorted by title.  The new Ruby 1.9 syntax allows this to be written alternatively as:&lt;/p&gt;
&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_ruby "&gt;&lt;span class="constant"&gt;Book&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;find&lt;/span&gt;&lt;span class="punct"&gt;(&lt;/span&gt;&lt;span class="symbol"&gt;:all&lt;/span&gt;&lt;span class="punct"&gt;,&lt;/span&gt; &lt;span class="ident"&gt;order&lt;/span&gt;&lt;span class="punct"&gt;:&lt;/span&gt; &lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;title ASC&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;,&lt;/span&gt; &lt;span class="ident"&gt;limit&lt;/span&gt;&lt;span class="punct"&gt;:&lt;/span&gt; &lt;span class="number"&gt;10&lt;/span&gt;&lt;span class="punct"&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Which is actually an identical call.  These &amp;#8220;keyword arguments&amp;#8221; are quite reminiscent of the Smalltalk-inspired syntax used in Objective-C. As I understand it, MacRuby will look at such a call, and turn it into an Objective-C message internally something like:&lt;/p&gt;
&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_objective-c "&gt;[Book find: @selector(all) order: &amp;quot;title ASC&amp;quot; limit: 10]&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;But this isn&amp;#8217;t exactly the same.  In Ruby one method can handle multiple optional keyword arguments which can appear (or not) in any order.  In Objective-C the message selectors find:order:limit, and find:limit:order would map to different methods.  When I asked Laurent Sansonetti about this on ruby-core, he said that the implementation would actually determine whether the receiving object understands :find:order:limit: and if not fall back to a more ruby-like call.  I&amp;#8217;m not sure how such a chicken-typed implementation will really stand up in practice, but I guess that time will tell.&lt;/p&gt;
&lt;p&gt;I&amp;#8217;m also not sure what the long-term implications of this are as Matz moves from 1.9 to 2.0 and perhaps starts defining new method definition syntax which provides syntactic sugar (at least) for handling &amp;#8220;keyword parameter&amp;#8221; hashes on the other side of the  invocation.&lt;/p&gt;
&lt;h2&gt;Platforms, Platforms, Platforms&lt;/h2&gt;
&lt;p&gt;As I said above, one way to characterize the various ruby implementations is by the platform each &amp;#8216;advocates&amp;#8217;.  Traditional &lt;span class="caps"&gt;MRI&lt;/span&gt; Ruby, and Ruby 1.9 run well on &lt;span class="caps"&gt;UNIX&lt;/span&gt; like platforms like Linux, &lt;span class="caps"&gt;OS X&lt;/span&gt;, and Solaris. Rubinius is building a new Ruby-based platform using ideas from Squeak and earlier Smalltalk implementations, although as far as I can tell, it&amp;#8217;s not following the Smalltalk philosophy of being an &amp;#8220;operating system&amp;#8221; on its own, IronRuby is really an attempt to optimize a Ruby implementation for Microsoft Platforms, while JRuby leverages the &lt;span class="caps"&gt;JVM&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;I can&amp;#8217;t help but think back to the early 1990s as a member of the Smalltalk community.  Smallalk had gained a fair bit of traction in the enterprise, particularly in industries such as finance and insurance where rapid application development was important. Java started to take the wind out of Smalltalk&amp;#8217;s sails.  I always considered the switch from Smalltalk to Java to be driven by factors such as the cost of entry for an individual programmer, but my old friend Dave Thomas (OTI&amp;#8217;s BigDave, not pragDave) points out that it was more a matter of companies like &lt;span class="caps"&gt;IBM&lt;/span&gt; (one of the main Smalltalk vendors by then) moving to Java as an anti-Microsoft platform. Java really took off in the enterprise after &lt;span class="caps"&gt;IBM&lt;/span&gt;, Sun, and others entered a kind of &lt;span class="caps"&gt;ABM&lt;/span&gt; treaty (Anyone But Microsoft)&lt;/p&gt;
&lt;p&gt;Ruby is in a different place than Smalltalk was at that time. Smalltalk was available from, and advocated by, a small number of vendors who sold it at a handsome price.  Two of the big Smalltalk implementations survive, &lt;span class="caps"&gt;IBM&lt;/span&gt;/VisualAge Smalltalk is still available from Instantiations &lt;a href="http://www.instantiations.com/VAST/purchase.html"&gt;at a four figure price&lt;/a&gt;. Cincom sells the latest version of VisualWorks Smalltalk, under a complex web of licensing options. Both of these &amp;#8220;compete&amp;#8221; with the open-source Squeak implementation.&lt;/p&gt;
&lt;p&gt;The environment has shifted out from under the big corporate providers of software development tooling like &lt;span class="caps"&gt;IBM&lt;/span&gt;, Sun and Microsoft. It&amp;#8217;s hard to see how to make big bucks selling development tools when so much is available under various open-source licenses for the cost of a download.&lt;/p&gt;
&lt;p&gt;Ruby has come out of today&amp;#8217;s open-software environment. It was conceived out of one man&amp;#8217;s desire for a language which he personally found pleasing, and grew within the open source community.  While I applaud and appreciate the support that Ruby has received from Sun, Microsoft, Apple, and other corporations, I can&amp;#8217;t help but feeling that some of the motivation is based on keeping control of the platform.&lt;/p&gt;
&lt;p&gt;These might be perilous times for Ruby, but I&amp;#8217;ve got confidence that the overall community will keep things from getting too far out of whack.&lt;/p&gt;
&lt;p&gt;Again, time will tell.&lt;/p&gt;</description>
      <pubDate>Sun, 27 Apr 2008 15:17:00 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:74c1c878-8e63-4058-a787-d9af613f2af7</guid>
      <author>Rick DeNatale</author>
      <link>http://talklikeaduck.denhaven2.com/articles/2008/04/27/the-perils-of-ruby</link>
      <category>ruby</category>
      <category>opinion</category>
      <trackback:ping>http://talklikeaduck.denhaven2.com/articles/trackback/496</trackback:ping>
    </item>
  </channel>
</rss>
