<?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: Adding Type Checking to Ruby</title>
	<atom:link href="http://www.codecommit.com/blog/ruby/adding-type-checking-to-ruby/feed" rel="self" type="application/rss+xml" />
	<link>http://www.codecommit.com/blog/ruby/adding-type-checking-to-ruby</link>
	<description>(permanently in beta)</description>
	<lastBuildDate>Sun, 29 Aug 2010 20:01:44 -0700</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Ragmaanir</title>
		<link>http://www.codecommit.com/blog/ruby/adding-type-checking-to-ruby/comment-page-1#comment-4966</link>
		<dc:creator>Ragmaanir</dc:creator>
		<pubDate>Thu, 22 Apr 2010 15:27:25 +0000</pubDate>
		<guid isPermaLink="false">http://www.codecommit.com/blog/ruby/adding-type-checking-to-ruby#comment-4966</guid>
		<description>I have to underline Martin Vahi&#039;s comment. I also have been using ruby for quite some time as well as c++, C#, Java (and i have some experience in Scala, Prolog, Scheme etc). And i also saved a lot of development and debugging time because type checking caught errors as soon as possible so i did not have to spend hours searching for the origin of the errors. I would like to see some extensions to the type checking framework for attributes:

    attr count: Integer, default: 0
    attr name: [Symbol,String]
    attr enabled: Boolean # =&gt; generates method: enabled?
</description>
		<content:encoded><![CDATA[<p>I have to underline Martin Vahi&#8217;s comment. I also have been using ruby for quite some time as well as c++, C#, Java (and i have some experience in Scala, Prolog, Scheme etc). And i also saved a lot of development and debugging time because type checking caught errors as soon as possible so i did not have to spend hours searching for the origin of the errors. I would like to see some extensions to the type checking framework for attributes:</p>
<p>    attr count: Integer, default: 0<br />
    attr name: [Symbol,String]<br />
    attr enabled: Boolean # =&gt; generates method: enabled?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Martin Vahi</title>
		<link>http://www.codecommit.com/blog/ruby/adding-type-checking-to-ruby/comment-page-1#comment-4942</link>
		<dc:creator>Martin Vahi</dc:creator>
		<pubDate>Fri, 26 Feb 2010 23:09:34 +0000</pubDate>
		<guid isPermaLink="false">http://www.codecommit.com/blog/ruby/adding-type-checking-to-ruby#comment-4942</guid>
		<description>As of February 2010 I&#039;ve been using Ruby for a few years, I&#039;ve also worked in Java, Delphi and had C++ as my favorite programming language in the past. I specially loved to do speed optimizations and play with template metaprogramming. (That is to say, I&#039;ve had many &quot;religions&quot;.)  I&#039;m not sure that I have fully understood the main values of duck typing, mainly due to lack of experience with it, but as I have spent about 7 months working with PHP(5) and JavaScript, mostly JavaScript, it seems to me that in practice run-time type checks for simple types like strings, hashtables, arrays, integers, has saved me a lot of time. 

If a method has to receive a string or a hashtable, but due to a typo or my fuzziness receives something else, then it saves considerable amount of development time, if that error has been reported.  On the other hand, in the &quot;duck typing&quot; side I actually &quot;study the duck&quot; more thoroughly in the debug mode. For instance, whether the hashtable/object instance has all of the required fields, whether their values are within the domain, etc. Actually, in the case of my JavaScript code, the type checks for the simple types, string, int, etc., occur only in debug mode. So, I think that the truth relies again somewhere in between. As of February 2010 I think that It&#039;s good to have some type checks, but it should be optional and in &quot;the appropriate place&quot;.

Regards,
Martin (Vahi)</description>
		<content:encoded><![CDATA[<p>As of February 2010 I&#8217;ve been using Ruby for a few years, I&#8217;ve also worked in Java, Delphi and had C++ as my favorite programming language in the past. I specially loved to do speed optimizations and play with template metaprogramming. (That is to say, I&#8217;ve had many &#8220;religions&#8221;.)  I&#8217;m not sure that I have fully understood the main values of duck typing, mainly due to lack of experience with it, but as I have spent about 7 months working with PHP(5) and JavaScript, mostly JavaScript, it seems to me that in practice run-time type checks for simple types like strings, hashtables, arrays, integers, has saved me a lot of time. </p>
<p>If a method has to receive a string or a hashtable, but due to a typo or my fuzziness receives something else, then it saves considerable amount of development time, if that error has been reported.  On the other hand, in the &#8220;duck typing&#8221; side I actually &#8220;study the duck&#8221; more thoroughly in the debug mode. For instance, whether the hashtable/object instance has all of the required fields, whether their values are within the domain, etc. Actually, in the case of my JavaScript code, the type checks for the simple types, string, int, etc., occur only in debug mode. So, I think that the truth relies again somewhere in between. As of February 2010 I think that It&#8217;s good to have some type checks, but it should be optional and in &#8220;the appropriate place&#8221;.</p>
<p>Regards,<br />
Martin (Vahi)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Roger</title>
		<link>http://www.codecommit.com/blog/ruby/adding-type-checking-to-ruby/comment-page-1#comment-4415</link>
		<dc:creator>Roger</dc:creator>
		<pubDate>Tue, 23 Dec 2008 18:27:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.codecommit.com/blog/ruby/adding-type-checking-to-ruby#comment-4415</guid>
		<description>http://74.125.95.132/search?q=cache:_7SQZf5WRQQJ:www.cs.umd.edu/~jfoster/ruby.pdf+ruby+static+parameters+library&amp;hl=en&amp;ct=clnk&amp;cd=2&amp;gl=us
lists an attempt at compile time ruby checking.  That&#039;s cool.</description>
		<content:encoded><![CDATA[<p><a href="http://74.125.95.132/search?q=cache:_7SQZf5WRQQJ:www.cs.umd.edu/~jfoster/ruby.pdf+ruby+static+parameters+library&amp;hl=en&amp;ct=clnk&amp;cd=2&amp;gl=us" rel="nofollow">http://74.125.95.132/search?q=cache:_7SQZf5WRQQJ:www.cs.umd.edu/~jfoster/ruby.pdf+ruby+static+parameters+library&amp;hl=en&amp;ct=clnk&amp;cd=2&amp;gl=us</a><br />
lists an attempt at compile time ruby checking.  That&#8217;s cool.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rich Morin</title>
		<link>http://www.codecommit.com/blog/ruby/adding-type-checking-to-ruby/comment-page-1#comment-3503</link>
		<dc:creator>Rich Morin</dc:creator>
		<pubDate>Sun, 20 Apr 2008 06:25:25 +0000</pubDate>
		<guid isPermaLink="false">http://www.codecommit.com/blog/ruby/adding-type-checking-to-ruby#comment-3503</guid>
		<description>Jorge Ortiz sez: Making a type check for every method call sounds like massive overhead.

It certainly is, but there&#039;s no reason that the checks have to be done in production code. For example, it&#039;s quite possible to move the assertions off to a separate &quot;library&quot;, running them only when the code is being tested, etc.  I have a proof of concept for this approach at http://cfcl.com/twiki/bin/view/Projects/Spect/UC_Method_Calls</description>
		<content:encoded><![CDATA[<p>Jorge Ortiz sez: Making a type check for every method call sounds like massive overhead.</p>
<p>It certainly is, but there&#8217;s no reason that the checks have to be done in production code. For example, it&#8217;s quite possible to move the assertions off to a separate &#8220;library&#8221;, running them only when the code is being tested, etc.  I have a proof of concept for this approach at <a href="http://cfcl.com/twiki/bin/view/Projects/Spect/UC_Method_Calls" rel="nofollow">http://cfcl.com/twiki/bin/view/Projects/Spect/UC_Method_Calls</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Cedric</title>
		<link>http://www.codecommit.com/blog/ruby/adding-type-checking-to-ruby/comment-page-1#comment-2942</link>
		<dc:creator>Cedric</dc:creator>
		<pubDate>Tue, 12 Feb 2008 12:56:45 +0000</pubDate>
		<guid isPermaLink="false">http://www.codecommit.com/blog/ruby/adding-type-checking-to-ruby#comment-2942</guid>
		<description>Erkki, you are completely right:  most of the refactorings we are used to with statically typed languages *cannot* be done reliably with dynamically typed languages (even Smalltalk).  Take a look at this article for more details:

http://beust.com/weblog/archives/000414.html

-- 
Cedric</description>
		<content:encoded><![CDATA[<p>Erkki, you are completely right:  most of the refactorings we are used to with statically typed languages *cannot* be done reliably with dynamically typed languages (even Smalltalk).  Take a look at this article for more details:</p>
<p><a href="http://beust.com/weblog/archives/000414.html" rel="nofollow">http://beust.com/weblog/archives/000414.html</a></p>
<p>&#8211;<br />
Cedric</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Daniel Spiewak</title>
		<link>http://www.codecommit.com/blog/ruby/adding-type-checking-to-ruby/comment-page-1#comment-2917</link>
		<dc:creator>Daniel Spiewak</dc:creator>
		<pubDate>Sun, 10 Feb 2008 19:18:36 +0000</pubDate>
		<guid isPermaLink="false">http://www.codecommit.com/blog/ruby/adding-type-checking-to-ruby#comment-2917</guid>
		<description>It&#039;s very strange that this wouldn&#039;t work right.  The only thing I can think of is the fact that RDT (which is what RadRails is based on) is an incredibly buggy creation.  I have a massive amount of respect for Chris and what he does, but RDT just isn&#039;t that stable.  I&#039;d be interested to see how the experimental refactoring in DLTK (not even turned on by default IIRC) or the refactorings in NetBeans Ruby stack up.  They&#039;re all using the JRuby AST parser and roughly the same refactoring code (at least in the case of DLTK and RDT), so we should be able to see where the weakness actually is.</description>
		<content:encoded><![CDATA[<p>It&#8217;s very strange that this wouldn&#8217;t work right.  The only thing I can think of is the fact that RDT (which is what RadRails is based on) is an incredibly buggy creation.  I have a massive amount of respect for Chris and what he does, but RDT just isn&#8217;t that stable.  I&#8217;d be interested to see how the experimental refactoring in DLTK (not even turned on by default IIRC) or the refactorings in NetBeans Ruby stack up.  They&#8217;re all using the JRuby AST parser and roughly the same refactoring code (at least in the case of DLTK and RDT), so we should be able to see where the weakness actually is.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Erkki Lindpere</title>
		<link>http://www.codecommit.com/blog/ruby/adding-type-checking-to-ruby/comment-page-1#comment-2916</link>
		<dc:creator>Erkki Lindpere</dc:creator>
		<pubDate>Sun, 10 Feb 2008 12:39:11 +0000</pubDate>
		<guid isPermaLink="false">http://www.codecommit.com/blog/ruby/adding-type-checking-to-ruby#comment-2916</guid>
		<description>Ok, I haven&#039;t really used Ruby beyond going through a few tutorials some time ago, and looking at scripts other people wrote, but I just downloaded Aptana RadRails and created a couple of simple classes to see how well the rename works. It could be that I&#039;m not using Ruby &quot;correctly&quot;, but my simple experiment shows that it doesn&#039;t work very well. I created three files:

----- &#039;dog.rb&#039;
class Dog
  def makeSound
    return &quot;woof!&quot;
  end
end

----- &#039;cat.rb&#039;
class Cat
  def makeSound
    &quot;meow&quot;
  end
end

----- &#039;animal_sounder.rb&#039;
require &#039;dog.rb&#039;
require &#039;cat.rb&#039;

class AnimalSounder
  def main
    animal = Dog.new
    puts animal.makeSound
    animal = Cat.new
    puts animal.makeSound
  end
end

(AnimalSounder.new).main
-----

Now, if I rename Cat&#039;s makeSound or Dog&#039;s makeSound to &quot;makeNoise&quot;, this isn&#039;t picked up in the other files.

If I move Cat into the same file as AnimalSounder, then renaming Cat.makeSound does suggest that &quot;animal.makeSound&quot; in AnimalSounder be renamed, in both cases (for dog and cat)! Then I can *manually* select the case where I want it to be renamed.</description>
		<content:encoded><![CDATA[<p>Ok, I haven&#8217;t really used Ruby beyond going through a few tutorials some time ago, and looking at scripts other people wrote, but I just downloaded Aptana RadRails and created a couple of simple classes to see how well the rename works. It could be that I&#8217;m not using Ruby &#8220;correctly&#8221;, but my simple experiment shows that it doesn&#8217;t work very well. I created three files:</p>
<p>&#8212;&#8211; &#8216;dog.rb&#8217;<br />
class Dog<br />
  def makeSound<br />
    return &#8220;woof!&#8221;<br />
  end<br />
end</p>
<p>&#8212;&#8211; &#8216;cat.rb&#8217;<br />
class Cat<br />
  def makeSound<br />
    &#8220;meow&#8221;<br />
  end<br />
end</p>
<p>&#8212;&#8211; &#8216;animal_sounder.rb&#8217;<br />
require &#8216;dog.rb&#8217;<br />
require &#8216;cat.rb&#8217;</p>
<p>class AnimalSounder<br />
  def main<br />
    animal = Dog.new<br />
    puts animal.makeSound<br />
    animal = Cat.new<br />
    puts animal.makeSound<br />
  end<br />
end</p>
<p>(AnimalSounder.new).main<br />
&#8212;&#8211;</p>
<p>Now, if I rename Cat&#8217;s makeSound or Dog&#8217;s makeSound to &#8220;makeNoise&#8221;, this isn&#8217;t picked up in the other files.</p>
<p>If I move Cat into the same file as AnimalSounder, then renaming Cat.makeSound does suggest that &#8220;animal.makeSound&#8221; in AnimalSounder be renamed, in both cases (for dog and cat)! Then I can *manually* select the case where I want it to be renamed.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Daniel Spiewak</title>
		<link>http://www.codecommit.com/blog/ruby/adding-type-checking-to-ruby/comment-page-1#comment-2907</link>
		<dc:creator>Daniel Spiewak</dc:creator>
		<pubDate>Fri, 08 Feb 2008 15:05:17 +0000</pubDate>
		<guid isPermaLink="false">http://www.codecommit.com/blog/ruby/adding-type-checking-to-ruby#comment-2907</guid>
		<description>Both NetBeans Ruby and Aptana RadRails offer rudimentary (by Java standards) refactorings including method/field/class rename, extract method, etc (http://r2.ifs.hsr.ch/trac/wiki/TheRefactoringList).  Obviously they can&#039;t hit invocations through mechanisms like eval() and send(), but that would fall under the &quot;reflective&quot; category that you wouldn&#039;t expect to be refactorable.</description>
		<content:encoded><![CDATA[<p>Both NetBeans Ruby and Aptana RadRails offer rudimentary (by Java standards) refactorings including method/field/class rename, extract method, etc (<a href="http://r2.ifs.hsr.ch/trac/wiki/TheRefactoringList" rel="nofollow">http://r2.ifs.hsr.ch/trac/wiki/TheRefactoringList</a>).  Obviously they can&#8217;t hit invocations through mechanisms like eval() and send(), but that would fall under the &#8220;reflective&#8221; category that you wouldn&#8217;t expect to be refactorable.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Erkki Lindpere</title>
		<link>http://www.codecommit.com/blog/ruby/adding-type-checking-to-ruby/comment-page-1#comment-2906</link>
		<dc:creator>Erkki Lindpere</dc:creator>
		<pubDate>Fri, 08 Feb 2008 14:56:10 +0000</pubDate>
		<guid isPermaLink="false">http://www.codecommit.com/blog/ruby/adding-type-checking-to-ruby#comment-2906</guid>
		<description>@Pazu

Refactoring nothing to do with static typing? Lets take the most basic refactoring there is: renaming a method. This is fully automatic in any modern Java IDE and takes only a few seconds even if the method has hundreds or even thousands of uses. And the ability to do this so easily actually gives the code a more &quot;dynamic&quot; property in the sense that it can changed easily (unless you have already released it to clients as API). Resistance to change is minimized and the changeability of code is incredibly important in my opinion. But in my experience, some Java programmers still aren&#039;t fully accustomed to this power and still resist changes to code.

Can a Ruby IDE do the same and guarantee that all the possible uses of the method, or any code that relies on that method, will be renamed correctly? Somewhy, I don&#039;t think so, but if I&#039;m wrong, then I raise my hat to the IDE developers. (of course, even in Java, use of the method by reflection isn&#039;t refactorable [to my knowledge no IDE tries that], but that is rare anyway.)

I&#039;ve seen a Ruby user claim that renames aren&#039;t necessary in Ruby because the code is so good from the start -- I call bullshit on that, all code needs to evolve and change and no one creates perfection from the start (or at all, actually).</description>
		<content:encoded><![CDATA[<p>@Pazu</p>
<p>Refactoring nothing to do with static typing? Lets take the most basic refactoring there is: renaming a method. This is fully automatic in any modern Java IDE and takes only a few seconds even if the method has hundreds or even thousands of uses. And the ability to do this so easily actually gives the code a more &#8220;dynamic&#8221; property in the sense that it can changed easily (unless you have already released it to clients as API). Resistance to change is minimized and the changeability of code is incredibly important in my opinion. But in my experience, some Java programmers still aren&#8217;t fully accustomed to this power and still resist changes to code.</p>
<p>Can a Ruby IDE do the same and guarantee that all the possible uses of the method, or any code that relies on that method, will be renamed correctly? Somewhy, I don&#8217;t think so, but if I&#8217;m wrong, then I raise my hat to the IDE developers. (of course, even in Java, use of the method by reflection isn&#8217;t refactorable [to my knowledge no IDE tries that], but that is rare anyway.)</p>
<p>I&#8217;ve seen a Ruby user claim that renames aren&#8217;t necessary in Ruby because the code is so good from the start &#8212; I call bullshit on that, all code needs to evolve and change and no one creates perfection from the start (or at all, actually).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jorge Ortiz</title>
		<link>http://www.codecommit.com/blog/ruby/adding-type-checking-to-ruby/comment-page-1#comment-2904</link>
		<dc:creator>Jorge Ortiz</dc:creator>
		<pubDate>Fri, 08 Feb 2008 10:40:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.codecommit.com/blog/ruby/adding-type-checking-to-ruby#comment-2904</guid>
		<description>This doesn&#039;t provide anywhere near the power of a sophisticated static type checking system. For one, you don&#039;t have any type information about the return values of functions. In your &quot;duck typing&quot; example, you know that the &quot;value&quot; parameter responds to the &quot;name&quot; method, but you have no way of knowing what type is returned by &quot;name&quot;. How do you even know that the result of &quot;name&quot; can be concatenated to a String?

Second, even with this type checking framework, you -still- need to do extensive unit testing to prevent type errors. Unless you want your production system to throw a runtime type error and crash.

Third, type checking is done at -every- method call? A good static type system checks types once... at compile-time. Making a type check for every method call sounds like massive overhead.

Overall, I think, you gain little (better runtime error messages) and lose much (worse performance, extra verbosity). For writing Ruby code, I&#039;d stick with unchecked dynamic types.</description>
		<content:encoded><![CDATA[<p>This doesn&#8217;t provide anywhere near the power of a sophisticated static type checking system. For one, you don&#8217;t have any type information about the return values of functions. In your &#8220;duck typing&#8221; example, you know that the &#8220;value&#8221; parameter responds to the &#8220;name&#8221; method, but you have no way of knowing what type is returned by &#8220;name&#8221;. How do you even know that the result of &#8220;name&#8221; can be concatenated to a String?</p>
<p>Second, even with this type checking framework, you -still- need to do extensive unit testing to prevent type errors. Unless you want your production system to throw a runtime type error and crash.</p>
<p>Third, type checking is done at -every- method call? A good static type system checks types once&#8230; at compile-time. Making a type check for every method call sounds like massive overhead.</p>
<p>Overall, I think, you gain little (better runtime error messages) and lose much (worse performance, extra verbosity). For writing Ruby code, I&#8217;d stick with unchecked dynamic types.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
