<?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"
	>
<channel>
	<title>Comments on: type(Duck)&#8217;ing: On Duck vs. Static Typing</title>
	<atom:link href="http://jessenoller.com/2007/05/30/typeducking-on-duck-vs-static-typing/feed/" rel="self" type="application/rss+xml" />
	<link>http://jessenoller.com/2007/05/30/typeducking-on-duck-vs-static-typing/</link>
	<description>python, programming and other things</description>
	<pubDate>Wed, 20 Aug 2008 08:06:55 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
		<item>
		<title>By: jessenoller.com - Duck typing + Wikipedia.</title>
		<link>http://jessenoller.com/2007/05/30/typeducking-on-duck-vs-static-typing/#comment-2510</link>
		<dc:creator>jessenoller.com - Duck typing + Wikipedia.</dc:creator>
		<pubDate>Wed, 22 Aug 2007 13:15:09 +0000</pubDate>
		<guid isPermaLink="false">http://jessenoller.com/2007/05/30/typeducking-on-duck-vs-static-typing/#comment-2510</guid>
		<description>[...] both - and after your done laughing, take a look at my previous articles (rants?) on the subject - typeducking-on-duck-vs-static-typing and [...]</description>
		<content:encoded><![CDATA[<p>[...] both - and after your done laughing, take a look at my previous articles (rants?) on the subject - typeducking-on-duck-vs-static-typing and [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jessenoller.com - Schrödinger&#8217;s Type (is a namespace a box?)</title>
		<link>http://jessenoller.com/2007/05/30/typeducking-on-duck-vs-static-typing/#comment-73</link>
		<dc:creator>jessenoller.com - Schrödinger&#8217;s Type (is a namespace a box?)</dc:creator>
		<pubDate>Fri, 01 Jun 2007 13:58:32 +0000</pubDate>
		<guid isPermaLink="false">http://jessenoller.com/2007/05/30/typeducking-on-duck-vs-static-typing/#comment-73</guid>
		<description>[...] "type(Duck)’ing: On Duck vs. Static Typing" post received some minor attention, but as with all things of an obsessive nature, I wanted to [...]</description>
		<content:encoded><![CDATA[<p>[...] &#8220;type(Duck)’ing: On Duck vs. Static Typing&#8221; post received some minor attention, but as with all things of an obsessive nature, I wanted to [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: nes</title>
		<link>http://jessenoller.com/2007/05/30/typeducking-on-duck-vs-static-typing/#comment-71</link>
		<dc:creator>nes</dc:creator>
		<pubDate>Thu, 31 May 2007 14:55:42 +0000</pubDate>
		<guid isPermaLink="false">http://jessenoller.com/2007/05/30/typeducking-on-duck-vs-static-typing/#comment-71</guid>
		<description>:&#62; Ideally, IMO, two messages with the same name should have
:&#62; the same meaning but possibly different implementations.
:&#62; Of course, "meaning" is somewhat relative, but the notion
:&#62; that two messages with the same name should have the same
:&#62; "meaning" is very useful.

:Like clothes.launder() vs money.launder(), or shape.draw() vs blood.draw(),
:or matrix.norm() vs hi.norm() ?  I'm afraid English thrives on puns,
:and the same word routinely means radically different things across
:application areas.  Therefore, to insist that a word have "one true meaning"
:in a programming language is insisting that the language cater to one true
:application domain.

http://groups.google.com/group/comp.lang.python/browse_thread/thread/c12d4b19d0f42f05/3acb79797dd3d3fd


Most people are pretty good at guessing the semantic of words depending on the context used. Having to define the precise semantics of every word each time it gets used sounds pretty verbose to me. Of course this might potentially create some bug (and is source material for jokes by comedians). BTW, Java interfaces don't even allow to implement methods of different domains with the same name for a class, so Java interfaces don't even solve the problem. I wonder how Haskell handles that.</description>
		<content:encoded><![CDATA[<p>:&gt; Ideally, IMO, two messages with the same name should have<br />
:&gt; the same meaning but possibly different implementations.<br />
:&gt; Of course, &#8220;meaning&#8221; is somewhat relative, but the notion<br />
:&gt; that two messages with the same name should have the same<br />
:&gt; &#8220;meaning&#8221; is very useful.</p>
<p>:Like clothes.launder() vs money.launder(), or shape.draw() vs blood.draw(),<br />
:or matrix.norm() vs hi.norm() ?  I&#8217;m afraid English thrives on puns,<br />
:and the same word routinely means radically different things across<br />
:application areas.  Therefore, to insist that a word have &#8220;one true meaning&#8221;<br />
:in a programming language is insisting that the language cater to one true<br />
:application domain.</p>
<p><a href="http://groups.google.com/group/comp.lang.python/browse_thread/thread/c12d4b19d0f42f05/3acb79797dd3d3fd" rel="nofollow">http://groups.google.com/group/comp.lang.python/browse_thread/thread/c12d4b19d0f42f05/3acb79797dd3d3fd</a></p>
<p>Most people are pretty good at guessing the semantic of words depending on the context used. Having to define the precise semantics of every word each time it gets used sounds pretty verbose to me. Of course this might potentially create some bug (and is source material for jokes by comedians). BTW, Java interfaces don&#8217;t even allow to implement methods of different domains with the same name for a class, so Java interfaces don&#8217;t even solve the problem. I wonder how Haskell handles that.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Paul Boddie</title>
		<link>http://jessenoller.com/2007/05/30/typeducking-on-duck-vs-static-typing/#comment-69</link>
		<dc:creator>Paul Boddie</dc:creator>
		<pubDate>Thu, 31 May 2007 11:10:21 +0000</pubDate>
		<guid isPermaLink="false">http://jessenoller.com/2007/05/30/typeducking-on-duck-vs-static-typing/#comment-69</guid>
		<description>"The problem is that someone else can just as well have created a “quack” method on the dog which does something completely different (perhaps a QUick Answer to A Cat: Kill)."

Yes, people might define perverse methods which have the same names as normal ones, and there is a possibility of method name "collisions", but this kind of problem is addressed in many other fields within computing (as well as being a general disambiguation problem), and the solution doesn't have to involve rigid interface hierarchies.</description>
		<content:encoded><![CDATA[<p>&#8220;The problem is that someone else can just as well have created a “quack” method on the dog which does something completely different (perhaps a QUick Answer to A Cat: Kill).&#8221;</p>
<p>Yes, people might define perverse methods which have the same names as normal ones, and there is a possibility of method name &#8220;collisions&#8221;, but this kind of problem is addressed in many other fields within computing (as well as being a general disambiguation problem), and the solution doesn&#8217;t have to involve rigid interface hierarchies.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Henry Story</title>
		<link>http://jessenoller.com/2007/05/30/typeducking-on-duck-vs-static-typing/#comment-68</link>
		<dc:creator>Henry Story</dc:creator>
		<pubDate>Thu, 31 May 2007 08:26:58 +0000</pubDate>
		<guid isPermaLink="false">http://jessenoller.com/2007/05/30/typeducking-on-duck-vs-static-typing/#comment-68</guid>
		<description>"If Dog’s Quack() method does not in fact, Quack() then it is not a valid quack. Dog() by it’s very nature has violated the contract for anyone who needs a Duck() but gets a Dog()"

Well not really. As I see in most of these languages nobody uses full namespaced method comparison to identify the method. If they did then you would be right, for the reasons I pointed to in my orignal article: your namespaced method is close to being a URI for it.

But in fact these languages don't do this. they just look to see that there is a method that is named "Quack". If there is it gets called as if it was clear that was it means was the sound. But why could a dog not have a "quack" method that meant to kill a cat? There would be no interface broken here. Just a clash of words, and we have those a lot in the english language. Things such as "bank" (the place you deposit your money at) and "bank" of a river... We disambiguate english because we take context into account, just as a programmer makes sure that when he gives objects to a method that will duck type on "quack" he makes sure never to give the method objects where "quack" means something else. Notice how this has trouble scaling though.

Anyway, I would be glad to be shown to be wrong. I just looked up a book on Ruby, and that confirmed my thinking. Do you have a pointer to a piece of code that could resolve the issue?</description>
		<content:encoded><![CDATA[<p>&#8220;If Dog’s Quack() method does not in fact, Quack() then it is not a valid quack. Dog() by it’s very nature has violated the contract for anyone who needs a Duck() but gets a Dog()&#8221;</p>
<p>Well not really. As I see in most of these languages nobody uses full namespaced method comparison to identify the method. If they did then you would be right, for the reasons I pointed to in my orignal article: your namespaced method is close to being a URI for it.</p>
<p>But in fact these languages don&#8217;t do this. they just look to see that there is a method that is named &#8220;Quack&#8221;. If there is it gets called as if it was clear that was it means was the sound. But why could a dog not have a &#8220;quack&#8221; method that meant to kill a cat? There would be no interface broken here. Just a clash of words, and we have those a lot in the english language. Things such as &#8220;bank&#8221; (the place you deposit your money at) and &#8220;bank&#8221; of a river&#8230; We disambiguate english because we take context into account, just as a programmer makes sure that when he gives objects to a method that will duck type on &#8220;quack&#8221; he makes sure never to give the method objects where &#8220;quack&#8221; means something else. Notice how this has trouble scaling though.</p>
<p>Anyway, I would be glad to be shown to be wrong. I just looked up a book on Ruby, and that confirmed my thinking. Do you have a pointer to a piece of code that could resolve the issue?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joe</title>
		<link>http://jessenoller.com/2007/05/30/typeducking-on-duck-vs-static-typing/#comment-66</link>
		<dc:creator>Joe</dc:creator>
		<pubDate>Thu, 31 May 2007 07:59:19 +0000</pubDate>
		<guid isPermaLink="false">http://jessenoller.com/2007/05/30/typeducking-on-duck-vs-static-typing/#comment-66</guid>
		<description>&lt;a href="http://lambda-the-ultimate.org/node/100" rel="nofollow"&gt;Why type systems are interesting&lt;/a&gt;</description>
		<content:encoded><![CDATA[<p><a href="http://lambda-the-ultimate.org/node/100" rel="nofollow">Why type systems are interesting</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jake</title>
		<link>http://jessenoller.com/2007/05/30/typeducking-on-duck-vs-static-typing/#comment-65</link>
		<dc:creator>Jake</dc:creator>
		<pubDate>Thu, 31 May 2007 06:05:44 +0000</pubDate>
		<guid isPermaLink="false">http://jessenoller.com/2007/05/30/typeducking-on-duck-vs-static-typing/#comment-65</guid>
		<description>I've been reading all of these Static/Duck arguments, and I've worked with both Rails and C++. I don't mind working with either systems, but when I stop and think about duck typing it just seems imprecise. I don't like relying on the name I happen to give a series of methods to define what it is.

Especially when working w/ lots of people it seems like a good idea to be able to define interfaces strictly by setting up a Duck abstract class and having everybody that supports the duck interface inheriting from it rather than relying on people calling things the same thing. It seems like we're taking a step back to have to manually write tests to check things that used to be done for us automatically.</description>
		<content:encoded><![CDATA[<p>I&#8217;ve been reading all of these Static/Duck arguments, and I&#8217;ve worked with both Rails and C++. I don&#8217;t mind working with either systems, but when I stop and think about duck typing it just seems imprecise. I don&#8217;t like relying on the name I happen to give a series of methods to define what it is.</p>
<p>Especially when working w/ lots of people it seems like a good idea to be able to define interfaces strictly by setting up a Duck abstract class and having everybody that supports the duck interface inheriting from it rather than relying on people calling things the same thing. It seems like we&#8217;re taking a step back to have to manually write tests to check things that used to be done for us automatically.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jonathan Allen</title>
		<link>http://jessenoller.com/2007/05/30/typeducking-on-duck-vs-static-typing/#comment-64</link>
		<dc:creator>Jonathan Allen</dc:creator>
		<pubDate>Thu, 31 May 2007 03:19:59 +0000</pubDate>
		<guid isPermaLink="false">http://jessenoller.com/2007/05/30/typeducking-on-duck-vs-static-typing/#comment-64</guid>
		<description>The problem I see with duck typing is that it seems to be really, really easy to break compatibility. 

Lets say I add a Swim method to my Duck class. Then I change the move method to call Swim instead of Fly under certain circumstances.

If I was using an IDuck interface, then I would get a compiler error on the Dog(Duck) class and know I needed to fix it.

If I am just using Duck, I wouldn't know there was a problem with Dog(Duck) until either the unit tests catch it or, more likely, it crashes up at runtime.</description>
		<content:encoded><![CDATA[<p>The problem I see with duck typing is that it seems to be really, really easy to break compatibility. </p>
<p>Lets say I add a Swim method to my Duck class. Then I change the move method to call Swim instead of Fly under certain circumstances.</p>
<p>If I was using an IDuck interface, then I would get a compiler error on the Dog(Duck) class and know I needed to fix it.</p>
<p>If I am just using Duck, I wouldn&#8217;t know there was a problem with Dog(Duck) until either the unit tests catch it or, more likely, it crashes up at runtime.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jesse</title>
		<link>http://jessenoller.com/2007/05/30/typeducking-on-duck-vs-static-typing/#comment-63</link>
		<dc:creator>jesse</dc:creator>
		<pubDate>Thu, 31 May 2007 01:46:48 +0000</pubDate>
		<guid isPermaLink="false">http://jessenoller.com/2007/05/30/typeducking-on-duck-vs-static-typing/#comment-63</guid>
		<description>@Henry: Obviously if you had Dog(Duck) and both had Quack() there would be no string comparison - it's resolved simply by the fact that Dog inherited Duck's methods, and then over wrote the original Quack.

If Dog's Quack() method does not in fact, Quack() then it is not a valid quack. Dog() by it's very nature has violated the contract for anyone who needs a Duck() but gets a Dog()

For example, in python - you have __getitem__(): If I created a class/object (class myob(object)) and over wrote __getitem__() to say, parse an XML stream and make the bios beep instead of simply returning a value from the local namespace - I am in violation of a very simple and basic contract within the language.

Name spaced methods are exactly that within Python. pkg.module.file.method() is a clear enough name space. Proper python module structure means that given your example, we should have:

animals.dog.sounds.quack()

animals.dog.actions.quack()

And so on. Which most python programs are smart enough to do - that's the glorious nature of namespaces. If you have 14 Quack methods, they should each be contained within the proper namespace. 

Man I have to get a threaded comment system</description>
		<content:encoded><![CDATA[<p>@Henry: Obviously if you had Dog(Duck) and both had Quack() there would be no string comparison - it&#8217;s resolved simply by the fact that Dog inherited Duck&#8217;s methods, and then over wrote the original Quack.</p>
<p>If Dog&#8217;s Quack() method does not in fact, Quack() then it is not a valid quack. Dog() by it&#8217;s very nature has violated the contract for anyone who needs a Duck() but gets a Dog()</p>
<p>For example, in python - you have __getitem__(): If I created a class/object (class myob(object)) and over wrote __getitem__() to say, parse an XML stream and make the bios beep instead of simply returning a value from the local namespace - I am in violation of a very simple and basic contract within the language.</p>
<p>Name spaced methods are exactly that within Python. pkg.module.file.method() is a clear enough name space. Proper python module structure means that given your example, we should have:</p>
<p>animals.dog.sounds.quack()</p>
<p>animals.dog.actions.quack()</p>
<p>And so on. Which most python programs are smart enough to do - that&#8217;s the glorious nature of namespaces. If you have 14 Quack methods, they should each be contained within the proper namespace. </p>
<p>Man I have to get a threaded comment system</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Henry Story</title>
		<link>http://jessenoller.com/2007/05/30/typeducking-on-duck-vs-static-typing/#comment-62</link>
		<dc:creator>Henry Story</dc:creator>
		<pubDate>Thu, 31 May 2007 01:36:12 +0000</pubDate>
		<guid isPermaLink="false">http://jessenoller.com/2007/05/30/typeducking-on-duck-vs-static-typing/#comment-62</guid>
		<description>Thanks for mentioning my article "Duck Typing done right".

The original point of that article was, as you repeat above, that duck typing is implemented in many languages as just simple string comparison. So your 
dog.quack() example, is said to implement the Duck interface just because both contain the "quack" methods. The problem is that someone else can just as well have created a "quack" method on the dog which does something completely different (perhaps a QUick Answer to A Cat: Kill). The fact that two strings are the same does not indicate they mean the same thing. For this you would need namespaced methods at the least. Then you could distinguish between animal.sound.quack() and animal.action.quack() perhaps.  This would give your program a lot more generality already: it would mesh better with wider libraries, and depend less on subtle contextual knowledge of the code base. You can then see how going with full fledged URIs gives you the largest scalability for exchanging and meshing information.</description>
		<content:encoded><![CDATA[<p>Thanks for mentioning my article &#8220;Duck Typing done right&#8221;.</p>
<p>The original point of that article was, as you repeat above, that duck typing is implemented in many languages as just simple string comparison. So your<br />
dog.quack() example, is said to implement the Duck interface just because both contain the &#8220;quack&#8221; methods. The problem is that someone else can just as well have created a &#8220;quack&#8221; method on the dog which does something completely different (perhaps a QUick Answer to A Cat: Kill). The fact that two strings are the same does not indicate they mean the same thing. For this you would need namespaced methods at the least. Then you could distinguish between animal.sound.quack() and animal.action.quack() perhaps.  This would give your program a lot more generality already: it would mesh better with wider libraries, and depend less on subtle contextual knowledge of the code base. You can then see how going with full fledged URIs gives you the largest scalability for exchanging and meshing information.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
