<?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: Category smalltalk</title>
    <link>http://talklikeaduck.denhaven2.com/articles/category/smalltalk</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>In Ruby, it's not the dog, it's the tricks!</description>
    <item>
      <title>Alan Kay, Super Hero</title>
      <description>&lt;p&gt;&lt;a href="http://www.boingboing.net/2008/11/20/illustrating-alan-ka.html"&gt;Via Boing-Boing&lt;/a&gt;, Business week has just put a comic strip on their web site, which tells the story of how &lt;a href="http://images.businessweek.com/ss/08/11/1106_portable_computers/index.htm"&gt;Alan Kay, inspired by a visit to Seymour Papert&lt;/a&gt; seeded the idea of portable computers.&lt;/p&gt;
&lt;p&gt;Long term readers of this blog no doubt know that I hold Alan Kay in high regard.  I got to meet him several times, first I think at an internal &lt;span class="caps"&gt;IBM&lt;/span&gt; conference on Object Oriented Programming in the mid 1980s, Another time was at a Digitalk developers conference, where I obtained a prize possession.  At the time I was the &lt;span class="caps"&gt;IBM&lt;/span&gt; technical liaison with Digitalk. They released a new version of Smalltalk/V PM at this particular conference, and I was presented a copy of the supplemental manual for the release signed by all of the Digitalk developers, and also by Alan Kay, who wrote something like &amp;#8220;to the most non-IBM like IBMer I&amp;#8217;ve ever met.&amp;#8221;&lt;/p&gt;
&lt;p&gt;Reading the business week strip, I was reminded of an even earlier personal connection with Kay and Smalltalk.  A year or so before I really got into Objects, I was working on &lt;span class="caps"&gt;IBM&lt;/span&gt; Mainframe software in Poughkeepsie, NY.  One summer the project got an intern, named &lt;a href="http://en.wikipedia.org/wiki/Radia_Perlman"&gt;Radia Perlman&lt;/a&gt;, who was in graduate school at M.I.T. And is now known as the &amp;#8220;mother of the internet&amp;#8221; for her invention of &lt;a href="http://en.wikipedia.org/wiki/Spanning-tree_protocol"&gt;spanning-tree protocol&lt;/a&gt;. It was only later that I learned that she was one of Papert&amp;#8217;s students working on Logo and seeing how kids learned programming with Logo, and if I recall correctly she also visited Xerox &lt;span class="caps"&gt;PARC&lt;/span&gt;, and was involved in porting the concept of the &lt;a href="http://en.wikipedia.org/wiki/Turtle_graphics"&gt;Logo turtle model of graphics&lt;/a&gt; to Smalltalk, where it became the Pen object.&lt;/p&gt;
&lt;p&gt;What a long strange trip it is!&lt;/p&gt;</description>
      <pubDate>Fri, 21 Nov 2008 00:03:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:365fea76-22a7-469f-981c-470b84bb942c</guid>
      <author>Rick DeNatale</author>
      <link>http://talklikeaduck.denhaven2.com/articles/2008/11/21/alan-kay-super-hero</link>
      <category>war_stories</category>
      <category>smalltalk</category>
      <category>alankay</category>
      <trackback:ping>http://talklikeaduck.denhaven2.com/articles/trackback/516</trackback:ping>
    </item>
    <item>
      <title>The Pros and Cons of 64-Bit Architectures</title>
      <description>&lt;p&gt;My former &lt;span class="caps"&gt;OTI&lt;/span&gt; colleague &lt;a href="http://www.lowtek.ca/roo/"&gt;Andrew &amp;#8220;Roo&amp;#8221; Low&lt;/a&gt; just wrote an interesting article about &lt;a href="http://www.lowtek.ca/roo/2008/java-performance-in-64bit-land/"&gt;the trade-offs involved&lt;/a&gt; in designing a VM (and software in general) to exploit 64-bit machine architectures.  Although, Roo discusses &lt;span class="caps"&gt;JVM&lt;/span&gt; implementation, he also grounds it with his experiences developing the &lt;span class="caps"&gt;IBM&lt;/span&gt;/OTI Smalltalk VM, and the lessons would be equally applicable to, say, a Ruby implementation.&lt;/p&gt;</description>
      <pubDate>Sat, 01 Nov 2008 09:17:00 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:d2ee8a8b-9910-4cbf-80f7-6376b1369adf</guid>
      <author>Rick DeNatale</author>
      <link>http://talklikeaduck.denhaven2.com/articles/2008/11/01/the-pros-and-cons-of-64-bit-architectures</link>
      <category>smalltalk</category>
      <category>jvm</category>
      <category>vm</category>
      <category>performance</category>
      <trackback:ping>http://talklikeaduck.denhaven2.com/articles/trackback/511</trackback:ping>
    </item>
    <item>
      <title>Will It Go Round in Circles?</title>
      <description>&lt;p&gt;I really like seeing the resurgence of interest in &lt;a href="http://blogs.gartner.com/mark_driver/2008/10/09/remember-smalltalk"&gt;my second most favorite programming language&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;One of the comments to the referenced Gartner Group blog post had a link to an &lt;span class="caps"&gt;IBM&lt;/span&gt; Developer Works article about using &lt;a href="http://www.ibm.com/developerworks/blogs/page/stdt"&gt;using Eclipse as a Smalltalk &lt;span class="caps"&gt;IDE&lt;/span&gt;.&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;It seems like a strange loop, since Eclipse is the descendant of IBMs old VisualAge. Now I happen to know a bit about this since I was involved at the beginning.  I guess that enough time has passed that nothing I say here will affect anyone&amp;#8217;s business.&lt;/p&gt;
&lt;h2&gt;&lt;span class="caps"&gt;IBM&lt;/span&gt;, Smalltalk, and VisualAge&lt;/h2&gt;
&lt;p&gt;VisualAge started out as a demonstration prototype I wrote using Digitalk Smalltalk/V. The idea was to make something like the NeXT interface builder in Smalltalk as an adjunct to the Smalltalk &lt;span class="caps"&gt;IDE&lt;/span&gt;.  For those who are not hip to such things, the Interface Builder, originally a Lisp program before Steve Jobs hired the author, lives on as part of Apple&amp;#8217;s XCode tool suite for OS/X for the Mac and the iPhone.&lt;/p&gt;
&lt;p&gt;The demo got some key &lt;span class="caps"&gt;IBM&lt;/span&gt; executives excited, and so the VisualAge development organization was born.  Development proceeded using Smalltalk/V, along with Object Technology International&amp;#8217;s (OTI) Envy/Developer, which was the state of the art version and configuration management for Smalltalk team programming.&lt;/p&gt;
&lt;p&gt;As the project progressed, &lt;span class="caps"&gt;IBM&lt;/span&gt; and Digitalk had a falling out over conflicting views of who should be doing what. I&amp;#8217;d shown the prototype to them in my position as liaison between the two companies, and they launched their Look and Feel kit which was seen by &lt;span class="caps"&gt;IBM&lt;/span&gt; management as competition from a supplier.  So since we already had a relationship with &lt;span class="caps"&gt;OTI&lt;/span&gt; because of Envy/Developer, and &lt;span class="caps"&gt;OTI&lt;/span&gt; was in the business of building Smalltalk VMs, including the VM used by Digitalk&amp;#8217;s Smalltalk/V for the Macintosh, &lt;span class="caps"&gt;IBM&lt;/span&gt; switched horses and contracted &lt;span class="caps"&gt;OTI&lt;/span&gt; to build &amp;#8220;IBM&amp;#8221; Smalltalk.  This eventually led to the acquisition of &lt;span class="caps"&gt;OTI&lt;/span&gt; by &lt;span class="caps"&gt;IBM&lt;/span&gt; Canada.&lt;/p&gt;
&lt;p&gt;This was about the time we founded the &lt;span class="caps"&gt;ANSI X3J20&lt;/span&gt; committee to forge a standard across the existing and emerging Smalltalk implementations.  I served as the secretary of &lt;span class="caps"&gt;X3J20&lt;/span&gt;.  Some of the other members included Peter Deutsch and Glenn Krasner of ParcPlace, which Xerox had spun-off from their Palo Alto Research Center to commercialize Smalltalk-80; George Bosworth of Digitalk; Allen Wirfs-Brock of Instantiations one of the more successful Smalltalk consulting companies in the Portland Oregon suburbs; David Simmons who was the brains behind the iconoclastic Smalltalk/Agents; and Bruce Schuchardt who worked for Servio-Logic or Gemstone, I can&amp;#8217;t recall which name they were going under at the time.  I&amp;#8217;m sure that I&amp;#8217;m forgetting some of the players, but I&amp;#8217;ll plead senility.&lt;/p&gt;
&lt;p&gt;One of the great joys of working in Smalltalk during it&amp;#8217;s first &amp;#8220;glory days&amp;#8221; was the opportunity to work with and exchange ideas with such brilliant people in &lt;span class="caps"&gt;IBM&lt;/span&gt;, OTI, and other companies.&lt;/p&gt;
&lt;p&gt;VisualAge grew to become an entire family of development environments for several of the &lt;span class="caps"&gt;IBM&lt;/span&gt; &amp;#8220;SAA&amp;#8221; programming languages. There was even a VisualAge for Cobol! All of the various flavors featured an &lt;span class="caps"&gt;IDE&lt;/span&gt; written in &lt;span class="caps"&gt;IBM&lt;/span&gt; Smalltalk.&lt;/p&gt;
&lt;h2&gt;Enter Java&lt;/h2&gt;
&lt;p&gt;When Java &amp;#8220;reared it&amp;#8217;s head.&amp;#8221;  &lt;span class="caps"&gt;IBM&lt;/span&gt;, of course came out with VisualAge for Java.  Again, the &lt;span class="caps"&gt;IDE&lt;/span&gt; was written in Smalltalk, although, in order to accomodate Java execution, &lt;span class="caps"&gt;OTI&lt;/span&gt; developed what was called the &lt;span class="caps"&gt;UVM&lt;/span&gt; (or Universal Virtual Machine) whcih could execute both Smalltalk and Java byte-codes, and used Smalltalk to implement the Java primitive functions which were implemented in C in the Sun &lt;span class="caps"&gt;JVM&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;&lt;span class="caps"&gt;IBM&lt;/span&gt; eventually switched its focus from Smalltalk to Java. After considerable thought about this, and conversations with those &lt;a href="http://agiletoolkit.libsyn.com/index.php?post_id=252431"&gt;who were in a position to know&lt;/a&gt;, I&amp;#8217;m now convinced that this had nothing to do with the relative technical merits, and everything to do with a combined &lt;span class="caps"&gt;IBM&lt;/span&gt;/Sun platform play against Microsoft.&lt;/p&gt;
&lt;p&gt;VisualAge for Java did eventually move away from the &lt;span class="caps"&gt;UVM&lt;/span&gt; for Java execution, primarily because the Java language had evolved to provide a standard C api for extensions.  &lt;span class="caps"&gt;OTI&lt;/span&gt; began implementation of a new &lt;span class="caps"&gt;JVM&lt;/span&gt;, which was dubbed J9, which was built from the ground up to be usable in embedded systems.&lt;/p&gt;
&lt;p&gt;&lt;span class="caps"&gt;OTI&lt;/span&gt; had a reputation of fostering the use of Smalltalk in embedded systems.  When I first became aware of them in the early &lt;span class="caps"&gt;OOPSLA&lt;/span&gt; days, they were showing off products like an HP Network Analyser, and a TekTronix Digital Oscilloscope which used Smalltalk to implement their user interfaces.  They were also involved with a large semiconductor company in Texas which was planning to use Smalltalk in controllers in an automated IC fabrication facility.&lt;/p&gt;
&lt;p&gt;Around the time of the birth of J9, &lt;span class="caps"&gt;IBM&lt;/span&gt; was becoming quite interested in embedded software, under an initiative called Pervasive Computing (PVC).  Because of this, &lt;span class="caps"&gt;OTI&lt;/span&gt; now an &lt;span class="caps"&gt;IBM&lt;/span&gt; Subsidiary, started working on VisualAge Micro Edition, which bundled J9 with an cross-platform &lt;span class="caps"&gt;IDE&lt;/span&gt; written, this time, in Java. About this time, I moved from &lt;span class="caps"&gt;IBM&lt;/span&gt; to &lt;span class="caps"&gt;OTI&lt;/span&gt;, and ended up working on the &lt;span class="caps"&gt;VAME IDE&lt;/span&gt;.&lt;/p&gt;
&lt;h2&gt;The Emergence of Eclipse&lt;/h2&gt;
&lt;p&gt;Work on &lt;span class="caps"&gt;VAME&lt;/span&gt; was distributed between various &lt;span class="caps"&gt;OTI&lt;/span&gt; labs.  The lab in Phoenix acted as the liaison with the &lt;span class="caps"&gt;IBM PVC&lt;/span&gt; folks, the &lt;span class="caps"&gt;J9 VM&lt;/span&gt; work was done in Ottawa, Raleigh did some applications work, and some UI work, but the bulk of the &lt;span class="caps"&gt;VAME UI&lt;/span&gt; framework was done by Erich Gamma&amp;#8217;s team at &lt;span class="caps"&gt;OTI&lt;/span&gt; Zurich.  The &lt;span class="caps"&gt;IDE&lt;/span&gt; used Swing, as most Java desktop apps did in those days, and apparently that was a bit of a struggle.  &lt;span class="caps"&gt;OTI&lt;/span&gt; used to have an annual all-hands internal developer conference in sunny early February Quebec, and I&amp;#8217;ll never forget Erich, who is quite the Alpine skier, talking about the UI while showing a slide he took at some ski report showing a sign with a precariously oscillating chair-lift and a skier about to fall, with the text &amp;#8220;Don&amp;#8217;t Swing!&amp;#8221;&lt;/p&gt;
&lt;p&gt;This led to the desire to develop a new UI framework and what is now known as the &lt;a href="http://www.eclipse.org/swt/"&gt;&lt;/a&gt;standard widget set or &lt;span class="caps"&gt;SWT&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;And the overall &lt;span class="caps"&gt;IDE&lt;/span&gt;/UI framework which replaced &lt;span class="caps"&gt;VAME&lt;/span&gt; was, of course Eclipse.&lt;/p&gt;
&lt;p&gt;And now it seems we&amp;#8217;ve gone from a Smalltalk &lt;span class="caps"&gt;IDE&lt;/span&gt; hosting Java development to the reverse!&lt;/p&gt;
&lt;h2&gt;Where Are They Now&lt;/h2&gt;
&lt;p&gt;Digitalk eventually merged with ParcPlace to form ParcPlace-Digitalk. For a while, both Smalltalk/V and VisualWorks/Objectworks (the ParcPlace Smalltalk-80 products) were carried, but eventually VisualWorks survived.  It&amp;#8217;s now shepherded by Cincom, which bought the rights.&lt;/p&gt;
&lt;p&gt;Similarly, &lt;span class="caps"&gt;IBM&lt;/span&gt; eventually sold the rights to market and develop VisualAge Smalltalk (a.k.a. &lt;span class="caps"&gt;VAST&lt;/span&gt;) to Instantiations. My old friend and colleague from &lt;span class="caps"&gt;IBM&lt;/span&gt; &lt;a href="http://smalltalkers.ning.com/profile/JohnOKeefe"&gt;John O&amp;#8217;Keefe&lt;/a&gt; &amp;#8220;retired&amp;#8221; from &lt;span class="caps"&gt;IBM&lt;/span&gt; to lead the development team.&lt;/p&gt;
&lt;p&gt;Several of the &lt;span class="caps"&gt;X3J20&lt;/span&gt; guys went to or through Microsoft.  George Bosworth worked for several years on &lt;a href="http://www.cincomsmalltalk.com/blog/blogView?showComments=true&amp;#38;printTitle=Keynote:_George_Bosworth&amp;#38;entry=3342753129"&gt;a precursor to today&amp;#8217;s Microsoft &lt;span class="caps"&gt;DLR&lt;/span&gt;.&lt;/a&gt; &lt;a href="http://www.cincomsmalltalk.com/blog/blogView?showComments=true&amp;#38;printTitle=Smalltalk_Solutions_Daily_Update:_David_Simmons_Keynote&amp;#38;entry=3390444300"&gt;Davd Simmons&lt;/a&gt; and &lt;a href="http://channel9.msdn.com/shows/Microsoft+Conversations+with+J/A-conversation-with-Allen-Wirfs-Brock-about-the-history-of-Smalltalk-and-the-future-of-dynamic-langu/"&gt;Allen Wirfs-Brock&lt;/a&gt; both work on Javascript for Microsoft.&lt;/p&gt;
&lt;p&gt;And, of interest to the Ruby community, Gemstone is now working on &lt;a href="http://ruby.gemstone.com"&gt;Maglev&lt;/a&gt;, a Ruby implementation with persistent objects based on their mature Smalltalk product.&lt;/p&gt;</description>
      <pubDate>Wed, 15 Oct 2008 15:24:00 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:52a3002f-5d95-4b18-90a6-ccdb440998c0</guid>
      <author>Rick DeNatale</author>
      <link>http://talklikeaduck.denhaven2.com/articles/2008/10/15/will-it-go-round-in-circles</link>
      <category>war_stories</category>
      <category>smalltalk</category>
      <category>x3j20</category>
      <category>maglev</category>
      <category>gemstone</category>
      <category>parcplace</category>
      <category>digitalk</category>
      <category>oti</category>
      <category>visualage</category>
      <category>j9</category>
      <trackback:ping>http://talklikeaduck.denhaven2.com/articles/trackback/508</trackback:ping>
    </item>
    <item>
      <title>What Would You Miss If You Had To Stop Using Ruby and Go Back to Smalltalk?</title>
      <description>&lt;p&gt;Last night, James Robertson from Cincom, &lt;a href="http://www.cincomsmalltalk.com/blog/blogView?showComments=true&amp;#38;printTitle=Seaside_with_the_Raleigh_Rubyists&amp;#38;entry=3388818661"&gt;presented Smalltalk and Seaside to the Raleigh Ruby Brigade.&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;It was an interesting deja-vu experience, since in my younger days, part of my job with &lt;span class="caps"&gt;IBM&lt;/span&gt; was evangelizing Smalltalk, much as James does today.  It was interesting to see what has and hasn&amp;#8217;t changed. For the most part the things about Smalltalk which were blessings and curses (or many times both) haven&amp;#8217;t changed.  The &lt;span class="caps"&gt;IDE&lt;/span&gt; is still powerful. It gets much of it&amp;#8217;s power from Smalltalk&amp;#8217;s model of how source code and run-time implementation objects like compiled-methods, classes and metaclasses interact, but the consequence is that there aren&amp;#8217;t really Smalltalk source files to use with popular editors like &lt;span class="caps"&gt;VIM&lt;/span&gt; or &lt;span class="caps"&gt;EMACS&lt;/span&gt; or Textmate.  The question came up about whether the Smalltalk &lt;span class="caps"&gt;IDE&lt;/span&gt; supported the notion of giving the code to an external editor, and the answer was that the size of a typical Smalltalk method, which is the unit of editing, was so small (10 lines is a long Smalltalk method) as to make it &amp;#8216;moot.&amp;#8217;  I used to get the same kind of questions and give pretty much the same answers.&lt;/p&gt;
&lt;p&gt;One area where Smalltalk really does excel is in it&amp;#8217;s debugging and inspection tools.  The same implementation object model which enables browser features, like finding all senders or implementers of a message using structural rather than textual searching, also allows live debugging, where you can not only inspect the run-time state at a breakpoint, or when an exception occurs, but actually make changes to the running code, and compile those changes, at which point the VM prunes the invocation stack down to the point of the change and allows you to restart from that point.  Protestations from &lt;span class="caps"&gt;TDD&lt;/span&gt;/BDD adherents that &lt;a href="http://talklikeaduck.denhaven2.com/articles/2007/10/18/true-confesssions"&gt;you don&amp;#8217;t need no steenking debugger&lt;/a&gt; if you follow &lt;span class="caps"&gt;TDD&lt;/span&gt; practice, the Smalltalk debugger was tool much favored by the very people, like Kent Beck, who invented &lt;span class="caps"&gt;TDD&lt;/span&gt;.  Many Rubyists who were around for more than a year or two had an anti-debugger attitude, generated more, I suspect, by the lack of a decent Ruby debugger than any real hatred of debuggers.&lt;/p&gt;
&lt;p&gt;Now that ruby-debug has been around for &lt;a href="http://datanoise.com/articles/2006/7/7/faster-debugger-for-ruby"&gt;almost two years&lt;/a&gt;, the situation is much better. Ruby has a fairly competent debugger which allows stepping through code.  It&amp;#8217;s still hampered by Ruby&amp;#8217;s rather simple run-time meta information, being forced to work on a line-by-line mode, rather than being able to step through individual expressions as can the Smalltalk debugger.  And we&amp;#8217;re still a long way from the live surgery capabilities I described. Perhaps as Ruby VM implementations mature we might see some of these advanced features emerge, perhaps this is something which the Rubinius implementers might also take as an inspiration from Smalltalk.  This is one of the main things I miss from my Smalltalk days.&lt;/p&gt;
&lt;p&gt;On the other hand, at this point in time, I&amp;#8217;m really much happier working in Ruby than  I think I would be were I somehow forced to work in Smalltalk again instead.  Much as I love it, Smalltalk is now my second favorite language.&lt;/p&gt;
&lt;p&gt;At one point last night, Brian Adkins asked me the question which is the title of this article.  I think it&amp;#8217;s a fair question, and I&amp;#8217;m not sure I know exactly, but let me try to answer it.&lt;/p&gt;
&lt;h2&gt;What I&amp;#8217;d miss from Ruby&lt;/h2&gt;
&lt;p&gt;I&amp;#8217;ve said this before, but one of the things I like about Ruby is that it is more dynamic than Smalltalk in ways which I like, and cuts back on other aspects of Smalltalk which I don&amp;#8217;t think are really that important.&lt;/p&gt;
&lt;p&gt;One of the things I like about Ruby is the &lt;a href="http://talklikeaduck.denhaven2.com/articles/2008/02/08/whose-variable-is-it-anyway"&gt;elimination of variable declarations.&lt;/a&gt; A good example of this was that during the Seaside demo last night, James showed how interfacing to the database requires attribute instance variables in model objects to be declared.  Now the &lt;span class="caps"&gt;IDE&lt;/span&gt; provides tools for helping with this, you get prompted with a list of column names and can add them one by one just by clicking buttons.  Contrast this with ActiveRecord where model objects just acquire instance variables dynamically at run-time.  Now I know that some prefer more explicit mappings, but personally I feel that the dynamic mapping provides much more capability for much less ceremony.&lt;/p&gt;
&lt;p&gt;The ways in which Ruby is more dynamic than Smalltalk seem to me to provide better facilities for building low-ceremony architectures and artifacts like Rails, Rake, etc.  There are more dynamic languages than Ruby to be sure, such as Self, and from what I can sense JavaScript, but Ruby seems to strike a very nice balance.&lt;/p&gt;
&lt;p&gt;Much has been made of the legacy of Smalltalk in pioneering metaprogramming, although some Lisp guys might quibble with that, and in truth, most Smalltalk metaprogramming was only used to support the &lt;span class="caps"&gt;IDE&lt;/span&gt; and never put to use by application programmers.  Alan Kay used to say that he was disappointed that no one seemed to make new classes of Behavior (which is the superclass of both Class and Metaclass in Smalltalk). I know he said this to some of us at an &lt;span class="caps"&gt;IBM&lt;/span&gt; internal conference, which at least led to Dave Smith and Jerry Archbald developing a &amp;#8220;behavior of behavior&amp;#8221; tutorial which ran for several years at &lt;span class="caps"&gt;OOPSLA&lt;/span&gt;.  But Rubyists have taken metaprogramming much further than I recall from my Smalltalk days.&lt;/p&gt;
&lt;p&gt;On the other end of the scale, Smalltalk as James pointed out, as I used to, has a very simple syntax, a few reserved words (self, super, nil, true, and false), three types of messages (unary, binary, and keyword),  two operators (:= for assignment, and &amp;#94; for return), and a few more things for defining block literals.&lt;/p&gt;
&lt;p&gt;Now when I was doing James&amp;#8217; job, this got mixed reactions. Some people took to syntax like:&lt;/p&gt;
&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_smalltalk "&gt;topLeft = Point x: 3+2*5 y: 15&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;While others found it just a little too strange, something which we Smalltalkers just couldn&amp;#8217;t get.&lt;/p&gt;
&lt;p&gt;Another thing which put off newcomers to Smalltalk was that, because of the simplicity of the language, and the lack of any form of operator precedence (remember the only operators are := and &amp;#94;), that subexpression 3+2*5 evaluates to 25 and not 13.&lt;/p&gt;
&lt;p&gt;Ruby trades off a little simplicity and does provide precedence between messages which seem like they should act as operators.&lt;/p&gt;
&lt;p&gt;I&amp;#8217;m not saying that Ruby is without quirks, just that different people react to different quirks in different ways.  If you don&amp;#8217;t like what you perceive to be the quirks of &lt;strong&gt;any&lt;/strong&gt; programming language, you won&amp;#8217;t be convinced, even by the most ardent supporter of those quirks.&lt;/p&gt;
&lt;p&gt;One of the interesting effects of the Smalltalk syntax was that, as we observed back in Smalltalk&amp;#8217;s heyday in the Enterprise (late &amp;#8216;80s-early &amp;#8216;90s), it seemed that a lot of &lt;span class="caps"&gt;COBOL&lt;/span&gt; programmers seemed to take to Smalltalk. We used to think that Smalltalk might actually become the 21st century &lt;span class="caps"&gt;COBOL&lt;/span&gt;, until the &amp;#8220;Enterprise&amp;#8221; got wooed away by EJBs and the like. The same things which made Smalltalk approachable by &lt;span class="caps"&gt;COBOL&lt;/span&gt; programmers made it seem weird to those who looked down on those &lt;span class="caps"&gt;COBOL&lt;/span&gt; programmers as &amp;#8220;trade-school&amp;#8221; programmers.&lt;/p&gt;
&lt;p&gt;Another much-touted feature of Smalltalk, is that everything is done by message sending, even control flow.  In Smalltalk a if/then/else control flow is achieved by sending an ifTrue:ifFalse: message to a boolean object as in:&lt;/p&gt;
&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_smalltalk "&gt; ^(x = 0) ifTrue:[a] ifFalse:[b]&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Smalltalk evaluates this as if the the expression (x = 0) is evaluated by sending the message with the selector = and argument 0, to the object referenced by x.  The result of that message, an object of course, is then sent the message with the selector ifTrue:ifFalse: and the arguments [a] and [b], which are two blocks.  What happens is up to that object.  Typically that object is either true (the sole instance of the class True) whose ifTrue:ifFalse: method evaluates the first argument, or false (the sole instance of the class False) whose ifTrue:ifFalse: method evaluates the second argument.  Very neat and conceptually clean.  It allows you to define your own control flow methods.&lt;/p&gt;
&lt;p&gt;Ruby on the other hand compiles if statements and their kind as tests and branches, much as a C compiler would.  We trade off a little flexibility for performance.&lt;/p&gt;
&lt;p&gt;But, in my experience, that flexibility rarely got used in Smalltalk.  Not only that but, in my day at least, the Smalltalk compilers would &lt;strong&gt;also&lt;/strong&gt; compile ifTrue:ifFalse: to a test of the result of the &amp;#8216;receiver&amp;#8217; and a branch.  In fact I just tried defining a FakeBoolean class with an ifTrue: method and when I try to use it I see this:&lt;/p&gt;
&lt;img src="http://talklikeaduck.denhaven2.com/files/2008-05-21_must_be_boolean.png" alt="must_be_boolean" height="326" width="326"&gt;
&lt;p&gt;That NonBooleanReceiver exception is like seeing the Wizard of Oz behind the curtain, this notion of no control flow, just messages is actually a bit of an illusion.&lt;/p&gt;
&lt;p&gt;Again, while Ruby doesn&amp;#8217;t even pretend to implement all control flow by messaging, it provides most of what the underlying Smalltalk mechanisms are really used for in the form of blocks used to implement iterators.&lt;/p&gt;
&lt;p&gt;There are other aspects of Smalltalk which are both blessings and curses.  The fact that Smalltalk has a persistent run-time image, containing all the development tools, which can be saved along with its state of execution, and restarted is quite powerful, alien to many programmers, and can drastically change your approach to deployment.  Back when I was doing Smalltalk we always struggled with issues like the footprint of the image, how to strip out the development tools before deployment, and start-up time.  Some of these problems might seem to be less severe with today&amp;#8217;s hardware, but they are still issues.&lt;/p&gt;
&lt;p&gt;I feel that I might be coming across a little too harshly on my old friend Smalltalk.  It still provides a great programming environment, and serves as a source of inspiration which shouldn&amp;#8217;t be overlooked, and I hope to see some of the powerful development tool features from Smalltalk appear with help from support in some of the emerging Ruby implementations.  I&amp;#8217;m glad to see that it seems to be making somewhat of a resurgence, along with dynamic languages in general.  But for me right now, while I wouldn&amp;#8217;t be unhappy if I had to go back to Smalltalk, but I feel happier with Ruby.&lt;/p&gt;</description>
      <pubDate>Wed, 21 May 2008 16:58:00 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:8d57cff0-8bf8-43fe-8b97-c7b98decd8f1</guid>
      <author>Rick DeNatale</author>
      <link>http://talklikeaduck.denhaven2.com/articles/2008/05/21/what-would-you-miss-if-you-had-to-stop-using-ruby-and-go-back-to-smalltalk</link>
      <category>ruby</category>
      <category>war_stories</category>
      <category>smalltalk</category>
      <category>seaside</category>
      <category>debugging</category>
      <trackback:ping>http://talklikeaduck.denhaven2.com/articles/trackback/500</trackback:ping>
    </item>
    <item>
      <title>Best Practice Patterns, Accessors and Encapsulation</title>
      <description>&lt;p&gt;&lt;img src="http://talklikeaduck.denhaven2.com/files/2008-02-15_kents_autograph_to_me_on_stbpp.png" alt="Kent's Autograph to me on STBPP" height="255" width="250" class="tease-image"&gt;
One of the classics in the Smalltalk literature, which  has also had a big influence on the Ruby community is Kent Beck&amp;#8217;s &lt;a href="http://www.amazon.com/gp/product/013476904X?ie=UTF8&amp;#38;tag=denhaven2com-20&amp;#38;linkCode=as2&amp;#38;camp=1789&amp;#38;creative=9325&amp;#38;creativeASIN=013476904X"&gt;&amp;#8220;Smalltalk Best Practice Patterns&amp;#8221;&lt;/a&gt;&lt;img src="http://www.assoc-amazon.com/e/ir?t=denhaven2com-20&amp;#38;l=as2&amp;#38;o=1&amp;#38;a=013476904X" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /&gt;, which captures the best practices for designing and coding Smalltalk programs.  Back when it was published, I used to see Kent a few times a year, and happened to be in the Bay area when he made an author appearance at the Computer Literacy Bookstore in San Jose, where I got my copy, and the autograph shown here.
&lt;p&gt;The Ruby language has many similarities with Smalltalk, so much of Kent&amp;#8217;s advice applies to Ruby.  I frequently hear prominent Rubyists mention the book.&lt;/p&gt;
&lt;p&gt;On the other hand, Ruby is not exactly Smalltalk, so Kent&amp;#8217;s book isn&amp;#8217;t an exact fit to Ruby. I&amp;#8217;ve been wanting to start writing about adapting some of these patterns to Ruby for a while, so this article will hopefully be the first in a series.&lt;/p&gt;
&lt;h2&gt;The Motivation For This Article&lt;/h2&gt;
&lt;p&gt;Recently on the ruby-talk forum a thread discussing &lt;a href="http://www.ruby-forum.com/topic/141107"&gt;accessor methods vs. direct instance variable access&lt;/a&gt; came up.  This was a hot debate topic in the Smalltalk community back in the 90s, and Kent addressed it in two competing patterns in the book, one of which Ryan Davis (a.k.a ZenSpider) brought up in the conversation.&lt;/p&gt;&lt;/p&gt;


&lt;h2&gt;Patterns Are Decisions, Not Prescriptions.&lt;/h2&gt;
&lt;p&gt;In their best form, patterns represent a network of decisions made during the creation of something, in this case software.  A good pattern should describe the &lt;strong&gt;forces&lt;/strong&gt; which affect the decision whether or not to adopt the particular &lt;strong&gt;solution&lt;/strong&gt; it offers.&lt;/p&gt;
&lt;p&gt;There can often be a tension between competing patterns, different patterns optimize different desirable characteristics, such as readability vs. flexibility.&lt;/p&gt;
&lt;p&gt;The forces, or their relative strength, can be affected by technical factors such as the language, and features of the editor or &lt;span class="caps"&gt;IDE&lt;/span&gt; being used. To varying degrees many or all of Kent&amp;#8217;s Smalltalk patterns have forces affected by the capabilities of the Smalltalk &lt;span class="caps"&gt;IDE&lt;/span&gt;. One of Kent&amp;#8217;s main goals is readable code, so writing code to maximize the utility of the code exploration features of the Smalltalk browsers, inspectors, and debugger figures into the book.&lt;/p&gt;
&lt;h2&gt;A Tale of Two Patterns&lt;/h2&gt;
&lt;p&gt;Now to the specifics of the article at hand.  The book has two patterns described in sequence,starting on page 89, &amp;#8220;Direct Variable Access&amp;#8221;, and &amp;#8220;Indirect Variable Access&amp;#8221;. Both address the same problem &amp;#8220;How do you get and set an instance variable&amp;#8217;s value?&amp;#8221; and give two opposing solutions, along with a good discussion of the tensions.&lt;/p&gt;
&lt;p&gt;The first pattern, as the name implies, advocates referring to an instance variable directly by name, so in Ruby, within a method, you&amp;#8217;d just write @x, instead of using accessor methods, the second pattern.&lt;/p&gt;
&lt;p&gt;As Kent points out in the discussion of the first pattern, direct vs. indirect access was a hotly debated topic in the Smalltalk community, although indirect access got to be popular since it was advocated by several Smalltalk training companies.&lt;/p&gt;
&lt;h2&gt;Tension Number One: Readability&lt;/h2&gt;
&lt;p&gt;In his argument for direct variable access, Kent explains that whenever he ran into an accessor method invocation, which in Smalltalk looks like this:&lt;/p&gt;
&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_Smalltalk "&gt;a = self x&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;He found himself pausing to remind himself that x was &amp;#8220;just&amp;#8221; accessing an instance variable, but that he would read the direct form:&lt;/p&gt;
&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_Smalltalk "&gt;a = x&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;without breaking his stride.&lt;/p&gt;
&lt;p&gt;I might point out that Ruby is subtly different here. First, direct instance variable access is clearly marked with the &amp;#8221;@&amp;#8221; sigil.  On the other hand, a read accessor invocation in Ruby can be written without the explicit self receiver:&lt;/p&gt;
&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_ruby "&gt;&lt;span class="ident"&gt;a&lt;/span&gt; &lt;span class="punct"&gt;=&lt;/span&gt; &lt;span class="ident"&gt;x&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;So it&amp;#8217;s not as clear that this is a method invocation as opposed to a local variable access, although we know that it &lt;strong&gt;isn&amp;#8217;t&lt;/strong&gt; a direct instance variable access. Write accessor invocation usually requires an explicit receiver:&lt;/p&gt;
&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_ruby "&gt;&lt;span class="constant"&gt;self&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;x&lt;/span&gt; &lt;span class="punct"&gt;=&lt;/span&gt; &lt;span class="ident"&gt;a&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;to disambiguate between a write accessor call and simply assigning to a local variable, at least the first time x appears in a particular lexical scope.&lt;/p&gt;
&lt;h2&gt;Tension Number Two: Subclassablity&lt;/h2&gt;
&lt;p&gt;Although direct instance variable is more readable, it does have a drawback in that it makes certain subclassing patterns harder to implement.&lt;/p&gt;
&lt;p&gt;If a class uses indirect variable access consistently, then a subclass can leverage this by overriding the accessor.  For example, lets say we want a subclass which audits changes to an instance variable.  By overriding the setter accessor it can do things like logging changes very simply.  Otherwise any methods which access the instance variable in the superclass need to be overridden.&lt;/p&gt;
&lt;p&gt;Kent&amp;#8217;s example is defining a PolarPoint subclass of Point which has radius and theta instance variables, and overrides Point&amp;#8217;s accessors for x and y.  One interesting aspect of the Ruby/Smalltalk comparison when you look at this example a little more deeply relates to my recent article about instance variables.  In Smalltalk since the Point class has x and y instance variables, it&amp;#8217;s subclass PolarPoint would have x, y, radius and theta instance variables, although the x and y variables would be vestigial and unused.  In Ruby a PolarPoint instance wouldn&amp;#8217;t acquire the unneeded x and y instance variables.&lt;/p&gt;
&lt;h2&gt;The Encapsulation Tension&lt;/h2&gt;
&lt;p&gt;One of the reasons why there was/is such a debate between proponents of direct vs. indirect instance variable access is the effect providing setter and getter accessors has on the apparent encapsulation of the object&amp;#8217;s state.&lt;/p&gt;
&lt;p&gt;First, in either Ruby or Smalltalk, the mere absence of accessor methods doesn&amp;#8217;t prevent encapsulation intrusions.  Ruby has the instance_variable_get and instance_variable_set methods, and Smalltalk has instVarAt: and instVarAt:put:, but these methods are &amp;#8216;marked&amp;#8217; as slightly evil and reserved for dastardly deeds.&lt;/p&gt;
&lt;p&gt;An accessor method on the other hand seems much more like any other normal method.  In Smalltalk, convention is used to mark methods as private, although this is very weak consisting simply of putting private methods in a particular category in the browser, with no runtime check.  Ruby does provide runtime checking of both private and protected methods, although even this protection can be circumvented, using &lt;strong&gt;send&lt;/strong&gt;.&lt;/p&gt;
&lt;H2&gt;Summing Up&lt;/H2&gt;
&lt;p&gt;So in the end, the existence of and the tension between these two patterns demonstrates some key points:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Patterns present choices, and the best patterns provide enough information to make an informed decision on a case-by-case basis.&lt;/li&gt;
&lt;li&gt;The languages and the tools we use have an effect on the patterns and the decisions they engender.&lt;/li&gt;&lt;/ul&gt;</description>
      <pubDate>Fri, 15 Feb 2008 08:29:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:ef046ae9-bf0a-4b78-b095-53123a3bcdd8</guid>
      <author>Rick DeNatale</author>
      <link>http://talklikeaduck.denhaven2.com/articles/2008/02/15/best-practice-patterns-accessors-and-encapsulation</link>
      <category>ruby</category>
      <category>smalltalk</category>
      <category>best_practices</category>
      <category>kentbeck</category>
      <category>bestpracticepatterns</category>
      <category>patterns</category>
      <trackback:ping>http://talklikeaduck.denhaven2.com/articles/trackback/490</trackback:ping>
    </item>
    <item>
      <title>Whose Variable Is It Anyway?</title>
      <description>&lt;p&gt;The more I think about Ruby in relation to other object programming languages I&amp;#8217;ve worked with, the more I realize that there&amp;#8217;s a continuum of static vs. dynamic typing.&lt;/p&gt;  
&lt;p&gt;Ruby fits close to one end of that continuum. Understanding this can help understand how to best use the language. I recently had a quick look at Russ Olsen&amp;#8217;s new book &lt;a href="http://www.amazon.com/gp/product/0321490452?ie=UTF8&amp;#38;tag=denhaven2com-20&amp;#38;linkCode=as2&amp;#38;camp=1789&amp;#38;creative=9325&amp;#38;creativeASIN=0321490452"&gt;Design Patterns in Ruby&lt;/a&gt;&lt;img src="http://www.assoc-amazon.com/e/ir?t=denhaven2com-20&amp;#38;l=as2&amp;#38;o=1&amp;#38;a=0321490452" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /&gt; and looked at his section on the observer pattern.  I&amp;#8217;d just posted to ruby-talk about this pattern, how it was implemented in Smalltalk, and a more Rubyish implementation.  I&amp;#8217;ll get to that at the end of this article, but first I really feel the urge to talk about instance variables.&lt;/p&gt;
&lt;p&gt;If we view a type as a particular interpretation of a memory layout, I see something like this&lt;/p&gt;

	&lt;table style="border:1px solid black;"&gt;
		&lt;tr&gt;
			&lt;th&gt;Language &lt;/th&gt;
			&lt;th&gt;Outside &lt;/th&gt;
			&lt;th&gt;inside &lt;/th&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td&gt; Java &lt;/td&gt;
			&lt;td&gt; static &lt;/td&gt;
			&lt;td&gt; static &lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td&gt; Smalltalk &lt;/td&gt;
			&lt;td&gt; encapsulated &lt;/td&gt;
			&lt;td&gt; static &lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td&gt; Ruby &lt;/td&gt;
			&lt;td&gt; encapsulated &lt;/td&gt;
			&lt;td&gt; dynamic &lt;/td&gt;
		&lt;/tr&gt;
	&lt;/table&gt;




&lt;p&gt;The two columns represent how the object&amp;#8217;s innards &amp;#8220;look&amp;#8221; from outside the object, and inside the object (i.e. inside a method) respectively.&lt;/p&gt;

&lt;p&gt;In Java, subject to access modifiers, instance variables, a.k.a. fields, can be directly accessed.  No accessor method is required.  In Smalltalk and Ruby, instance variables of an object are only accessible while executing one of the object&amp;#8217;s methods.  Although both languages provide a bypass mechanism, instance_variable_get and instance_variable_set for Ruby; instVarAt: and instVarAt:put: for Smalltalk, these are both methods, and are to be used only in &amp;#8220;emergencies&amp;#8221; since they break the encapsulation of the object.&lt;/p&gt;

&lt;h2&gt;Static Instance Variable Binding&lt;/h2&gt;
&lt;p&gt;By static here, I mean that the code which accesses the instance variable uses information which is statically bound by the compiler. This is a subtlety which misses a lot of today&amp;#8217;s programmers &lt;a href="http://steve-yegge.blogspot.com/2007/06/rich-programmer-food.html"&gt;who don&amp;#8217;t understand what a compiler does,&lt;/a&gt; which is to take the textual, human written and readable source code and turn it into bits and bytes which can be executed by some form of computer.  The older wiser guys might just want to skim this section.&lt;/p&gt;
&lt;p&gt;That computer might be a real computer, like an Intel processor, or a virtual computer in the form of a software implemented virtual machine or interpreter. In the case of a real or virtual machine, there is an instruction set which gives the repertoire of the machine.  The program is executed by moving step by step, instruction by instruction. Now, if we have a simple C statement like:&lt;/p&gt;
&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_C "&gt;int a = b&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Then the instruction sequence for an imaginary computer might be something like:&lt;/p&gt;
&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;    load  reg2, 20(reg1)
    store reg2, 40(reg1)&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Which loads the second machine register from a word which is at an address 20 bytes after the address contained in machine register 1, and then stores that value into another word offset 40 bytes from register 1.  Here a and b are intended to be local temporary variables, and I&amp;#8217;ve decided that my compiler is using register 1 to point to the current activation stack frame.  Those magic numbers, 20 and 40 are computed by the compiler as part of it&amp;#8217;s function to map variables to memory locations.&lt;/p&gt;
&lt;p&gt;The idea that instructions might be different lengths is quite common in instruction set design.  Usually some number of bits at the beginning of the instruction is used to encode an &amp;#8216;op code&amp;#8217; like load or store, add, or subtract, etc.  Other bits are used to determine the presence and format of parameters for the operation.  Different instruction sets have different addressing modes, which allow memory to be addressed in various ways, such as the mode used above which addresses memory as an offset from a location held in a register. Other addressing modes might add another register used to index elements in an array, for example. Most real instruction sets have some unit of length for instructions, so for a given machine architecture, all instructions might be one or more words, or one or more bytes.&lt;/p&gt;
&lt;h2&gt;Bytecodes Are An Instruction Set Format&lt;/h2&gt;
&lt;p&gt;The term &amp;#8220;bytecode&amp;#8221; is simply a particular form of an instruction set, or rather a family of forms.  Most people associate the term with Java, and a particular instruction set, although the term predates Java, being used by Smalltalk and probably before.  It really means that the &amp;#8216;machine code&amp;#8217; instructions are represented as a series of bytes.  Many instructions are encoded by a single byte, although some require additional bytes in order to form a complete instruction. The general term bytecode simply means that the length unit for the instruction set is one byte.&lt;/p&gt;
&lt;p&gt;Although Java and Smalltalk implementations typically use bytecode instruction sets for their virtual machines, the actual set of bytecodes differs, much as the instruction set for an Intel Core Duo 2, differs from the instruction set for a PowerPC G4.&lt;/p&gt;
&lt;h2&gt;Classical Instance Variable Binding, Smalltalk Style&lt;/h2&gt;
&lt;p&gt;Now lets look at similar code in Smalltalk.  In this article, I&amp;#8217;m using the bytecodes defined by the out of print, &amp;#8220;Smalltalk:The Language and Its Implementation&amp;#8221;, a.k.a. &amp;#8220;The Blue Book&amp;#8221;, other Smalltalk implementations might be slightly different.&lt;/p&gt;
&lt;p&gt;Let&amp;#8217;s say that a and b here are instance variables.  The Smalltalk bytecodes&lt;/p&gt;
&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;    a := b&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Would look something like:&lt;/p&gt;
&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;    push_iv_4            # push instance-variable #4 
                             # onto the stack
    store_and_pop_iv_6   # store the top of the stack in
                             # instance-variable #6&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;In Smalltalk, those magic index numbers used to access instance variables are determined when the class definition is saved. In this case b turned out to be the 4th instance variable, and a the 6th.  Smalltalk bytecodes are optimized for small objects, the first 16 instance variables can all be pushed or popped with a single-byte instruction, if an object has more than 16 instance variables then those beyond the 16th need to be accessed via an extended push or store instruction, which allows up to 64 instance variables to be accessed.&lt;/p&gt;
&lt;p&gt;In Smalltalk, although instance variables aren&amp;#8217;t &lt;strong&gt;typed&lt;/strong&gt;, they are &lt;strong&gt;declared&lt;/strong&gt; in a class definition message executed when the class definition is saved.  Any time a class definition is saved, the indices for the instance variables of that class, and of any subclasses are (re)computed, and any methods in the class and it&amp;#8217;s subclasses are re-compiled to adjust the offsets. The instance variables defined in the topmost class get the first n offsets, each immediate subclasses instance variables get sequential offsets starting with the next available, and so forth.&lt;/p&gt;
&lt;p&gt;This is why I said above that inside a Smalltalk object, i.e. within it&amp;#8217;s methods, the object is mapped statically.  Changing the instance variable definitions requires re-compilation to avoid &amp;#8216;type-errors&amp;#8217; in the methods.&lt;/p&gt;
&lt;p&gt;Note that those &amp;#8216;emergency-only&amp;#8217; methods instvarAt: and instVarAt:put: map to the push_iv and store_and_pop_iv bytecodes, the first argument to both is the instance variable index.  This also means that they need to be used with care, since you need to know the offset of the instance variable. Now, at least Smalltalk can tell you if you try to access a non-existant instance variable slot but it can&amp;#8217;t tell that you&amp;#8217;re accessing the &lt;strong&gt;wrong&lt;/strong&gt; slot.&lt;/p&gt;
&lt;h2&gt;Java Field Binding&lt;/h2&gt;
&lt;p&gt;In Java, offsets are not compiled directly into the bytecodes, there&amp;#8217;s a level of indirection. Peter Haggar, with whom  I used to work at &lt;span class="caps"&gt;IBM&lt;/span&gt; wrote an &lt;a href="http://www.ibm.com/developerworks/ibm/library/it-haggar_bytecode/"&gt;article on Java bytecodes&lt;/a&gt; on developerworks. I hope he won&amp;#8217;t mind if I borrow one of his examples. Here&amp;#8217;s a simple accessor method&lt;/p&gt;
&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;public String employeeName()
{
    return name;
}&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
And the resultant bytecodes. (The 0, 1, and 4 are offsets from the beginning of the method)
&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;    Method java.lang.String employeeName()
    0 aload_0
    1 getfield #5 &amp;lt;Field java.lang.String name&amp;gt;
    4 areturn&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;What this code does first is to push a reference to the current object, &lt;strong&gt;this&lt;/strong&gt;, onto the stack.  Then the getfield instruction uses it&amp;#8217;s operand to replace the top two items on the stack with the value of the field.  So these two byte-codes (actually 3 bytes in total) are roughly equivalent to the Smalltalk push_iv bytecode, but for two differences:&lt;/p&gt;
&lt;ol&gt;
    &lt;li&gt;The Smalltalk push_iv opcode implicitly uses the receiver of the current method, whereas the getfield opcode needs another argument referencing the object whose instance variable is being accessed.&lt;/li&gt;
    &lt;li&gt;In Smalltalk the argument identifying the variable is an integer index, but in Java the argument is actually a reference to a field descriptor associated with the class of the object whose instance variable is being referenced.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The first difference is because in Java, unlike in Smalltalk, you can directly get and set public fields outside of of the objects methods, so since the object in question isn&amp;#8217;t implied, it has to be specified.&lt;/p&gt;
&lt;p&gt;The second difference is to allow for separate compilation.  The actual Java VM specification doesn&amp;#8217;t dictate how fields are mapped within objects, but the abstraction is to allow this mapping to be adjusted at the time classes are loaded.  If a subclass is compiled separately from it&amp;#8217;s superclass, it might get a new starting position for it&amp;#8217;s fields everytime it&amp;#8217;s loaded if one or it&amp;#8217;s superclasses has added or removed fields.&lt;/p&gt;
&lt;p&gt;So in order to access a Java field, the compiler needs to know the type of the object containing the field.  This is true whether we are inside a method or outside.&lt;/p&gt;
&lt;h2&gt;Instance Variables, The Ruby Way&lt;/h2&gt;
&lt;p&gt;In Ruby, instance variables aren&amp;#8217;t declared, so offsets can&amp;#8217;t be assigned statically. Instead, Ruby looks up instance variables dynamically, using the instance variable &lt;strong&gt;name&lt;/strong&gt; rather than an offset. Again this matches the &amp;#8216;emergency use&amp;#8217; messages, instance_variable_get and instance_variable_set take an instance variable name, complete with the &amp;#8221;@&amp;#8221; sigil, where the Smalltalk instVarAt: methods take an integer.&lt;/p&gt;
&lt;p&gt;In Ruby 1.8, this lookup is implemented in a fairly straightforward fashion. With a few exceptions, which I won&amp;#8217;t take the time to go into here, a Ruby object has a pointer named iv_tbl which points to a hash table which maps the instance variable names to values.  In Ruby 1.9, the implementation is a bit more clever, but the effects are the same.&lt;/p&gt;
&lt;h2&gt;So Whose Variable IS it Anyway?&lt;/h2&gt;
&lt;p&gt;Which brings us back to the title of this article.  In Java and Smalltalk, every instance of a given class has the same set of instance variables, albeit each with it&amp;#8217;s own value. The variables come into existence when they are declared, and the class is compiled or the class definition is saved.&lt;/p&gt;
&lt;p&gt;One thing I didn&amp;#8217;t mention in the discussion of Smalltalk is that, because traditional Smalltalk implementations don&amp;#8217;t separate the development environment from the run-time environment, when a class definition changes, besides requiring method recompilation for the class and it&amp;#8217;s subclasses, any existing instance variables need to be mutated to either add or remove the changed instance variables.  Back when he was working on the language self, which has dynamic resolution of instance variables like Ruby, Dave Ungar used to like to kill various Smalltalk implementations by adding an instance variable to the Object class.  The problem is that because we are trying to operate on the running system, the system usually trips over itself during such a change.  I tried this a few weeks ago with Squeak, and although it warned me twice that I shouldn&amp;#8217;t do that, it did try when I clicked that second &amp;#8220;Are you sure&amp;#8221; button, and crashed pretty quickly. Ruby does handle this as a matter of course, since instance variables are only added to individual objects when they are needed, and self inside a method really is duck-typed, actually more than duck-typed, since the needed instance variables appear just in time.&lt;/p&gt;
&lt;h2&gt;So you mentioned the Observer Pattern, What&amp;#8217;s All This Have To Do With That&lt;/h2&gt;
&lt;p&gt;One of the things which got me thinking about this again was a thread on ruby-talk some weeks ago about Ruby garbage collection and some of the things which keep Object from being considered garbage and being collected.  The Ruby GC tends to have problems if you use finalization and aren&amp;#8217;t &lt;strong&gt;really&lt;/strong&gt; careful about how you define your finalizers.&lt;/p&gt;
&lt;p&gt;One of the classic gotcha&amp;#8217;s in Smalltalk in this vein is the implementation of Object dependents, a.k.a. the Observer Pattern.  Smalltalk provides a mechanism to add dependent objects to any other object which, when it want&amp;#8217;s to notify it&amp;#8217;s dependents that it has changed, can simply send itself the changed message, which in turn sends each dependent the message update: with the changed object as the argument.&lt;/p&gt;
&lt;p&gt;This is the basis of the Model View Controller design in Smalltalk. Views register as dependents on Models, and when a model changes, any Views depending on it can react. This is the genesis of the Observer pattern from the &lt;a href="http://www.amazon.com/gp/product/0201633612?ie=UTF8&amp;#38;tag=denhaven2com-20&amp;#38;linkCode=as2&amp;#38;camp=1789&amp;#38;creative=9325&amp;#38;creativeASIN=0201633612"&gt;well known gang of four Design Patterns book&lt;/a&gt;&lt;img src="http://www.assoc-amazon.com/e/ir?t=denhaven2com-20&amp;#38;l=as2&amp;#38;o=1&amp;#38;a=0201633612" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /&gt; where Model, and View have been generalized to Subject and Observer respectively.&lt;/p&gt;
&lt;p&gt;In Smalltalk the ability to manage a list of dependents and notify them on changes is something that every object can do, but very few objects actually use this capability.  In order to avoid having an instance variable in every Smalltalk object to reference a dependents collection which is almost always empty, the default implementation actually keeps a global hash which maps objects with dependents to their dependent collection.&lt;/p&gt;
&lt;p&gt;The problem with this default implementation is that once an object gains a dependent, the object and it&amp;#8217;s dependent objects are permanently reachable, and therefore ineligible for garbage collection, unless the dependency is explicitly removed.  As a result of this, the classes of most objects which actually &lt;strong&gt;have&lt;/strong&gt; dependents reimplement the default methods to refer to the dependents collection via an instance value in the object with dependents. Squeak, for example provides a subclass of object called Model which provides such a GC friendly implementation.&lt;/p&gt;
&lt;p&gt;Which brings me to the implementation of the observer pattern in Ruby.  In his discussion of this pattern in his book, Russ Olsen provides a module which can be mixed into an object to allow it to have dependents:&lt;/p&gt;
&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_ruby "&gt;&lt;span class="keyword"&gt;module &lt;/span&gt;&lt;span class="module"&gt;Subject&lt;/span&gt;
  &lt;span class="keyword"&gt;def &lt;/span&gt;&lt;span class="method"&gt;initialize&lt;/span&gt;
    &lt;span class="attribute"&gt;@observers&lt;/span&gt; &lt;span class="punct"&gt;=&lt;/span&gt; &lt;span class="punct"&gt;[]&lt;/span&gt;
  &lt;span class="keyword"&gt;end&lt;/span&gt;

  &lt;span class="keyword"&gt;def &lt;/span&gt;&lt;span class="method"&gt;add_observer&lt;/span&gt;&lt;span class="punct"&gt;(&amp;amp;&lt;/span&gt;&lt;span class="ident"&gt;observer&lt;/span&gt;&lt;span class="punct"&gt;)&lt;/span&gt;
    &lt;span class="attribute"&gt;@observers&lt;/span&gt; &lt;span class="punct"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="ident"&gt;observer&lt;/span&gt;
  &lt;span class="keyword"&gt;end&lt;/span&gt;

  &lt;span class="keyword"&gt;def &lt;/span&gt;&lt;span class="method"&gt;delete_observer&lt;/span&gt;&lt;span class="punct"&gt;(&lt;/span&gt;&lt;span class="ident"&gt;observer&lt;/span&gt;&lt;span class="punct"&gt;)&lt;/span&gt;
    &lt;span class="attribute"&gt;@observers&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;delete&lt;/span&gt;&lt;span class="punct"&gt;(&lt;/span&gt;&lt;span class="ident"&gt;observer&lt;/span&gt;&lt;span class="punct"&gt;)&lt;/span&gt;
  &lt;span class="keyword"&gt;end&lt;/span&gt;

  &lt;span class="keyword"&gt;def &lt;/span&gt;&lt;span class="method"&gt;notify_observers&lt;/span&gt;
    &lt;span class="attribute"&gt;@observers&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;each&lt;/span&gt; &lt;span class="keyword"&gt;do&lt;/span&gt; &lt;span class="punct"&gt;|&lt;/span&gt;&lt;span class="ident"&gt;observer&lt;/span&gt;&lt;span class="punct"&gt;|&lt;/span&gt;
      &lt;span class="ident"&gt;observer&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;call&lt;/span&gt;&lt;span class="punct"&gt;(&lt;/span&gt;&lt;span class="constant"&gt;self&lt;/span&gt;&lt;span class="punct"&gt;)&lt;/span&gt;
    &lt;span class="keyword"&gt;end&lt;/span&gt;
  &lt;span class="keyword"&gt;end&lt;/span&gt;  
&lt;span class="keyword"&gt;end&lt;/span&gt;    &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This is a nice Ruby spin on the pattern, in that the Observers can be blocks, or any other object which responds to a call method which takes the Subject as its argument.&lt;/p&gt;
&lt;p&gt;Shortly before seeing the book, as a result of that GC thread, I&amp;#8217;d written my own variation on this, which let&amp;#8217;s any object be a subject, by opening up the Object class:&lt;/p&gt;
&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_ruby "&gt;&lt;span class="keyword"&gt;class &lt;/span&gt;&lt;span class="class"&gt;Object&lt;/span&gt;
    &lt;span class="keyword"&gt;def &lt;/span&gt;&lt;span class="method"&gt;add_observer&lt;/span&gt;&lt;span class="punct"&gt;(&amp;amp;&lt;/span&gt;&lt;span class="ident"&gt;observer&lt;/span&gt;&lt;span class="punct"&gt;)&lt;/span&gt;
      &lt;span class="punct"&gt;(&lt;/span&gt;&lt;span class="attribute"&gt;@observers&lt;/span&gt; &lt;span class="punct"&gt;||=&lt;/span&gt; &lt;span class="punct"&gt;[])&lt;/span&gt; &lt;span class="punct"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="ident"&gt;observer&lt;/span&gt;
    &lt;span class="keyword"&gt;end&lt;/span&gt;

    &lt;span class="keyword"&gt;def &lt;/span&gt;&lt;span class="method"&gt;delete_observer&lt;/span&gt;&lt;span class="punct"&gt;(&lt;/span&gt;&lt;span class="ident"&gt;observer&lt;/span&gt;&lt;span class="punct"&gt;)&lt;/span&gt;
      &lt;span class="ident"&gt;observers&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;delete&lt;/span&gt;&lt;span class="punct"&gt;(&lt;/span&gt;&lt;span class="ident"&gt;observer&lt;/span&gt;&lt;span class="punct"&gt;)&lt;/span&gt;
    &lt;span class="keyword"&gt;end&lt;/span&gt;

    &lt;span class="keyword"&gt;def &lt;/span&gt;&lt;span class="method"&gt;notify_observers&lt;/span&gt;
      &lt;span class="ident"&gt;observers&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;each&lt;/span&gt; &lt;span class="keyword"&gt;do&lt;/span&gt; &lt;span class="punct"&gt;|&lt;/span&gt;&lt;span class="ident"&gt;observer&lt;/span&gt;&lt;span class="punct"&gt;|&lt;/span&gt;
        &lt;span class="ident"&gt;observer&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;call&lt;/span&gt;&lt;span class="punct"&gt;(&lt;/span&gt;&lt;span class="constant"&gt;self&lt;/span&gt;&lt;span class="punct"&gt;)&lt;/span&gt;
      &lt;span class="keyword"&gt;end&lt;/span&gt;
    &lt;span class="keyword"&gt;end&lt;/span&gt;

    &lt;span class="ident"&gt;private&lt;/span&gt;
    &lt;span class="keyword"&gt;def &lt;/span&gt;&lt;span class="method"&gt;observers&lt;/span&gt;
      &lt;span class="attribute"&gt;@observers&lt;/span&gt; &lt;span class="punct"&gt;||&lt;/span&gt; &lt;span class="punct"&gt;[]&lt;/span&gt;
    &lt;span class="keyword"&gt;end&lt;/span&gt; 
&lt;span class="keyword"&gt;end&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Because of the fact that Ruby only adds instance variables on the fly as needed, we get the benefit of universal support for objects to be Subjects without requiring an observers instance variable for those objects which don&amp;#8217;t. The only cost is the potential namespace collision for the four method names.&lt;/p&gt;
&lt;h2&gt;Another Use of Dynamic Instance Variables&lt;/h2&gt;
&lt;p&gt;Recently I wrote an &lt;a href="http://www.infoq.com/news/2008/01/rails-resource-controller"&gt;article for InfoQ&lt;/a&gt; about &lt;a href="http://jamesgolick.com/resource_controller"&gt;James Golick&amp;#8217;s resource_controller plugin for Rails&lt;/a&gt; which allows you to write Rails controllers for RESTful resources which can automatically adapt for use in different resource nesting contexts.  This plugin makes good use of the dynamic nature of Ruby instance variables, automatically defining different instance variables in the controller to correspond to the end resource and each of its parent resources.&lt;/p&gt;
&lt;h2&gt;Whew!&lt;/h2&gt;
&lt;p&gt;This has turned out to be a rather long article, which I&amp;#8217;ve been meaning to write for some time.  I hope that someone finds it useful, or at least interesting.&lt;/p&gt;</description>
      <pubDate>Fri, 08 Feb 2008 16:14:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:bfb1599b-784b-403b-8fdf-90e68ecaa897</guid>
      <author>Rick DeNatale</author>
      <link>http://talklikeaduck.denhaven2.com/articles/2008/02/08/whose-variable-is-it-anyway</link>
      <category>ruby</category>
      <category>smalltalk</category>
      <category>java</category>
      <category>binding</category>
      <category>variables</category>
      <trackback:ping>http://talklikeaduck.denhaven2.com/articles/trackback/487</trackback:ping>
    </item>
    <item>
      <title>Alan Kay on the meaning of OOP</title>
      <description>&lt;img src="http://talklikeaduck.denhaven2.com/files/2008-01-01_alan_kay.jpg" alt="Alan Kay" class="tease-image" width="128px"/&gt;
I've written before in this blog about how the meaning of the term "object-oriented programming" got hijacked from it's original meaning. For example I go into this in some length &lt;a href="http://talklikeaduck.denhaven2.com/articles/2006/07/29/about-me"&gt;in my mini-memoirs.&lt;/a&gt;
&lt;p&gt;I recently ran into an interesting site with links to &lt;a href="http://e7l3.org/classics.html"&gt;"Classical Computer Science Texts"&lt;/a&gt;, which in turn led me to this &lt;a href="http://www.purl.org/stefan_ram/pub/doc_kay_oop_en"&gt;e-mail exchange with Alan Kay on the meaning of OOP from July of 2003.&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;This exchange gives support, with details, for my description of Kay's concept of what Object-Oriented Programming was supposed to mean.&lt;/p&gt; &lt;blockquote class="pullquote"&gt;I'm not against types, but I don't know of any type systems that aren't a complete pain, so I still like dynamic typing. &lt;br/&gt;- Alan Kay&lt;/blockquote&gt; 
&lt;p&gt;As Kay explains, the key concepts came from biological cell communications modeled as networked "whole computers" and a desire to "get rid of with data"&lt;/p&gt;
&lt;p&gt;As for the influence of Simula on Smalltalk's notion of classes and inheritance:&lt;/p&gt;
&lt;blockquote&gt;I didn't like the way Simula I or Simula 67 did inheritance (though I thought Nygaard and Dahl were just tremendous thinkers and  designers). So I decided to leave out inheritance as a built-in feature until I understood it better. - Alan Kay&lt;/blockquote&gt;
&lt;p&gt;And summing it up:&lt;/p&gt;
&lt;blockquote&gt;OOP to me means only messaging, local retention and protection and hiding of state-process, and extreme late-binding of all things. It can be done in Smalltalk and in LISP. There are possibly other systems in which this is possible, but I'm not aware of them.&lt;/blockquote&gt;
&lt;p&gt;I'd argue that you can do this in Ruby as well. I don't know if Ruby was on Kay's radar in mid-2003.&lt;/p&gt;

</description>
      <pubDate>Tue, 01 Jan 2008 14:39:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:f7442bb9-2a85-4aa9-945b-25d69c9133fb</guid>
      <author>Rick DeNatale</author>
      <link>http://talklikeaduck.denhaven2.com/articles/2008/01/01/alan-kay-on-the-meaning-of-oop</link>
      <category>ruby</category>
      <category>smalltalk</category>
      <category>types</category>
      <category>alankay</category>
      <trackback:ping>http://talklikeaduck.denhaven2.com/articles/trackback/484</trackback:ping>
    </item>
    <item>
      <title>Cool, but Stupid, Things I've Done</title>
      <description>&lt;div style='width:240; float:left; text-align:right; font-size:xx-small; border-width:1px; border-color:#444444; border-style:solid;margin-bottom:30px; margin-right:30px;' class='tease-image'&gt;
&lt;img width='240' height='162' alt='Cones' src='http://farm2.static.flickr.com/1156/525199388_4361019fd9_m.jpg'&gt;
&lt;br/&gt;
&lt;a href='http://flickr.com/photos/ericcastro/525199388/'&gt;Cones&lt;/a&gt;
&lt;br/&gt;&amp;copy;
&lt;a href='http://flickr.com/people/ericcastro'&gt;Eric Castro&lt;/a&gt;
&lt;br/&gt;&lt;a href='http://creativecommons.org/licenses/by/2.0/'&gt;&lt;img src='http://i.creativecommons.org/l/by/2.0/80x15.png' title='used under a Creative Commons Attribution License' width='80' height='15' border='0'/&gt;&lt;/a&gt;
&lt;/div&gt;
One of the things about working with software is that you can pretty much do anything you imagine.
&lt;p&gt;Many of these things can be cool.&lt;/p&gt;
&lt;p&gt;And many of them, particularly in retrospect, can be less than brilliant.&lt;/p&gt;
&lt;p&gt;Here are two of the more visible cool, but stupid things I've done in the past.&lt;/p&gt;



&lt;h2&gt;Visual VisualAge&lt;/h2&gt;
&lt;p&gt;Years ago, my position at IBM gave me the opportunity to visit other companies pushing the envelope in software development.  One such visit was to a small company in Santa Barbera, CA called Expertelligence, which at the time produced a version of common lisp for the Macintosh called &lt;a href="http://www.byte.com/art/9608/sec4/art2.htm"&gt;ExperCommonLisp&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;There I met an interesting young Frenchman by the name of Jean-Marie Hulot, who showed me a user interface tool written in ExperCommon Lisp.&lt;/p&gt;
&lt;p&gt;Sometime later I ran into Jean-Marie again at a meeting with Steve Jobs at NeXT.  Steve had hired Jean-Marie. The interface tool had been ported to Objective-C and had become the NeXT interface builder. It lives on to this day as part of the XCode tools for Mac OSX.&lt;/p&gt;
&lt;p&gt;I was impressed by what I'd seen, but by then I'd been working with Smalltalk for a while.  The visual construction of the UI was cool, but I didn't like the idea of being dumped back into the mundane world of compilers and make.  After having seen "Paree" in the form of the Smalltalk development environment, it was hard to imagine staying down on the farm.&lt;/p&gt;
&lt;p&gt;So, I thought, why not make something like the interface builder inside the Smalltalk environment, and a quick prototype was born.&lt;/p&gt;
&lt;p&gt;For some reason, I dubbed this the "Application Builder" with the idea that the combined UI Builder/IDE was for building more than just UIs.&lt;/p&gt;
&lt;p&gt;Well, after I showed the prototype around a bit, I got to show it to Earl Wheeler, who was the IBM executive responsible for IBMs software tools strategy (AD/Cycle).  He apparently liked what he saw, and funded a Smalltalk project based on my prototype.  This opened the door for the IBM Smalltalk products to come.&lt;/p&gt;
&lt;p&gt;Rather than getting intimately involved with the product development group, I stayed in advanced technology research.&lt;/p&gt;
&lt;p&gt;When Earl took on Smalltalk, the last thing he seemed to want was to introduce a new language.  But, because of the visual UI construction in my prototype, he rationalized "positioning" Smalltalk as a "generator."  Perhaps as a result of this, the product team got quite carried away with visual construction and made the project a complete visual programming language, and the product was dubbed &lt;a href="http://en.wikipedia.org/wiki/VisualAge"&gt;VisualAge&lt;/a&gt; as a result of a christening contest among the development team.&lt;/p&gt;
&lt;p&gt;In retrospect the streass on visual programming wasn't so smart.  The resulting programs were hard to understand, debug and maintain. Ken Auer &lt;a href="http://rubyhoedown2007.confreaks.com/session07.html"&gt;recently observed&lt;/a&gt; that it produced a lot of "Smalltalk" programmers who didn't learn Smalltalk.&lt;/p&gt;
&lt;p&gt;It also had a marketing effect on Smalltalk.  After IBM came out with VisualAge, ParcPlace renamed their ObjectWorks family of products as VisualWorks.&lt;/p&gt;
&lt;p&gt;IBM did eventually release IBM Smalltalk, unbundled from the visual programming componentry.&lt;/p&gt;
&lt;h2&gt;Too Much Transparency Considered Harmful&lt;/h2&gt;
&lt;p&gt;Sometime later, I had another "cool idea" and led a small development team to turn it into a product.  The idea was transparent distributed execution of Smalltalk programs, and the product was the IBM/Smalltalk Distributed feature.&lt;/p&gt;
&lt;p&gt;This was, if I may say so, a technical tour-de-force.  Completely written in Smalltalk, the feature allowed Smalltalk programs to comprise objects on different networked machines.  It was much more transparent that other distributed object technologies like Rubys DRB, Javas RMI, or Corba.  Everything worked off of Smalltalks reflection capabilities, there was no IDL. In fact we named it Smalltalk Distributed to distinguish it from HPs Distributed Smalltalk which was 'just' a binding of Smalltalk to CORBA.&lt;/p&gt;
&lt;p&gt;And the development environment was fully distributed as well, without too much work on our parts.  For example the regular Smalltalk debugger was able to follow execution threads (in Smalltalk threads are called Proessses) from machine to machine and back again. A Smalltalk block containing a return on one machine could be called from a method on another machine, and the distributed stack would unwind just like it would on a single machine. Normal process synchronization techniques would work as well.&lt;/p&gt;
&lt;p&gt;The key to making this work was implementing what I called a "logical" process which associated each Smalltalk process with a single local process on each physical machine involved in the logical process. The Debugger worked, because the Smalltalk debugger is, at heart, a process inspector, and by making the logical process mimic a normal process, the debugger was none the wiser.&lt;/p&gt;
&lt;p&gt;This was really cool technical stuff, but in reality it turned out to be stupid because making distributed method sends so transparent hides important facts such as that there can be orders of magnitude performance differences between a local and remote send and, probably more importantly, there are failure modes (like network outages) for a remote send which just don't occur for local sends.&lt;/p&gt;
&lt;p&gt;So just like cases where a building owner decides that it's prudent to put some obvious visual clue on a large floor-to-ceiling window to keep people from trying to walk through it, sometimes it's better to eschew transparency and make the programmer deal with reality rather than perception.&lt;/p&gt;</description>
      <pubDate>Sat, 17 Nov 2007 06:18:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:ddf2e13e-1398-4255-9ee4-998ab2300b71</guid>
      <author>Rick DeNatale</author>
      <link>http://talklikeaduck.denhaven2.com/articles/2007/11/17/cool-but-stupid-things-ive-done</link>
      <category>war_stories</category>
      <category>smalltalk</category>
      <category>visualage</category>
      <category>stupidity</category>
      <category>smalltalkdistributed</category>
      <trackback:ping>http://talklikeaduck.denhaven2.com/articles/trackback/482</trackback:ping>
    </item>
    <item>
      <title>A Chat with Matz, Classs Variable reversion, and A Mystery Explained</title>
      <description>&lt;img src="http://talklikeaduck.denhaven2.com/files/2007-11-02_ruby_conf_2007logo_200x_123.png" alt="Ruby Conf 2007logo 200x 123" height="123" width="200" style='border-width:1px; border-color:#444444; margin-bottom:30px; margin-right:30px;border-style:solid;float:left;'&gt;
I finally got to meet Matz in person today, and we had a nice little chat.
&lt;p&gt;I was pleased to learn that he follows this blog.  My readership might be small, but it's quality readership. One thing I told him was that as much as I love, and still love, Smalltalk, I really do feel that I love Ruby just a little bit more.&lt;/p&gt;
&lt;p&gt;We talked a bit about the upcoming stabilization of 1.9, which will be frozen as far as language and standard libary changes for the Christmas 2007 1.9.1 release, at which time transition from development to stable status. He has been backing out some of the differences between 1.8.x and 1.9.0. He told me that he had recently, or was soon to, revert the changes to the scoping of class variables.  It appears that class variables will continue to be shared between classes and subclasses.&lt;/p&gt;
&lt;p&gt;He also cleared up a technical ruby mystery that's been puzzling me for some time.&lt;/p&gt;
&lt;p&gt;About a year ago I wrote about a change in Ruby 1.9 which &lt;a href="http://talklikeaduck.denhaven2.com/articles/2006/10/09/a-subtle-change-to-mixin-semantics-in-ruby-1-9"&gt;cleaned up the semantics&lt;/a&gt; when modules included by a class are re-included in a subclass.  The mystery is that sometime after I wrote the article, in a subsequent revision of 1.9, this got dropped.  I never could find out why this happened, so today I took the opportunity to ask Matz in person.&lt;/p&gt;



&lt;p&gt;He agreed that the way that it worked temporarily was the right way for it to work, but it got dropped because YARV had difficulties with the change in implementing the &lt;strong&gt;super&lt;/strong&gt; keyword.&lt;/p&gt;
&lt;p&gt;We didn't go into further details, but here's my informed speculation on the situation.&lt;/p&gt;
&lt;p&gt;When you send a message to a Ruby object, what happens, at least notionally, is that a linked list of (pseudo)objects is searched to find the first one which contains a method with that name in its method hash. Let's call this the method lookup chain. The head of the chain is pointed to by the receiving objects klass field, and is either the singleton class of the object if it has one, or the Class of the object, links in the chain represent modules and classes in the ancestry of the object. If the end of the chain is reached a method_not_found message is generated and searched for beginning again from the beginning of the receiving objects method chain.&lt;/p&gt;
&lt;p&gt;Each link is either a class or a pseudo object marked as an "IClass" (for Included Class) whose method hash pointer points to the method hash of the Module it represents. Because module method hashes are shared in this way, changes modules methods will be visible to every class or module which includes the module immediately.&lt;/p&gt;
&lt;p&gt;When the 'receiver' is &lt;strong&gt;super&lt;/strong&gt;, the same kind of search occurs as for a send to &lt;strong&gt;self&lt;/strong&gt;, but instead of starting with the receivers method chain, we want to search starting with the link in the chain after the one in which the currently executing method was found.&lt;/p&gt;
&lt;p&gt;Smalltalk implementations typically reify methods as CompiledMethod objects which have an instance variable which refers to the class in which the method was defined. So a send to &lt;strong&gt;super&lt;/strong&gt; simply starts the search with the superclass of the currently executing CompiledMethods definition class.&lt;/p&gt;
&lt;p&gt;This approach doesn't work for Ruby because Modules can be included in multiple classes or modules, which means that methods defined in Modules can appear in multiple places in multiple method lookup chains.&lt;/p&gt;
&lt;p&gt;One way to find the right place to start searching for a method with &lt;strong&gt;super&lt;/strong&gt; as the receiver is to start from the beginning of &lt;strong&gt;self&lt;/strong&gt;s method lookup chain, search until we find the currently executing method, then start the &lt;strong&gt;super&lt;/strong&gt; search with the next link in the chain.  I believe that this is how Ruby works, except for that brief time in the evolution of 1.9.&lt;/p&gt;
&lt;p&gt;In Smalltalk you must name the message when you do a send to &lt;strong&gt;super&lt;/strong&gt;. In Ruby you can't.  Smalltalk, unlike Ruby, allows you to send a different message than the current one to &lt;strong&gt;super&lt;/strong&gt;. In Smalltalk, the keyword &lt;strong&gt;super&lt;/strong&gt; effectively means "&lt;strong&gt;self&lt;/strong&gt;, but resolve any messages starting with the superclass of the class which defined the currently executing method," while in Ruby it means something like, "the current message, but look for me after where you found the currently executing method."  This difference simplifies finding the current method in the chain.  We know we're looking for a method with the same name in both the first and second searches. Since each link in the chain has a hash of methods, it's generally faster to do a hash lookup on the name, and in the first stage of the search compare the value returned with the current method.&lt;/p&gt;
&lt;p&gt;This two-phase search for &lt;strong&gt;super&lt;/strong&gt; runs into a small snag when a modules method hash appears more than once in a given method lookup chain. The first stage &lt;strong&gt;super&lt;/strong&gt; search can find the wrong place in the chain.&lt;/p&gt;
&lt;p&gt;Here's some code similar to that in the earlier article.&lt;/p&gt;
&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_ruby "&gt;&lt;notextile&gt;&lt;span class="keyword"&gt;module &lt;/span&gt;&lt;span class="module"&gt;M&lt;/span&gt;
  &lt;span class="keyword"&gt;def &lt;/span&gt;&lt;span class="method"&gt;foo&lt;/span&gt; &lt;span class="comment"&gt;#foo_m&lt;/span&gt;
    &lt;span class="ident"&gt;puts&lt;/span&gt; &lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;foo in M1&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;
    &lt;span class="keyword"&gt;super&lt;/span&gt;
  &lt;span class="keyword"&gt;end&lt;/span&gt;
&lt;span class="keyword"&gt;end&lt;/span&gt;

&lt;span class="keyword"&gt;class &lt;/span&gt;&lt;span class="class"&gt;C1&lt;/span&gt;
  &lt;span class="ident"&gt;include&lt;/span&gt; &lt;span class="constant"&gt;M&lt;/span&gt;
&lt;span class="keyword"&gt;end&lt;/span&gt;

&lt;span class="keyword"&gt;class &lt;/span&gt;&lt;span class="class"&gt;C2&lt;/span&gt; &lt;span class="punct"&gt;&amp;lt;&lt;/span&gt; &lt;span class="constant"&gt;C1&lt;/span&gt;
  &lt;span class="keyword"&gt;def &lt;/span&gt;&lt;span class="method"&gt;foo&lt;/span&gt; &lt;span class="comment"&gt;#foo_c&lt;/span&gt;
    &lt;span class="ident"&gt;puts&lt;/span&gt; &lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;foo in C2&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;
    &lt;span class="keyword"&gt;super&lt;/span&gt;
  &lt;span class="keyword"&gt;end&lt;/span&gt;
&lt;span class="keyword"&gt;end&lt;/span&gt; 

&lt;span class="keyword"&gt;class &lt;/span&gt;&lt;span class="class"&gt;C3&lt;/span&gt; &lt;span class="punct"&gt;&amp;lt;&lt;/span&gt; &lt;span class="constant"&gt;C2&lt;/span&gt;
  &lt;span class="ident"&gt;include&lt;/span&gt; &lt;span class="constant"&gt;M&lt;/span&gt;
&lt;span class="keyword"&gt;end&lt;/span&gt;&lt;/notextile&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Admittedly this code is contrived, it's specifically crafted to expose the issue in the simplest way, C1, C2, and C3 would probably have other methods which don't need to be shown here.
&lt;p&gt;If every module inclusion in the above code created an IClass then the method chain for instances of C3 Would look like this:&lt;/p&gt;
&lt;img src="http://myskitch.com/rubyredrick/cam-20071103-014213.jpg" alt="Cam"&gt;
&lt;p&gt;The boxes with names inside represent the class objects, empty orange boxes represent IClass pseudo-objects, the blue box labeled M is the module object, and the blue labels represent the methods.&lt;/p&gt;
&lt;p&gt;Okay, now let's say we evaluate the expression:&lt;/p&gt;
&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_ruby "&gt;&lt;notextile&gt;&lt;span class="constant"&gt;C3&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;new&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;foo&lt;/span&gt;&lt;/notextile&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;ol&gt;
	&lt;li&gt;We first search the method chain for a foo method and the first one we find is foo_m in the first IClass, so we invoke it.&lt;/li&gt;
	&lt;li&gt;We reach the &lt;strong&gt;super&lt;/strong&gt; in foo_m, so we start at the beginning of the method chain to find it which we do in the first IClass, since this is a send to &lt;strong&gt;super&lt;/strong&gt;, we then look for the next mathod named foo, and we find foo_c in class C2, so we invoke it.&lt;/li&gt;
	&lt;li&gt;We reach the &lt;strong&gt;super&lt;/strong&gt; in foo_c, so we start at the beginning of the method chain to find it which we do in the first IClass, since this is a send to &lt;strong&gt;super&lt;/strong&gt;, we then look for the next mathod named foo, and we find foo_c in class C2, so we invoke that.&lt;/li&gt;
	&lt;li&gt;We reach the &lt;strong&gt;super&lt;/strong&gt; in foo_c, so we start at the beginning of the method chain to find it which we do in the first IClass, since this is a send to &lt;strong&gt;super&lt;/strong&gt;, we then look for the next mathod named foo, and we find foo_c in class C2, so we invoke that.&lt;/li&gt;
	&lt;li&gt;Houston, we have a problem!&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;So, including IClasses for a module more than once can lead to an infinite loop when there's a &lt;strong&gt;super&lt;/strong&gt;, if the two-part re-search is used.&lt;/p&gt;
&lt;p&gt;And this is most probably the reason why the code to include a module checks to see if the module is already included and doesn't actually re-include it in this, admittedly rare case.&lt;/p&gt;
&lt;p&gt;So late last year, some other mechanism must have been being used to find the start of the super method chain, to allow real module re-inclusion. Perhaps, whenever a method was invoked, a pointer to the Class or IClass where it was found was placed on the execution stack so that it could be found if needed to resolve &lt;strong&gt;super&lt;/strong&gt;, perhaps some other mechanism was used.&lt;/p&gt;
&lt;p&gt;Whatever method was used, it was apparently incompatible, or hard to implement efficiently with YARV, so when YARV became a standard part of 1.9, the old module inclusion logic came back.&lt;/p&gt;
&lt;p&gt;Oh well, being able to re-include really makes the semantics of Module inclusion clearer, seems a shame, albeit perhaps a rather small one.&lt;/p&gt;</description>
      <pubDate>Sat, 03 Nov 2007 02:51:00 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:d3f1cb74-7196-4237-b529-92666bfc8c2a</guid>
      <author>Rick DeNatale</author>
      <link>http://talklikeaduck.denhaven2.com/articles/2007/11/03/a-chat-with-matz-classs-variable-reversion-and-a-mystery-explained</link>
      <category>ruby</category>
      <category>smalltalk</category>
      <category>railsconf2007</category>
      <category>railsconf</category>
      <category>matz</category>
      <trackback:ping>http://talklikeaduck.denhaven2.com/articles/trackback/481</trackback:ping>
    </item>
    <item>
      <title>To paraphrase Kent Beck...</title>
      <description>&lt;p&gt;&lt;img src="http://talklikeaduck.denhaven2.com/files/merlin2tee.jpg" class="tease-image"/&gt;
I&amp;#8217;m catching up on my &lt;span class="caps"&gt;RSS&lt;/span&gt; feeds this afternoon, and I just ran across the 
&lt;a href="http://www.iunknown.com/2007/09/what-is-this-me.html"&gt;
latest from John Lam&lt;/a&gt;.  Which exposed an interesting coincidence.&lt;blockquote class="pullquote"&gt;Oh yes, Merlin is the original code-name for our team, which was originally IronPython but has now expanded to include the Dynamic Language Runtime and IronRuby. &lt;br/&gt;- John Lam&lt;/blockquote&gt;
&lt;p&gt;The codename for &lt;span class="caps"&gt;IBM&lt;/span&gt;&amp;#8217;s original VisualAge project was &amp;#8220;Camelot.&amp;#8221;  Various subcomponents
and follow-ons were dubbed with various names from Arthurian legend.  For example, there
were components with names like &amp;#8220;Lancelot&amp;#8221; and &amp;#8220;Guinivere.&amp;#8221;&lt;/p&gt;
&lt;p&gt;Sometime after the initial success of VisualAge, it was decided that &lt;span class="caps"&gt;IBM&lt;/span&gt; would actually 
produce a separate Smalltalk language and &lt;span class="caps"&gt;IDE&lt;/span&gt; packaging, a product which was originally named
&amp;#8220;IBM Smalltalk&amp;#8221; at launch.&lt;/p&gt;
&lt;p&gt;But during development &lt;span class="caps"&gt;IBM&lt;/span&gt; Smalltalk had Arthur&amp;#8217;s wizard as its namesake.  As usual there
were tee shirts, and this article starts with a picture I just took of my copy of the &lt;span class="caps"&gt;IBM&lt;/span&gt;
Merlin Tee, which my wife still uses as an exercise tee.
And in case you can&amp;#8217;t read them, the words in the
crystal ball read &amp;#8220;think &lt;span class="caps"&gt;BIG&lt;/span&gt;/TALK small&amp;#8221; a combined reference to &lt;span class="caps"&gt;IBM&lt;/span&gt;, Smalltalk, and I suppose, Teddy Roosevelt.
&lt;img src="http://talklikeaduck.denhaven2.com/files/merlin1tee.jpg" class="tease-image"/&gt;
Now old Merlin might look more like a Swami than the wizard of Camelot, but here&amp;#8217;s the proof
from the front of the shirt:&lt;/p&gt;
&lt;p&gt;So to paraphrase my old buddy Kent Beck, I knew that Microsoft was trying to implement
Ruby, but I didn&amp;#8217;t know it would be called Merlin!&lt;/p&gt;&lt;/p&gt;</description>
      <pubDate>Sun, 02 Sep 2007 17:35:00 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:5bc282b9-04f1-4c02-9707-414a10802e05</guid>
      <author>Rick DeNatale</author>
      <link>http://talklikeaduck.denhaven2.com/articles/2007/09/02/to-paraphrase-kent-beck</link>
      <category>ruby</category>
      <category>war_stories</category>
      <category>smalltalk</category>
      <category>ironruby</category>
      <category>ibmsmalltalk</category>
      <trackback:ping>http://talklikeaduck.denhaven2.com/articles/trackback/459</trackback:ping>
    </item>
  </channel>
</rss>
