<?xml version="1.0" encoding="utf-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Ruby: First Impressions</title>
	<atom:link href="http://www.whirlycott.com/phil/2005/04/13/ruby-first-impressions/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.whirlycott.com/phil/2005/04/13/ruby-first-impressions/</link>
	<description>Philip Jacob's web page</description>
	<lastBuildDate>Tue, 13 Sep 2011 08:59:30 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Jules</title>
		<link>http://www.whirlycott.com/phil/2005/04/13/ruby-first-impressions/comment-page-1/#comment-1583</link>
		<dc:creator>Jules</dc:creator>
		<pubDate>Fri, 17 Mar 2006 20:17:16 +0000</pubDate>
		<guid isPermaLink="false">http://www.whirlycott.com/phil/2005/04/13/ruby-first-impressions/#comment-1583</guid>
		<description></description>
		<content:encoded><![CDATA[<p>Another way to iterate:</p>
<p>for i in [1, 2, 3]<br />
  # do something<br />
end</p>
<p>or for a hash:</p>
<p>for (key, value) in {:one =&gt; 1, :two =&gt; 2}<br />
  # &#8230;<br />
end</p>
<p>or:</p>
<p>{:one =&gt; 1, :two =&gt; 2}.each do |(key, value)|<br />
  # &#8230;<br />
end</p>
<p>I think most ruby programmers will do this:</p>
<p>list = [â€?dogâ€?, â€œcatâ€?, â€œweaselâ€?, â€œfishâ€?, â€œcanaryâ€?, â€œmonkeyâ€?]<br />
puts list.sort.map{|animal|  â€œwould you like to pet my #{animal}?â€?)</p>
<p>instead of:</p>
<p>list = [â€?dogâ€?, â€œcatâ€?, â€œweaselâ€?, â€œfishâ€?, â€œcanaryâ€?, â€œmonkeyâ€?]<br />
list.sort.each do |animal|<br />
  puts â€œwould you like to pet my #{animal}?â€?<br />
end</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anonymous</title>
		<link>http://www.whirlycott.com/phil/2005/04/13/ruby-first-impressions/comment-page-1/#comment-724</link>
		<dc:creator>Anonymous</dc:creator>
		<pubDate>Wed, 27 Apr 2005 11:23:13 +0000</pubDate>
		<guid isPermaLink="false">http://www.whirlycott.com/phil/2005/04/13/ruby-first-impressions/#comment-724</guid>
		<description>two tiny little differences in the exception handling beetween java and ruby.
First, in ruby you have a &quot;rescue modifier&quot;, wich means that where in java you&#039;d do:

Foo f=null;
try{
 f= someDangerousCall();
} catch (SomeException e){
 f= someThingElse;
}

in ruby you&#039;d do:
 f= dangerous_call() rescue something_else

The other nice thing is that, when you&#039;re writing methods, the method block acts as an enclosing try/catch, so you would write:
def foo
 bla bla bla
rescue 
 yuk yuk
end

where in java you&#039;d write:
Foo foober( ) {
 try {
  bla bla bla
 } catch(Excep e){
  yuk yuk
 }
 return something
}

and since the ruby stile is to write many little methods, you almost never use the begin/end thing </description>
		<content:encoded><![CDATA[<p>two tiny little differences in the exception handling beetween java and ruby.<br />
First, in ruby you have a &#8220;rescue modifier&#8221;, wich means that where in java you&#8217;d do:</p>
<p>Foo f=null;<br />
try{<br />
 f= someDangerousCall();<br />
} catch (SomeException e){<br />
 f= someThingElse;<br />
}</p>
<p>in ruby you&#8217;d do:<br />
 f= dangerous_call() rescue something_else</p>
<p>The other nice thing is that, when you&#8217;re writing methods, the method block acts as an enclosing try/catch, so you would write:<br />
def foo<br />
 bla bla bla<br />
rescue<br />
 yuk yuk<br />
end</p>
<p>where in java you&#8217;d write:<br />
Foo foober( ) {<br />
 try {<br />
  bla bla bla<br />
 } catch(Excep e){<br />
  yuk yuk<br />
 }<br />
 return something<br />
}</p>
<p>and since the ruby stile is to write many little methods, you almost never use the begin/end thing</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dan</title>
		<link>http://www.whirlycott.com/phil/2005/04/13/ruby-first-impressions/comment-page-1/#comment-721</link>
		<dc:creator>Dan</dc:creator>
		<pubDate>Wed, 27 Apr 2005 04:15:53 +0000</pubDate>
		<guid isPermaLink="false">http://www.whirlycott.com/phil/2005/04/13/ruby-first-impressions/#comment-721</guid>
		<description>Gotcha Philip. Glad to hear it.

Hope I didn&#039;t scare you off with the...intensity...of my first response. I saw these lines:

&gt; Iâ€™m fairly sure that thereâ€™s no such ability in the Ruby world.
&gt; ...the big enterprise stuff doesnâ€™t exist yet in Rubyland: 

and had to speak up. Guess they weren&#039;t really &#039;conclusions&#039; per say.

Good luck, as you&#039;ve probably noticed, there&#039;s quite a community out there to support (chastize? :) you in your ruby adventures.

Dan
 </description>
		<content:encoded><![CDATA[<p>Gotcha Philip. Glad to hear it.</p>
<p>Hope I didn&#8217;t scare you off with the&#8230;intensity&#8230;of my first response. I saw these lines:</p>
<p>&gt; Iâ€™m fairly sure that thereâ€™s no such ability in the Ruby world.<br />
&gt; &#8230;the big enterprise stuff doesnâ€™t exist yet in Rubyland: </p>
<p>and had to speak up. Guess they weren&#8217;t really &#8216;conclusions&#8217; per say.</p>
<p>Good luck, as you&#8217;ve probably noticed, there&#8217;s quite a community out there to support (chastize? <img src='http://www.whirlycott.com/phil/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  you in your ruby adventures.</p>
<p>Dan</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Philip Jacob</title>
		<link>http://www.whirlycott.com/phil/2005/04/13/ruby-first-impressions/comment-page-1/#comment-719</link>
		<dc:creator>Philip Jacob</dc:creator>
		<pubDate>Tue, 26 Apr 2005 23:02:14 +0000</pubDate>
		<guid isPermaLink="false">http://www.whirlycott.com/phil/2005/04/13/ruby-first-impressions/#comment-719</guid>
		<description>Dan,

The &lt;em&gt;only&lt;/em&gt; conclusion that I&#039;ve made about Ruby so far is this one:

&lt;blockquote&gt;
So Rubyâ€™s good. Iâ€™m into it. My first experience was good, which means that Iâ€™ll certainly have a second experience.
&lt;/blockquote&gt;

Zdennis,

Thanks for your interesting thoughts about list iteration.  What I&#039;m seeing is again reminiscent of one of the differences between Perl and Java: the size of the language.  Java is actually a much smaller language than Perl is, precisely because it doesn&#039;t have &lt;b&gt;built-in&lt;/b&gt; support for things like iteration... all of Java&#039;s cool features are in classes that exist outside of java.lang (like java.util&#039;s collections, iterators, etc.) while Perl has all of this stuff baked into the language as builtin functions (keys, each, etc.).  Notice again how I&#039;m not drawing any conclusions about Ruby but rather am making a general comparision of the design of the language.</description>
		<content:encoded><![CDATA[<p>Dan,</p>
<p>The <em>only</em> conclusion that I&#8217;ve made about Ruby so far is this one:</p>
<blockquote><p>
So Rubyâ€™s good. Iâ€™m into it. My first experience was good, which means that Iâ€™ll certainly have a second experience.
</p></blockquote>
<p>Zdennis,</p>
<p>Thanks for your interesting thoughts about list iteration.  What I&#8217;m seeing is again reminiscent of one of the differences between Perl and Java: the size of the language.  Java is actually a much smaller language than Perl is, precisely because it doesn&#8217;t have <b>built-in</b> support for things like iteration&#8230; all of Java&#8217;s cool features are in classes that exist outside of java.lang (like java.util&#8217;s collections, iterators, etc.) while Perl has all of this stuff baked into the language as builtin functions (keys, each, etc.).  Notice again how I&#8217;m not drawing any conclusions about Ruby but rather am making a general comparision of the design of the language.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Merc</title>
		<link>http://www.whirlycott.com/phil/2005/04/13/ruby-first-impressions/comment-page-1/#comment-718</link>
		<dc:creator>Merc</dc:creator>
		<pubDate>Tue, 26 Apr 2005 22:07:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.whirlycott.com/phil/2005/04/13/ruby-first-impressions/#comment-718</guid>
		<description>Why use &quot;each&quot; for iterators?  Because you don&#039;t need the index, so fewer useless variables littering your code.

list = [&quot;dog&quot;, &quot;cat&quot;, &quot;weasel&quot;, &quot;fish&quot;, &quot;canary&quot;, &quot;monkey&quot;]
list.sort.each do
  &#124;animal&#124;
  puts &quot;would you like to pet my #{animal}?&quot;
end

The only variable there is &quot;animal&quot;, there is no &quot;i&quot;, this makes it much easier to have nested looping constructs, and to copy and paste these loops around all over the place.  If you have to use &quot;i&quot; in your loops, when you stick it into another loop, you have to remember to change that &quot;i&quot; to a &quot;j&quot;.

The bit between &quot;do&quot; and &quot;end&quot; is a block, and they&#039;re also really useful for doing things like connecting to databases.  Rather than knowing about &quot;begin&quot;, &quot;rescue&quot;, &quot;ensure&quot;, &quot;end&quot;, you can let that be handled inside the DB layer:

db.connect(foo, bar, baz) do
  &#124;handle&#124;
  handle.do_something()
end

If do_something() makes the database throw an exception, the db wrapper can clean it all up and you just get to &quot;end&quot; cleanly.
</description>
		<content:encoded><![CDATA[<p>Why use &#8220;each&#8221; for iterators?  Because you don&#8217;t need the index, so fewer useless variables littering your code.</p>
<p>list = ["dog", "cat", "weasel", "fish", "canary", "monkey"]<br />
list.sort.each do<br />
  |animal|<br />
  puts &#8220;would you like to pet my #{animal}?&#8221;<br />
end</p>
<p>The only variable there is &#8220;animal&#8221;, there is no &#8220;i&#8221;, this makes it much easier to have nested looping constructs, and to copy and paste these loops around all over the place.  If you have to use &#8220;i&#8221; in your loops, when you stick it into another loop, you have to remember to change that &#8220;i&#8221; to a &#8220;j&#8221;.</p>
<p>The bit between &#8220;do&#8221; and &#8220;end&#8221; is a block, and they&#8217;re also really useful for doing things like connecting to databases.  Rather than knowing about &#8220;begin&#8221;, &#8220;rescue&#8221;, &#8220;ensure&#8221;, &#8220;end&#8221;, you can let that be handled inside the DB layer:</p>
<p>db.connect(foo, bar, baz) do<br />
  |handle|<br />
  handle.do_something()<br />
end</p>
<p>If do_something() makes the database throw an exception, the db wrapper can clean it all up and you just get to &#8220;end&#8221; cleanly.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dan</title>
		<link>http://www.whirlycott.com/phil/2005/04/13/ruby-first-impressions/comment-page-1/#comment-717</link>
		<dc:creator>Dan</dc:creator>
		<pubDate>Tue, 26 Apr 2005 22:03:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.whirlycott.com/phil/2005/04/13/ruby-first-impressions/#comment-717</guid>
		<description>You have missed some ruby features in your evaluation that may have lead you to some erroneous conclusions:

- jruby (like jython)
- ruby&#039;s builtin concurrent programming libraries
- the ruby queue library (http://www.linuxjournal.com/article/7922)

For me, what ruby has over perl is the ease for OOP. I&#039;m highly surprised that you didn&#039;t mention that. The syntax is &#039;cute&#039;, as you say, but the ability to easily create/extend classes and the like really is more important IMHO.

Perhaps with a more in-depth analyis of ruby, the real advantages it has will emerge. &#039;Ruby first impressions&#039; is a good title for your entry for that reason, just be wary of what conclusions you arrive at with only a &#039;first impression&#039;. You really do take your conclusions a little too far for so little experience.
</description>
		<content:encoded><![CDATA[<p>You have missed some ruby features in your evaluation that may have lead you to some erroneous conclusions:</p>
<p>- jruby (like jython)<br />
- ruby&#8217;s builtin concurrent programming libraries<br />
- the ruby queue library (<a href="http://www.linuxjournal.com/article/7922" rel="nofollow">http://www.linuxjournal.com/article/7922</a>)</p>
<p>For me, what ruby has over perl is the ease for OOP. I&#8217;m highly surprised that you didn&#8217;t mention that. The syntax is &#8216;cute&#8217;, as you say, but the ability to easily create/extend classes and the like really is more important IMHO.</p>
<p>Perhaps with a more in-depth analyis of ruby, the real advantages it has will emerge. &#8216;Ruby first impressions&#8217; is a good title for your entry for that reason, just be wary of what conclusions you arrive at with only a &#8216;first impression&#8217;. You really do take your conclusions a little too far for so little experience.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: zdennis</title>
		<link>http://www.whirlycott.com/phil/2005/04/13/ruby-first-impressions/comment-page-1/#comment-716</link>
		<dc:creator>zdennis</dc:creator>
		<pubDate>Tue, 26 Apr 2005 21:54:43 +0000</pubDate>
		<guid isPermaLink="false">http://www.whirlycott.com/phil/2005/04/13/ruby-first-impressions/#comment-716</guid>
		<description>Philip, Me&#039;s approach for iteration is more correct when talking in terms of Ruby. In the ruby community there seems to be a preferred &#039;ruby way&#039; to do basic tasks do things. As you mentioned in your blog/article, it is more of syntactic sugar. Your example gets the job done, but it also takes way to many characters. Imagine you had: &#039;

for i in 0...@recurs.length
r = @recurs[i]
...
end

Now see the ruby way:

@recurs.each { &#124;r&#124; ... }

or

@recurs.each do &#124;r&#124; ... end

If you need multiline support you can do that:

@recurs.each { &#124;r&#124;
  ...
}

or 

@recurs.each do &#124;r&#124;
  ...
end

It saves you typing and reduces two unnecessary lines to 1 line. I prefer the ruby way in this case. 

</description>
		<content:encoded><![CDATA[<p>Philip, Me&#8217;s approach for iteration is more correct when talking in terms of Ruby. In the ruby community there seems to be a preferred &#8216;ruby way&#8217; to do basic tasks do things. As you mentioned in your blog/article, it is more of syntactic sugar. Your example gets the job done, but it also takes way to many characters. Imagine you had: &#8216;</p>
<p>for i in <a href="mailto:0...@recurs.length">0&#8230;@recurs.length</a><br />
r = @recurs[i]<br />
&#8230;<br />
end</p>
<p>Now see the ruby way:</p>
<p>@recurs.each { |r| &#8230; }</p>
<p>or</p>
<p>@recurs.each do |r| &#8230; end</p>
<p>If you need multiline support you can do that:</p>
<p>@recurs.each { |r|<br />
  &#8230;<br />
}</p>
<p>or </p>
<p>@recurs.each do |r|<br />
  &#8230;<br />
end</p>
<p>It saves you typing and reduces two unnecessary lines to 1 line. I prefer the ruby way in this case.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Daniel Berger</title>
		<link>http://www.whirlycott.com/phil/2005/04/13/ruby-first-impressions/comment-page-1/#comment-715</link>
		<dc:creator>Daniel Berger</dc:creator>
		<pubDate>Tue, 26 Apr 2005 21:18:23 +0000</pubDate>
		<guid isPermaLink="false">http://www.whirlycott.com/phil/2005/04/13/ruby-first-impressions/#comment-715</guid>
		<description>If you ever need to write a C extension, you&#039;ll appreciate Ruby even more when compared to the mess that is XS.</description>
		<content:encoded><![CDATA[<p>If you ever need to write a C extension, you&#8217;ll appreciate Ruby even more when compared to the mess that is XS.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: rawlinson - us &#187; Lootly! Development Beginning - Help Appreciated</title>
		<link>http://www.whirlycott.com/phil/2005/04/13/ruby-first-impressions/comment-page-1/#comment-714</link>
		<dc:creator>rawlinson - us &#187; Lootly! Development Beginning - Help Appreciated</dc:creator>
		<pubDate>Tue, 26 Apr 2005 20:16:29 +0000</pubDate>
		<guid isPermaLink="false">http://www.whirlycott.com/phil/2005/04/13/ruby-first-impressions/#comment-714</guid>
		<description>[...] getters on the Song class for the name, artist and duration fields.     example thanks to  Philip Jacob.  Recent development in PHP land such as the release of mach-ii f [...]</description>
		<content:encoded><![CDATA[<p>[...] getters on the Song class for the name, artist and duration fields.     example thanks to  Philip Jacob.  Recent development in PHP land such as the release of mach-ii f [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Philip Jacob</title>
		<link>http://www.whirlycott.com/phil/2005/04/13/ruby-first-impressions/comment-page-1/#comment-713</link>
		<dc:creator>Philip Jacob</dc:creator>
		<pubDate>Tue, 26 Apr 2005 20:08:27 +0000</pubDate>
		<guid isPermaLink="false">http://www.whirlycott.com/phil/2005/04/13/ruby-first-impressions/#comment-713</guid>
		<description>Mel, design patterns are langugage independent constructs.  But, yes, if my job was to write code that opened files, I wouldn&#039;t use java.

Me, why is your approach to iteration the proper way?  If you&#039;re iterating through an array of integer values, I think my approach works fine.  Am I missing something?</description>
		<content:encoded><![CDATA[<p>Mel, design patterns are langugage independent constructs.  But, yes, if my job was to write code that opened files, I wouldn&#8217;t use java.</p>
<p>Me, why is your approach to iteration the proper way?  If you&#8217;re iterating through an array of integer values, I think my approach works fine.  Am I missing something?</p>
]]></content:encoded>
	</item>
</channel>
</rss>

