<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xml:base="http://thoughtshapes.com" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
 <title>ThoughtShapes - Closures in Ruby, Part I - Comments</title>
 <link>http://thoughtshapes.com/node/77</link>
 <description>Comments for &quot;Closures in Ruby, Part I&quot;</description>
 <language>en</language>
<item>
 <title>Jay,
Thanks a ton for</title>
 <link>http://thoughtshapes.com/node/77#comment-623</link>
 <description>&lt;p&gt;Jay,&lt;/p&gt;
&lt;p&gt;Thanks a ton for extending the usefulness of this post.&lt;/p&gt;
&lt;p&gt;Once you open your mind to the concept of closures, whatever the syntactical sugar may be, you begin to find all sorts of applications. I have one concern about closures: they lower the barrier of entry on concurrent programming. In other words, I am concerned because closures make it so a developer can be writing concurrent code, &lt;strong&gt;without even knowing it&lt;/strong&gt;. I hope any senior developers out there such as yourself remind their team that closures can be a loaded gun.&lt;/p&gt;
&lt;p&gt;It is certainly great to see dynamic language support making its way onto the .NET Runtime playing field. I wonder how far off we are from having (Visual Studio) solutions that contain both C# projects and Ruby.NET (or whatever it gets called)? The thought sits just fine in my mind because each language has its own strengths and weaknesses.&lt;/p&gt;
&lt;p&gt;Thanks again Jay.&lt;/p&gt;
</description>
 <pubDate>Mon, 07 Apr 2008 15:13:00 -0400</pubDate>
 <dc:creator>Rjae Easton</dc:creator>
 <guid isPermaLink="false">comment 623 at http://thoughtshapes.com</guid>
</item>
<item>
 <title>Hi!
Sorry for being so</title>
 <link>http://thoughtshapes.com/node/77#comment-622</link>
 <description>&lt;p&gt;Hi!&lt;/p&gt;
&lt;p&gt;Sorry for being so delayed in posting here but life, vacation, child illnesses etc kept me from it :)&lt;br /&gt;
This is pretty interesting stuff.  Before this post I hadn&#039;t spent time looking into the performance characteristics of the different ways to do closures in Ruby.  I was just loving closures in general and how easy of a tool they are to use in Ruby.  :)&lt;/p&gt;
&lt;p&gt;So I took your code and ran it on my machine.  I happen to be running on a MacBook pro and have 2 Ruby vms.  JRuby 1.1 RC2 and the CRuby vm everyone uses.    It&#039;s interesting to note that in JRuby &lt;/p&gt;
&lt;pre&gt;
call_with_block                0.031000   0.000000   0.031000 (  0.030000)
call_with_block_from_lambda    0.019000   0.000000   0.019000 (  0.020000)
call_with_block_from_proc      0.018000   0.000000   0.018000 (  0.018000)
yield_with_block               0.016000   0.000000   0.016000 (  0.016000)
yield_with_block_from_lambda   0.013000   0.000000   0.013000 (  0.013000)
yield_with_block_from_proc     0.012000   0.000000   0.012000 (  0.013000)
&lt;/pre&gt;&lt;p&gt;CRuby numbers on my machine:&lt;/p&gt;
&lt;pre&gt;
call_with_block               0.100000   0.000000   0.100000 (  0.100587)
call_with_block_from_lambda   0.020000   0.000000   0.020000 (  0.019553)
call_with_block_from_proc     0.020000   0.000000   0.020000 (  0.019233)
yield_with_block              0.010000   0.000000   0.010000 (  0.010333)
yield_with_block_from_lambda  0.010000   0.000000   0.010000 (  0.011263)
yield_with_block_from_proc    0.010000   0.000000   0.010000 (  0.011194)
&lt;/pre&gt;&lt;p&gt;While in JRuby the numbers seem less clear, I still think the elegance of yields and blocks needs to be a factor until such a time as performance tuning needs to be examined.  &lt;/p&gt;
&lt;p&gt;Also I hadn&#039;t been using yield all that much but I haven&#039;t written to many functions that take a block explicitly, yet.  I&#039;m still getting into that swing.  But I&#039;ll be sure to go back and make sure I&#039;m using yield :)&lt;/p&gt;
&lt;p&gt;good stuff!&lt;/p&gt;
</description>
 <pubDate>Sun, 06 Apr 2008 21:07:57 -0400</pubDate>
 <dc:creator>Jay</dc:creator>
 <guid isPermaLink="false">comment 622 at http://thoughtshapes.com</guid>
</item>
<item>
 <title>Closures in Ruby, Part I</title>
 <link>http://thoughtshapes.com/node/77</link>
 <description>&lt;p&gt;Closures are a powerful concept in some languages - a powerful tool in others. In my mind a &lt;i&gt;tool&lt;/i&gt; is something I can ask for by name - as in, &quot;I&#039;d like a reciprocating saw, please.&quot; Languages where closures are truly a tool include Lisp, Python, Ruby, among others. For the time being I will use Ruby to discuss closures - although a switch over to Lisp may be necessary.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://thoughtshapes.com/node/77&quot;&gt;read more&lt;/a&gt;&lt;/p&gt;</description>
 <comments>http://thoughtshapes.com/node/77#comments</comments>
 <category domain="http://thoughtshapes.com/taxonomy/term/24">Ruby</category>
 <enclosure url="http://thoughtshapes.com/files/closuretest.rb" length="1627" type="text/plain" />
 <pubDate>Thu, 20 Mar 2008 10:11:31 -0400</pubDate>
 <dc:creator>Rjae Easton</dc:creator>
 <guid isPermaLink="false">77 at http://thoughtshapes.com</guid>
</item>
</channel>
</rss>
