<?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: Tag oop</title>
    <link>http://talklikeaduck.denhaven2.com/articles/tag/oop</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>In Ruby, it's not the dog, it's the tricks!</description>
    <item>
      <title>About me</title>
      <description>&lt;p&gt;For those who don&amp;#8217;t want to read a lot, or dont care too much, here&amp;#8217;s the executive summary:&lt;/p&gt;


&lt;ul&gt;
&lt;li&gt;I&amp;#8217;m a long time object programmer.&lt;/li&gt;
&lt;li&gt;I worked for &lt;span class="caps"&gt;IBM&lt;/span&gt; for 31 years.&lt;/li&gt;
&lt;li&gt;I was one of the early adopters/advocates of Smalltalk in &lt;span class="caps"&gt;IBM&lt;/span&gt;.&lt;/li&gt;
&lt;li&gt;I&amp;#8217;ve done a &lt;b&gt;lot&lt;/b&gt; of Smalltalk.
&lt;li&gt;I&amp;#8217;ve done a lot of standards work.&lt;/li&gt;
&lt;li&gt;I&amp;#8217;ve done a lot of Java.&lt;/li&gt;
&lt;li&gt;I&amp;#8217;m now free of &lt;span class="caps"&gt;IBM&lt;/span&gt; and Java, and I&amp;#8217;m learning to love Ruby.&lt;/li&gt;
&lt;/ul&gt;

	&lt;p&gt;As a result of all of the above I&amp;#8217;ve developed lots of strong opinions, weakly held, which I&amp;#8217;d like to share.&lt;/p&gt;


	&lt;p&gt;Now for those with the stamina, some more details on my personal journey&amp;#8230;&lt;/p&gt;


&lt;h1&gt;&lt;span class="caps"&gt;IBM&lt;/span&gt; Research &amp;#8211; Smalltalk and ClassC&lt;/h1&gt;

	&lt;p&gt;My early &lt;span class="caps"&gt;IBM&lt;/span&gt; career gave me a lot of experience with developing software.  One of the things which struck me was how, despite its name, most software was &lt;i&gt;hard&lt;/i&gt;. Hard to develop in the first place, and harder to change to adapt to new requirements.&lt;/p&gt;


	&lt;p&gt;Like many others, I first became aware of Smalltalk when Byte magazine published a special issue on the langage in 1981. I led a small team at &lt;span class="caps"&gt;IBM&lt;/span&gt; Watson Research which developed a language called ClassC which was inspired by that Byte issue, and added Smalltalk message sending to C, it was similar in concept, but not in syntax to Brad Cox&amp;#8217;s Objective-C.  We found out about Objective-C after we&amp;#8217;d already done our worst. ClassC got some use for internal projects in &lt;span class="caps"&gt;IBM&lt;/span&gt; after I moved to a new &lt;span class="caps"&gt;IBM&lt;/span&gt; development lab in Cary, NC in 1984.&lt;/p&gt;


	&lt;p&gt;While I was working on ClassC, the late David N. Smith was dealing with the lawyers at &lt;span class="caps"&gt;IBM&lt;/span&gt; Research, Xerox, and UC Berkeley to get Smalltalk-80 into research.  Dave and I became good friends, along with other folks in the &lt;span class="caps"&gt;IBM&lt;/span&gt; Research User Interface Institute like Dave&amp;#8217;s &amp;#8220;sidekick,&amp;#8221; the late Jerry Archibald, and John T. Richards, and we formed an OO-Smalltalk cadre within &lt;span class="caps"&gt;IBM&lt;/span&gt;. These three were also key participants in the birth of the &lt;span class="caps"&gt;ACM OOPSLA&lt;/span&gt; conference.  Although I personally missed the first &lt;span class="caps"&gt;OOPSLA&lt;/span&gt;, I was a steady participant for the first decade or so, moderating several panel discussions, participating in workshops, and serving on the commitee for &lt;span class="caps"&gt;OOPSLA&lt;/span&gt; &amp;#8216;93.&lt;/p&gt;


	&lt;p&gt;One of the advantages of being part of the &lt;span class="caps"&gt;OOPSLA&lt;/span&gt; community was being able to forge friendships and working relationships with many very bright people such as Ward Cunningham, Kent Beck, and all four of the &amp;#8220;Gang of Four&amp;#8221;&lt;/p&gt;


&lt;h1&gt;Research to Internal Consultant&lt;/h1&gt;

	&lt;p&gt;After moving to the new lab in Cary, I primarily worked as an inter-divisional consultant, working to drive the requirements of my division, which was writing what was then a new style of applications with graphical direct manipulation user interfaces, into the plans of the Personal Systems division.  This got me into a lot of interesting meetings with not only other &lt;span class="caps"&gt;IBM&lt;/span&gt; folks, but also staff from other companies.  For example, I was present at the shotgun marriage between &lt;span class="caps"&gt;IBM&lt;/span&gt; Boca Raton, &lt;span class="caps"&gt;IBM&lt;/span&gt; Hursley, and Microsoft which led to OS/2.&lt;/p&gt;


	&lt;p&gt;My job had given me the opportunity to visit various companies which &lt;span class="caps"&gt;IBM&lt;/span&gt; was investing in, or considering investing in.  I got to meet people like Jean-Marie Hulot of Expertelligence whose interface builder implemented in Lisp got re-written in Objective-C to become NeXTStep&amp;#8217;s Interface Builder, after he moved to NeXT.  A little later, after &lt;span class="caps"&gt;IBM&lt;/span&gt; had made an investment in NeXT, I got to meet Jean-Marie again along with Steve Jobs.  I got to argue with Tony Williams and Bill Gates and his team over the merits of their approach to the early design of what became &lt;a href="http://en.wikipedia.org/wiki/Component_Object_Model"&gt;&lt;span class="caps"&gt;COM&lt;/span&gt;&lt;/a&gt;, which made the C++ type system a little more dynamic andwith the &lt;span class="caps"&gt;IBM&lt;/span&gt; designers of  &lt;a href="http://en.wikipedia.org/wiki/System_Object_Model"&gt;&lt;span class="caps"&gt;SOM&lt;/span&gt;&lt;/a&gt; which tried to make a statically typed systems more resilient to &amp;#8220;schema&amp;#8221; evolution. Both of these were also (failed) attempts to forge an entente in the &lt;a href=#langWars&gt;&amp;#8220;Language wars&amp;#8221;&lt;/a&gt;&lt;/p&gt;


&lt;h1&gt;Smalltalk and &lt;span class="caps"&gt;IBM&lt;/span&gt;&lt;/h1&gt;

	&lt;p&gt;With the availability of Digitalk&amp;#8217;s SmalltalkV, our little OO cadre started to push for adoption of Smalltalk inside &lt;span class="caps"&gt;IBM&lt;/span&gt;.  One of my biggest contributions was to implement a prototype which extended the Smalltalk/V development environment with a direct-manipulation UI and UI Logic (i.e. controller) tool inspired by the Interface builder, which I dubbed Application Builder.  When SmalltalkV/PM came out, I ported the Application Builder to it.&lt;/p&gt;


	&lt;p&gt;The division&amp;#8217;s mission had been shifting towards building application development tools, so this prototype fit in.  Most of those tools were focused on old big-iron ideas and languages, such as &lt;span class="caps"&gt;ISPF&lt;/span&gt;, and Cobol adapted to personal computers, although targeted for mainframes. I arranged to demonstrate Application Builder to Earl Wheeler, the group executive who oversaw our division and who was in charge of a grand &lt;span class="caps"&gt;IBM&lt;/span&gt; strategy called Systems Application Architecture.  Wheeler seemed quite impressed with the App Builder demo and directed us to turn it into a product, and get Smalltalk to be part of &lt;span class="caps"&gt;SAA&lt;/span&gt;, although he wanted it positioned as a &amp;#8220;generator&amp;#8221; instead of a language for internal &lt;span class="caps"&gt;IBM&lt;/span&gt; political reasons.&lt;/p&gt;


	&lt;p&gt;I took the point on getting Smalltalk into &lt;span class="caps"&gt;IBM&lt;/span&gt; product plans, while others took the prototype and turned it into what became VisualAge.  In my opinion they took the visual programming idea a bit too far, but it did the job of getting Smalltalk out to the world from &lt;span class="caps"&gt;IBM&lt;/span&gt;.  And it resulted in &lt;span class="caps"&gt;IBM&lt;/span&gt; Smalltalk, which was implemented by Object Technology International, a company founded by Dave Thomas, although &lt;b&gt;a different&lt;/b&gt; Dave Thomas than PragDave.  As an aside, what is it about guys named Dave Thomas?  Besides &lt;span class="caps"&gt;OTI&lt;/span&gt;-Dave (who is well-known to the Smalltalk community as Big Dave), and PragDave, we have the Dave Thomas from &lt;span class="caps"&gt;SCTV&lt;/span&gt; and Doug of the McKenzie brothers, and the Dave Thomas who founded Wendy&amp;#8217;s. Two Canadians, and two Americans.&lt;/p&gt;


	&lt;p&gt;I also spent a lot of time talking to &lt;span class="caps"&gt;IBM&lt;/span&gt; customers about how object-oriented approaches, and Smalltalk in particular, could help them solve the problems they were having with software being &lt;i&gt;hard.&lt;/i&gt;&lt;/p&gt;


&lt;h1&gt;Smalltalk Distributed&lt;/h1&gt;
One of my big-idea products was Smalltalk Distributed, a feature for VisualAge/Smalltalk.  I led the development on this one.

	&lt;p&gt;Distributed applications were the rage at the time.  There was another approach to distributing Smalltalk from HP called Distributed Smalltalk, but this was really a Smalltalk implementation of the Object Management Groups &lt;span class="caps"&gt;CORBA&lt;/span&gt;.  Although I had been serving as one of the &lt;span class="caps"&gt;IBM&lt;/span&gt; representatives to &lt;span class="caps"&gt;OMG&lt;/span&gt; (as a Smalltalk expert), I didn&amp;#8217;t find this idea particularly interesting or appealing.  The goal of Smalltalk Distributed was transparent distribution of Smalltalk.  Our approach was to implement a distributed implementation of the Smalltalk object model including object storage and garbage collection, message sending, and distributed threads of execution complete with non-local returns.  This was all done completely in Smalltalk, using lots of tricks in using metaprogramming much like what the wizard Ruby metaprogrammers do.&lt;/p&gt;


	&lt;p&gt;This project was technically interesting, and got some use by customers, but it was most valuable as a learning experience. In retrospect, the transparency was both a neat idea, and a problem.  Putting a black box around a distrubuted system is probably not as good an idea of putting a distributed system together out of black boxes.&lt;/p&gt;


	&lt;p&gt;As a result of the Smalltalk Distributed work, I got to spend a month in Sydney Australia, working with Jeff McAffer of &lt;span class="caps"&gt;OTI&lt;/span&gt;, to re-implement some of the ideas such as the distributed threads in a toolkit for building server applications which he called Surfer (or Server) Smalltalk.  Jeff subsequently became one of the technical leads of the Eclipse project.&lt;/p&gt;


&lt;h1&gt;Smalltalk Standardization&lt;/h1&gt;
Another piece of work I did at &lt;span class="caps"&gt;IBM&lt;/span&gt; was to write a report characterizing the similarities and differences between the various Smalltalk implementations.  At that time these were ParcPlace VisualWorks/Smalltalk-80, Digitalk Smalltalk/V, and &lt;span class="caps"&gt;IBM&lt;/span&gt;/Smalltalk (from &lt;span class="caps"&gt;OTI&lt;/span&gt;).  By focusing on the externals of the classes and taking inheritance out of the picture, I wrote a report called &amp;#8220;Smalltak: A Common Base&amp;#8221; which was in effect a rough draft of a reverse-engineered specification for a common Smalltalk language specification.

	&lt;p&gt;When the various Smalltalk vendors expressed interest in forging a Smalltalk language standard, &lt;span class="caps"&gt;X3J20&lt;/span&gt; was formed to develop an &lt;span class="caps"&gt;ANSI&lt;/span&gt; standard, and the common base document became one of the early inputs.  I became the secretary of &lt;span class="caps"&gt;X3J20&lt;/span&gt;.  The standard was published in January of 1998.&lt;/p&gt;


	&lt;p&gt;&lt;a name="langWars"&gt;&lt;/a&gt;&lt;h1&gt;Language Wars &amp;#8211; Dynamic vs. Static OO&lt;/h1&gt;
Of course back in the days before the turn of the century, there was a great debate raging in the &amp;#8220;object-oriented&amp;#8221; programming community, centered around the value of dynamic languages like Smalltalk vs. static languages like C++.&lt;/p&gt;


	&lt;p&gt;One of the things which always attracted me to Smalltalk was that it placed encapsulation above all else.  As Alan Kay noted in his &lt;a href="http://www.smalltalk.org/smalltalk/TheEarlyHistoryOfSmalltalk_Abstract.html"&gt;memoir about the origins of Smalltalk&lt;/a&gt;, his original conception of object-oriented programming was that software should be composed of objects which were, in effect, little computers themselves, which encapsulated both data and behavior, and hid the implementation of both from  other objects, with objects interacting via sending messages to each other and replying. This uniform object model separates languages like Smalltalk and Ruby from other &amp;#8220;object-oriented&amp;#8221; languages. The various versions of Smalltalk all shared this model, although they varied as to some of the semantics of message sending and reception.&lt;/p&gt;


	&lt;p&gt;The idea of classes and inheritance as a way of factoring &lt;b&gt;implementation&lt;/b&gt; was actually a rather late addition to Smalltalk. Although Kay acknowledges the Simula language, which also lacked classes and inheritance, as one of the influences on his thinking leading up to Smalltalk, it&amp;#8217;s been a popular misconception that the better known Simula-67 was his real influence, when Smalltalk and Simula actually evolved independently.&lt;/p&gt;


	&lt;p&gt;Kay&amp;#8217;s term &amp;#8220;object-oriented&amp;#8221; got hijacked when Peter Wegner published paper entitled &amp;#8220;Dimensions of Object Based Language Design&amp;#8221; at the second &lt;span class="caps"&gt;OOPSLA&lt;/span&gt; conference in which he defined &amp;#8220;object-oriented&amp;#8221; as &amp;#8220;objects + classes + inheritance.&amp;#8221;&lt;/p&gt;


Simula-67 spawned a family of languages which called themselves object-oriented but really used classes and inheritance to create hierarchies of abstract data types. In thes languages which include C++, Oberon, and to a lesser extent, Java became popular bacause they were seen as an easy entree into &amp;#8220;object-orientation&amp;#8221; to programmers who were more comfortable with the notion of programs manipulating data from &amp;#8220;a distance.&amp;#8221;  This led Alan Kay to observe that
&lt;blockquote&gt;It is unfortunate that much of what is called &amp;#8220;object-oriented programming&amp;#8221; today is simply old style programming with fancier constructs. Many programs are loaded with &amp;#8220;assignment-style&amp;#8221; operations now done by more expensive attached procedures.&lt;/blockquote&gt;

	&lt;p&gt;Because of this morphing of the meaning of object-oriented programming I started to use the term &amp;#8220;object programming&amp;#8221; instead.  In 1991, I wrote an &lt;span class="caps"&gt;IBM&lt;/span&gt; Research Report called &lt;a href="/files/TypesFromTheClientsViewpoint.PDF"&gt;&amp;#8220;Types From the Client&amp;#8217;s Viewpoint,&amp;#8221;&lt;/a&gt; which very much relates to duck typing and which got cited in a few places.  It&amp;#8217;s long out of print. So I&amp;#8217;ve scanned a hard copy of a draft, to show my thinking at the time.&lt;/p&gt;


	&lt;p&gt;This debate lives on. It pops up as some of the uneasiness of new Ruby programmers coming from the strong-typing/abstract data type community over thinks like &amp;#8220;duck typing.&amp;#8221;  I plan to explain my thinking about duck typing and other related topics here.&lt;/p&gt;


My point here is, I&amp;#8217;ve got strong opinions about this topic.  While I do believe that the key to wisdom is &lt;a href="http://bobsutton.typepad.com/my_weblog/2006/07/strong_opinions.html"&gt;strong opinions weakly held&lt;/a&gt;, I haven&amp;#8217;t seen any reason, over twenty-something years to let go of &lt;b&gt;this&lt;/b&gt; set of opinions.
&lt;h1&gt;Smalltalk to Java&lt;/h1&gt;
Smalltalk was quite successful with our customers. In some ways it looked like it might  become the Cobol of the 21st Century. 

	&lt;p&gt;Then Java came along.  It gave &lt;i&gt;some&lt;/i&gt; of the benefits of Smalltalk like languages in a package which was appealing to the C++ community, a lot of who were starting to become jaded over how C++  (if they actually used the compiler to do more than compile normal C programs), seemed to make development harder.  It kind of looks like C++, and has a more &amp;#8220;regular&amp;#8221; syntax than Smalltalk, which some found wierd, although to the Smalltalkers it was beautiful in it&amp;#8217;s sparseness and elegance.&lt;/p&gt;


	&lt;p&gt;And &lt;span class="caps"&gt;IBM&lt;/span&gt; made the jump to Java.  Most of us who had been working on Smalltalk were encouraged to start working on Java and Java tools.&lt;/p&gt;


	&lt;p&gt;About this time, I took an assignment to &lt;span class="caps"&gt;OTI&lt;/span&gt;, which had been acquired by &lt;span class="caps"&gt;IBM&lt;/span&gt; Canada as a wholly owned subsidiary.&lt;/p&gt;


	&lt;p&gt;&lt;span class="caps"&gt;OTI&lt;/span&gt; itself was making an investment in Java.  The first step was to turn the &lt;span class="caps"&gt;IBM&lt;/span&gt;/Smalltalk virtual machine into what was called the &lt;span class="caps"&gt;UVM&lt;/span&gt; or Universal Virtual Machine.  This could run both Java and Smalltalk bytecodes.  The Java &amp;#8220;natives,&amp;#8221; the equivalent of extensions in Ruby were written in Smalltalk instead of C. The first VisualAge for Java was written in Smalltalk on this &lt;span class="caps"&gt;UVM&lt;/span&gt;.&lt;/p&gt;


	&lt;p&gt;Eventually, as Java evolved this approach became less tenable.  So &lt;span class="caps"&gt;OTI&lt;/span&gt; started building a new &lt;span class="caps"&gt;IDE&lt;/span&gt; in Java.  Our first use for this was for a system to develop embedded Java applications. &lt;span class="caps"&gt;IBM&lt;/span&gt; was getting very interested in embedded software, which they called &amp;#8220;Pervasive Computing&amp;#8221; and had formed a division called PvC to pursue it.   Embedded applications (e.g. code inside an oscilloscope, or a cell phone) written in Smalltalk was an early focus of &lt;span class="caps"&gt;OTI&lt;/span&gt; predating the relationship with &lt;span class="caps"&gt;IBM&lt;/span&gt;.  Java, which was actually first developed within Sun for such embedded applications, was a natural language to employ.&lt;/p&gt;


	&lt;p&gt;The resulting development was called VisualAge/Micro Environment or &lt;span class="caps"&gt;VAME&lt;/span&gt;.  The &lt;span class="caps"&gt;IDE&lt;/span&gt; and UI design was done at the &lt;span class="caps"&gt;OTI&lt;/span&gt; Zurich lab by a team led by Erich Gamma of the &amp;#8220;Gang of Four.&amp;#8221;  This code was almost completely reworked and combined with Jeff McAffer&amp;#8217;s component run-time architecture to become the basis for Eclipse.&lt;/p&gt;


	&lt;p&gt;After working on &lt;span class="caps"&gt;VAME&lt;/span&gt;, I moved over to a group working with customers on embedded Java applications. We majored on automotive applications, since there were a lot of car companies and suppliers who were interested in telematics systems with sophisticated software.  As a &amp;#8220;standards guy&amp;#8221; I represented &lt;span class="caps"&gt;IBM&lt;/span&gt; in standards organizations such as the &amp;#8220;Vehicle Expert Group&amp;#8221; within &lt;a href="http://www.osgi.org/"&gt;OSGi&lt;/a&gt;&lt;/p&gt;


&lt;h1&gt;Back to the Mother Ship for a while&lt;/h1&gt;

	&lt;p&gt;By this time, &lt;span class="caps"&gt;OTI&lt;/span&gt; was being gradually assimilated into the Borg of &lt;span class="caps"&gt;IBM&lt;/span&gt;.  My group was first. Although we continued to work out of the &lt;span class="caps"&gt;OTI&lt;/span&gt; lab in Raleigh, NC, we now reported to &lt;span class="caps"&gt;IBM&lt;/span&gt; PvC management in Austin Tx.&lt;/p&gt;


	&lt;p&gt;Then because I was &amp;#8220;the standards guy,&amp;#8221; I got re-assigned to the PvC architecture department in Austin which was the home of all the PvC standards guys.&lt;/p&gt;


	&lt;p&gt;Eventually, &lt;span class="caps"&gt;OTI&lt;/span&gt; got &amp;#8220;reorganized&amp;#8221; (i.e. broken up) with various pieces going to different &lt;span class="caps"&gt;IBM&lt;/span&gt; divisions.&lt;/p&gt;


&lt;h1&gt;Free at last&lt;/h1&gt;

	&lt;p&gt;After a year or so of this, and 30+ years of &lt;span class="caps"&gt;IBM&lt;/span&gt;, I realized that I was tired of life in a big corporation.  Since I was old enough to still have a traditional pension, it was time to see what life was like on the outside, so I retired in the spring of 2005, and I&amp;#8217;ve been happily pursuing my own muse, happily learning and working on new projects that I wanted to work on.&lt;/p&gt;


	&lt;p&gt;I&amp;#8217;ve recently discovered Ruby, and as an old Smalltalker, I&amp;#8217;m excited to see what looks like the reincarnation of an old friend.  I&amp;#8217;m starting this blog to see what I can share with the Ruby community based on my experiences.&lt;/p&gt;</description>
      <pubDate>Sat, 29 Jul 2006 09:34:00 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:87bab668-5946-406b-ac56-cbff37acf5ea</guid>
      <author>Rick DeNatale</author>
      <link>http://talklikeaduck.denhaven2.com/articles/2006/07/29/about-me</link>
      <category>ruby</category>
      <category>war_stories</category>
      <category>smalltalk</category>
      <category>memoirs</category>
      <category>smalltalk</category>
      <category>types</category>
      <category>oop</category>
      <trackback:ping>http://talklikeaduck.denhaven2.com/articles/trackback/3</trackback:ping>
    </item>
    <item>
      <title>On Hunting Ducks</title>
      <description>&lt;p&gt;Five doctors go duck hunting, they draw lots to determine the order in which they will shoot from the blind.&lt;/p&gt;


	&lt;p&gt;The Psychiatrist gets the first chance.&lt;/p&gt;


	&lt;p&gt;A flock of birds fly over. He looks down at his shotgun and says&lt;/p&gt;


&lt;blockquote&gt;They look like ducks! They sound like ducks!  I wonder how they feel about being ducks?&lt;/blockquote&gt;

	&lt;p&gt;Meanwhile the birds fly by.&lt;/p&gt;


	&lt;p&gt;Next up is the internist:&lt;/p&gt;


&lt;blockquote&gt;They look like ducks! They sound like ducks!  But we can&amp;#8217;t rule out the possibility that they might be geese.&lt;/blockquote&gt;

	&lt;p&gt;Then the general practitioner:&lt;/p&gt;


&lt;blockquote&gt;They look like ducks! They sound like ducks!  What do you guys think?.&lt;/blockquote&gt;

	&lt;p&gt;The surgeon takes his place next.  He confidently feels the trigger of his shotgun with his highly skilled right forefinger. The next flock flys over.&lt;/p&gt;


&lt;blockquote&gt;&lt;b&gt;Bang!  Bang!&lt;/b&gt;&lt;/blockquote&gt;

	&lt;p&gt;And the surgeon turns to the pathologist and says:&lt;/p&gt;


&lt;blockquote&gt;Check them out and see if they are ducks.&lt;/blockquote&gt;

	&lt;p&gt;I&amp;#8217;ve known this joke for quite a few years, but I&amp;#8217;ve never thought about it in relationship to software, until I started playing around with Ruby, and discovered an old friend under a new name, &amp;#8220;Duck Typing.&amp;#8221;&lt;/p&gt;


	&lt;p&gt;Last week, I ran across a thread on the ruby forum called &lt;a href="http://www.ruby-forum.com/topic/74246"&gt;&amp;#8220;I&amp;#8217;ll have the Duck!&amp;#8221;&lt;/a&gt; which quickly got lots of responses, and seems to have ended up with jokes.&lt;/p&gt;


	&lt;p&gt;Most of this thread seems to miss the point of duck typing.&lt;/p&gt;


	&lt;p&gt;Once you&amp;#8217;ve really grokked duck-typing you become like that surgeon.  Your perception of the properties of objects that really matter changes.  And you learn to use the pathologist (testing) as a powerful ally.&lt;/p&gt;


	&lt;p&gt;Many programers coming to ruby from languages like C++ and Java are like the psychiatrist, internist, and general praticioner in the duck hunting story.&lt;/p&gt;


	&lt;p&gt;They want certainty in their typing.  They&amp;#8217;ve developed the expectation that early type-checking by a compiler will keep them from making mistakes.&lt;/p&gt;


The problem with this expectation of the power of early type checking is two-fold.
&lt;ul&gt;
&lt;li&gt;It doesn&amp;#8217;t really work&lt;/li&gt;
&lt;li&gt;It is overly constraining&lt;/li&gt;
&lt;/ul&gt;

	&lt;p&gt;It doesn&amp;#8217;t work because the bugs caused by type-checking errors is a small subset of buges in general. Besides, in a fully object&amp;#8212;oriented language like Ruby or Smalltalk, they are rare (because the methods which actually operates on the data is actually automatically strongly type-bound to the data by virtue of it being a method.  It&amp;#8217;s overly constraining because it unnecessarily couples the implementations of the provider and users of the services provided by an object.&lt;/p&gt;


	&lt;p&gt;Rather than droning on about the failures and contraints of early-type checking, which I suspect I&amp;#8217;ll address more fully here as time goes on. Allow me to introduce the notion of types in an object-oriented languagethat I&amp;#8217;ve come to accept over many years.&lt;/p&gt;


	&lt;p&gt;Let me suggest that in a fully object-oriented language types are not properties of objects or classes, but properties of variables which code using an object uses to refer to those objects.  In saying this I&amp;#8217;m recapping the key idea behind an &lt;span class="caps"&gt;IBM&lt;/span&gt; Technical Report I wrote back in 1991 entitled &amp;#8220;Types fromthe Client&amp;#8217;s Viewpoint&amp;#8221; &lt;a href="/files/TypesFromTheClientsViewpoint.PDF"&gt;Which is available here as a pdf file.&lt;/a&gt;&lt;/p&gt;


	&lt;p&gt;&amp;#8220;But wait a minute!&amp;#8221;, you say.  &amp;#8220;Aren&amp;#8217;t types for matching objects with variables, so that programmers won&amp;#8217;t  make mistakes when they manipulate the object?&amp;#8221;  To which I reply, &amp;#8220;That&amp;#8217;s not object-oriented.&amp;#8221;&lt;/p&gt;


	&lt;p&gt;Now of course many will argue with this, but I&amp;#8217;d like to revisit the &lt;b&gt;original&lt;/b&gt; conception of object-orientation, a term which was coined by Alan Kay, the inventor of Smalltalk, a language from which Ruby has borrowed a lot.&lt;/p&gt;


	&lt;p&gt;The key idea behind &amp;#8220;object-orientation&amp;#8221; a la Smalltalk and Ruby is the encapsulation of implementation behind an interface defined by a set of messages.  Kay felt that the traditional way of structuring software as programs which processed data, and the attendant separation of program and data was somthing to be avoided.  His view is that it isbetter to compose software out of components which all look like little computers, which contain and bind the programs and state together. This was a synthesis of ideas which he had seen over many years, although they had never been codified before he did it.&lt;/p&gt;


	&lt;p&gt;For an insight into Kay&amp;#8217;s thinking, have a look at the article he wrote some years ago about &lt;a href="http://www.smalltalk.org/smalltalk/TheEarlyHistoryOfSmalltalk_Abstract.html"&gt;&amp;#8220;The Early History of Smalltalk&amp;#8221;&lt;/a&gt;&lt;/p&gt;


	&lt;p&gt;Another way of looking at this idea, is that objects should be like little server machines, the exact set of services available and their implementation can vary from server to server, but clients can still use those services in isolation from those details.&lt;/p&gt;


	&lt;p&gt;In both Ruby and Smalltalk, classes and inheritance are used for &lt;b&gt;implementation&lt;/b&gt; sharing, in order to achieve economies in implementing those little computers (objects). This is not an essential feature in Kay&amp;#8217;s conception of OO. The original versions of Smalltalk had neither classes nor inheritance which were introduced in later versions.&lt;/p&gt;


	&lt;p&gt;In parallel with the evolution of Smalltalk, a family of languages based around the concept of &lt;i&gt;Abstract Data Types&lt;/i&gt; became an important Computer Science  research topic.  Abstract Data Types arranged data types into a hierarchy so as to categorize their use as a way to structure more traditional procedural programs, and they called these abstract &lt;b&gt;data types&lt;/b&gt;, classes, and the relationship between classes inheritance, so subclassing was simply a synonym for sub&lt;b&gt;typing&lt;/b&gt;.&lt;/p&gt;


	&lt;p&gt;Since, by the time Smalltalk had been made widely known by the publication of a special issue of Byte magazine devoted to Smalltalk-80 in 1981, it had added classes and inheritance, most observers mistakenly thought of classes and inheritance as essential features of the language.  One of these was Peter Wegner who wrote an influential paper &lt;a href="http://portal.acm.org/affiliated/citation.cfm?id=38823&amp;#38;dl=ACM&amp;#38;coll=ACM&amp;#38;CFID=15151515&amp;#38;CFTOKEN=6184618"&gt;Dimensions of Object based Language Design&lt;/a&gt; which was published in the proceedings of the 1987 &lt;span class="caps"&gt;OOPSLA&lt;/span&gt; conference.  In this paper, Wegner defined &amp;#8220;object-oriented&amp;#8221; languages as those cobining &amp;#8220;objects+classes+inheritance.&amp;#8221;  What he missed was that in Kay&amp;#8217;s conception of object-orientation classes and inheritance were merely implementation artifacts, and that the encapsulation of implementation within an object was the big idea which separates object-oriented languages from procedural languages, and despite the similarity in terminology, abstract-data-type languages, which presented instances of those data types as things to be manipulated from the outside, were far from object-oriented, at least as Kay conceived it.&lt;/p&gt;


	&lt;p&gt;So to wrap this up for now, duck-typing is a natural consequence of the nature of how objects with strongly encapsulated implementations should interact.  The notion of objects containing the code which manipulates them, and hiding that implementation behind a wall, through which messages are sent, is a paradigm shift with powerful consequences.  Because many so-called &amp;#8220;object oriented&amp;#8221; languages missed this paradigm shift, many of their users are uaware the power of thinking about software design from this new perspective.&lt;/p&gt;


	&lt;p&gt;I hope, that in some small way, this blog will help expose the beauty of this paradigm shift.&lt;/p&gt;</description>
      <pubDate>Wed, 26 Jul 2006 15:39:00 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:be83a184-9f5b-4ab2-97de-de47263fa986</guid>
      <author>Rick DeNatale</author>
      <link>http://talklikeaduck.denhaven2.com/articles/2006/07/26/my-favorite-duck-typing-story</link>
      <category>ruby</category>
      <category>smalltalk</category>
      <category>humor</category>
      <category>types</category>
      <category>oop</category>
      <enclosure type="application/pdf" length="6274072" url="http://talklikeaduck.denhaven2.com/files/TypesFromTheClientsViewpoint.PDF"/>
      <trackback:ping>http://talklikeaduck.denhaven2.com/articles/trackback/2</trackback:ping>
    </item>
  </channel>
</rss>
