<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>DanielWaechter.com &#187; Programming</title>
	<atom:link href="http://blog.danielwaechter.com/category/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.danielwaechter.com</link>
	<description>just another geek blog</description>
	<lastBuildDate>Fri, 11 Jul 2008 01:33:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>The Long Road Back to C++</title>
		<link>http://blog.danielwaechter.com/programming/the-long-road-back-to-cpp/</link>
		<comments>http://blog.danielwaechter.com/programming/the-long-road-back-to-cpp/#comments</comments>
		<pubDate>Thu, 10 Jul 2008 01:30:34 +0000</pubDate>
		<dc:creator>Daniel Waechter</dc:creator>
				<category><![CDATA[C]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Game development]]></category>
		<category><![CDATA[Rant]]></category>
		<category><![CDATA[Web development]]></category>

		<guid isPermaLink="false">http://blog.danielwaechter.com/?p=13</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<h3>Where I&#8217;m Coming From</h3>
<p>I used to be very much a &#8220;C&#8221; guy.  After learning BASIC and Pascal in my early teens, I cut my chops on C and &#8211; despite a few struggles &#8211; fell in love with it.  The language felt right; it was close to the metal, but far enough away that programming it it could be pleasant.  It helped me truly build a model of computation in my head which I think has served me well.</p>
<p>After getting into the web industry, however, I began to leave C behind.  I coded in it less and less, since the industry outside of J2EE pretty much runs on dynamic languages (at that time, Perl &#8211; now PHP, ASP, Python, etc.).  These languages always felt a little messy to me; I didn&#8217;t know what was really going on at the metal any more, like it felt like I did with C.  Automatic memory management felt like a black box, and it always seemed I couldn&#8217;t optimize my data structures except at the algorithm level.  And even then, who knew what the GC was doing in the background.</p>
<p>Over time, however, I came to embrace them &#8211; even to the point of spending a good deal of my free time playing in Lisp, Scheme, and SmallTalk.  With processing power and memory becoming cheaper and cheaper, it was less necessary to worry about the overhead in dynamic languages, at least for my purposes.  They tend to run plenty fast enough for web applications (where most performance problems are I/O- or DB-bound), and if they don&#8217;t then there&#8217;s always caching or throwing more hardware at the problem.  If you know what you&#8217;re doing, the medium lends itself to the dynamic language programming style very well.  It&#8217;s a common joke that PHP&#8217;s memory leaks don&#8217;t matter if a page request only lasts a second, and it&#8217;s basically true; who cares about optimizing a process that works to your needs?  Reach the equilibrium between programmer time and project requirements, then move on to the next thing.</p>
<p>My old self would scoff at that attitude.  It seems lazy, and it is.  It still makes me uncomfortable.  But it&#8217;s the way the web industry is built; the seat-of-the-pants, fly-by-night, hack-it-till-you-make-it attitude.</p>
<h3>Where I&#8217;d Like To Go</h3>
<p>However, I&#8217;ve got a bit of a problem.  A long-time goal of mine has been to get into the PC game industry, ever since I wrote my first &#8220;Hello, World&#8221; in BASIC when I was 12.  A kid getting into programming to write games is almost cliche, but it&#8217;s true; there are few teenagers that dream about writing database software or eCommerce sites.  When we grow up our tastes often change, but sometimes they don&#8217;t.  Case in point:  after a decade in the web industry, I <i>still</i> want to work on real, wide-release, 3d games for a living.</p>
<p>There&#8217;s a small problem with moving to the game industry after the web industry, however.  The programming culture is almost entirely different.  The dynamic languages that I&#8217;ve mostly been immersed in at work &#8211; except for C# &#8211; are relegated to scripting in the game industry.  Real developer positions, for the foreseeable future, have one almost ubiquitous language: C++.</p>
<p>That&#8217;s changing, somewhat, of course.  Some development houses I understand are moving to C#, especially Xbox developers.  Microsoft is pushing <a href="http://en.wikipedia.org/wiki/Microsoft_XNA">XNA</a>, which runs on .NET.  Then there are other enterprising folks who <a href="http://en.wikipedia.org/wiki/Game_Oriented_Assembly_Lisp">refuse to conform</a>.  But for most places, C++ still seems to be the language of choice for PC games.</p>
<p>So, basically, I made a choice.  A while ago, I started sharpening my C++ skills again.</p>
<h3>The Long Road Ahead</h3>
<p>Now, in the hierarchy of languages that I enjoy coding in, C++ ranks somewhere above <a href="http://en.wikipedia.org/wiki/COBOL">COBOL</a> but below <a href="http://en.wikipedia.org/wiki/Logo_(programming_language)">Logo</a>; it is a complicated beast of a thing, with so many gotchas and corner cases that I&#8217;m sure it would make a Pharisee sweat.  I actually derive real pleasure from the rantings of <a href="http://yosefk.com/">Yossi Kreinin</a> in his <a href="http://yosefk.com/c++fqa/">C++ FQA Lite</a>; even when I think he&#8217;s being somewhat unfair to the <a href="http://www.parashift.com/c++-faq-lite/">C++ FAQ</a> authors, and even when I disagree with him on substantive issues, he still usually has interesting criticisms.</p>
<p>So, if I am so critical of C++, why am I studying it?  Very simply &#8211; because C++ is still the industry language for game development.  This is true just as much for historical reasons as it is for practical ones; arguably, there are better languages than C++ at the same level, without turning to dynamic or managed languages.  But industry standard is industry standard, and until that tide turns, those of us who&#8217;d like to work with that industry have to tag along.</p>
<p>Now, I consider myself fairly proficient with C++ for someone who hasn&#8217;t shipped anything in it (it&#8217;s not exactly number one in my current field).  I have most of the important bits of the language in my head, and I&#8217;m aware of things like <a href="http://en.wikipedia.org/wiki/Resource_acquisition_is_initialization">RAII</a> and how to implement patterns, etc.  I&#8217;ve read Scott Meyer&#8217;s <a href="http://www.amazon.com/gp/redirect.html?ie=UTF8&#038;location=http%3A%2F%2Fwww.amazon.com%2FEffective-Specific-Addison-Wesley-Professional-Computing%2Fdp%2F0201924889&#038;tag=garthnaksjour-20&#038;linkCode=ur2&#038;camp=1789&#038;creative=9325">two</a><img src="http://www.assoc-amazon.com/e/ir?t=garthnaksjour-20&amp;l=ur2&amp;o=1" width="1" height="1" alt="" style="border:none !important; margin:0px !important;" /> <a href="http://www.amazon.com/gp/redirect.html?ie=UTF8&#038;location=http%3A%2F%2Fwww.amazon.com%2FMore-Effective-Addison-Wesley-Professional-Computing%2Fdp%2F020163371X&#038;tag=garthnaksjour-20&#038;linkCode=ur2&#038;camp=1789&#038;creative=9325">books</a><img src="http://www.assoc-amazon.com/e/ir?t=garthnaksjour-20&amp;l=ur2&amp;o=1" width="1" height="1" alt="" style="border:none !important; margin:0px !important;" /> (though I haven&#8217;t fully internalized it all), and I&#8217;ve even <em>built stuff</em> in the language.</p>
<p>That said, it easily takes me up to two to ten times longer to implement <em>and debug</em> C++ code than in a dynamic language like Ruby or Lisp, depending on the complexity.  Part of that is, of course, the language (and implementations) &#8211; no lexical closures (<a href="#C++0x">yet</a>), no first-class functions (<a href="#Cpp0x">yet</a>) (function pointers don&#8217;t count), no <a href="http://en.wikipedia.org/wiki/Multiple_dispatch">multiple dispatch</a> (if you&#8217;ve never used it, it is <strong>unbelievably useful</strong>), gratuitous overloading of C keywords (like &#8220;static&#8221;), no standard ABI, private variables stored in header files (I understand why, and it can be avoided with <a href="http://en.wikipedia.org/wiki/Pimpl">pimpl</a>, but it still bothers me), cryptic error messages (especially for templates, but other times as well), slow compilation&#8230;I can go on.  One of the more irritating things is the default copy-constructors, and these days I just throw <a href="http://www.boost.org/doc/libs/1_35_0/boost/noncopyable.hpp">boost::noncopyable</a> onto my classes unless I know consumers will need it (which is less often than you may think).</p>
<p><a name="Cpp0x" href="http://en.wikipedia.org/wiki/C%2B%2B0x">C++0x</a> has some improvements.  For example, I can&#8217;t wait for <a href="http://herbsutter.wordpress.com/2008/06/20/type-inference-vs-staticdynamic-typing/">type inference</a>; if the compiler can figure out what type I want, then why should I spell it out every time (though there are some limitations<sup><a href="#tlrbtc_fn1" name="tlrbtc_fn1_ref">1</a></sup>)?  Even better, we&#8217;re going to have <a href="http://herbsutter.wordpress.com/2008/03/29/trip-report-februarymarch-2008-iso-c-standards-meeting/">real lambdas and closures</a>!  But who knows how long it&#8217;ll take to implement &#8211; we&#8217;re <a href="http://en.wikipedia.org/wiki/C99#Support_by_major_compilers">still</a> <a href="http://gcc.gnu.org/c99status.html">waiting</a> for C99.  Hopefully we&#8217;ll at least get early uptake of the most important features.  <a href="http://en.wikipedia.org/wiki/Technical_Report_1">TR1</a> is already <a href="http://blogs.msdn.com/vcblog/archive/2008/01/08/q-a-on-our-tr1-implementation.aspx">available for VC9</a>.</p>
<h3>Qi&#x0101;n L&#464; Zh&#x012B; H&aacute;ng, Sh&#464; Y&uacute; Z&uacute; Xi&agrave;<sup><a href="#tlrbtc_fn2" name="tlrbtc_fn2_ref">2</a></sup></h3>
<p>I still have a ways to go.  I&#8217;m in the playing around with various projects in C++, trying to be idiomatic rather than cute or clever.  At the same time, I&#8217;m going through Sutter&#8217;s <a href="http://www.amazon.com/gp/redirect.html?ie=UTF8&#038;location=http%3A%2F%2Fwww.amazon.com%2FExceptional-Engineering-Programming-Solutions-Depth%2Fdp%2F0201615622&#038;tag=garthnaksjour-20&#038;linkCode=ur2&#038;camp=1789&#038;creative=9325">Exceptional C++</a><img src="http://www.assoc-amazon.com/e/ir?t=garthnaksjour-20&amp;l=ur2&amp;o=1" width="1" height="1" alt="" style="border:none !important; margin:0px !important;" /> and <a href="http://www.amazon.com/gp/redirect.html?ie=UTF8&#038;location=http%3A%2F%2Fwww.amazon.com%2FCoding-Standards-Guidelines-Practices-Depth%2Fdp%2F0321113586&#038;tag=garthnaksjour-20&#038;linkCode=ur2&#038;camp=1789&#038;creative=9325">C++ Coding Standards</a><img src="http://www.assoc-amazon.com/e/ir?t=garthnaksjour-20&amp;l=ur2&amp;o=1" width="1" height="1" alt="" style="border:none !important; margin:0px !important;" />, internalizing good habits.  It&#8217;s a little tough returning to the world of static typing, (semi-)manual memory management, and complex builds after such a long hiatus, but it&#8217;s worth the rewards.  A longtime dream realized&mdash;becoming a real game developer.</p>
<p>I welcome the challenge.</p>
<div class="footnotes">
<p><sup><a name="tlrbtc_fn1" href="#tlrbtc_fn1_ref">1</a></sup>For example, if you create a <code>vector&lt;int&gt; v</code>, you might want to retrieve a <code>::const_iterator</code> from <code>v.begin()</code>.  Unfortunately, <code>auto i = v.begin()</code> will only return the most obvious type, which in this case is a plain <code>::iterator</code>, and there doesn&#8217;t seem to be a way to specify an alternate.  You&#8217;ll still have to specify <code>vector&lt;int&gt;::const_iterator ci = v.begin()</code>.  Oh well.</p>
<p><sup><a name="tlrbtc_fn2" href="#tlrbtc_fn2_ref">2</a></sup>&#8220;A journey of a thousand <i>li</i> starts with a single step.&#8221; -<a href="http://en.wikipedia.org/wiki/Laozi">Laozi</a></p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.danielwaechter.com/programming/the-long-road-back-to-cpp/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Making Smalltalk (applications)</title>
		<link>http://blog.danielwaechter.com/programming/making-smalltalk-applications/</link>
		<comments>http://blog.danielwaechter.com/programming/making-smalltalk-applications/#comments</comments>
		<pubDate>Thu, 30 Aug 2007 02:21:19 +0000</pubDate>
		<dc:creator>Daniel Waechter</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Smalltalk]]></category>

		<guid isPermaLink="false">http://blog.danielwaechter.com/programming/making-smalltalk-applications/</guid>
		<description><![CDATA[So I&#8217;ve been playing with Smalltalk, specifically Squeak, for a while now, and I&#8217;ve been trying to come up with a project. I&#8217;ve decided ultimately to build a simple Paint-by-Number game (example), just to see how it works out. I&#8217;m going to use TDD and continuous refactoring, after the fashion of this excellent tutorial, and [...]]]></description>
			<content:encoded><![CDATA[<p>So I&#8217;ve been playing with Smalltalk, specifically <a href="http://www.squeak.org/">Squeak</a>, for a while now, and I&#8217;ve been trying to come up with a project.  I&#8217;ve decided ultimately to build a simple Paint-by-Number game (<a href="http://www.webpbn.com/">example</a>), just to see how it works out.  I&#8217;m going to use TDD and continuous refactoring, after the fashion of <a href="http://squeak.preeminent.org/tut2007/html/index.html">this excellent tutorial</a>, and I&#8217;m going to build off of Damien Cassou&#8217;s <a href="http://damien.cassou.free.fr/squeak-dev/">squeak-dev image</a>.</p>
<p>This should be interesting.  Before encountering (Smalltalk-inspired) <a href="http://en.wikipedia.org/wiki/Objective-C">Objective-C</a> a few years ago and then (also Smalltalk-inspired) <a href="http://www.ruby-lang.org/en/">Ruby</a>, my primary experience with OOP had been C++ and Java &#8211; both of which had left a rather sour taste in my mouth.  Sure, I could see a few advantages, but they didn&#8217;t seem worth it &#8211; and now I realize why.  Most development in those languages is really OINO &#8211; OOP In Name Only.  People actually program procedurally, and create just as much (sometimes more!) spaghetti code as in traditional procedural languages!</p>
<p>One thing about Smalltalk that I think encourages &#8220;true&#8221; OOP development is the way that the development environment works.  In C++ and Java, the file and class are the units of account &#8211; but in Smalltalk, all you see is <i>one method at a time</i>.  I think this is an important observation; it actually encourages the developer to think more granularly, developing smaller and more targeted methods.  Methods are visually separated from the class definition from each other &#8211; even instance and class methods are completely visually separated.  My hypothesis is that this has a valuable psychological impact on design.</p>
<p>Interestingly, though, Ruby and Python developers still seem to do this.  Perhaps not with the tenacity that Smalltalk programmers seem to, but I don&#8217;t seem to find ridiculously long procedures-masquerading-as-methods in their applications as often.  Maybe it&#8217;s because of the nature of the communities, or maybe I just don&#8217;t have a large enough sampling of code.  In any case, it&#8217;s an observation.</p>
<p>So, we&#8217;ll see how I do with this little project.  I don&#8217;t imagine it should be too terribly difficult &#8211; the problem seems easily solved, at least from a distance.  But now my first decision &#8211; how do I store puzzles?</p>
<p>This may not be as trivial as it sounds.  The old-style Perl programmer in me wants to store it as a packed string.  The C programmer wants a multi-dimensional array.  The Lisper wants perhaps an array, perhaps a list of lists.  But what&#8217;s the Smalltalk Way?  A multi-dimensional array of &#8220;Cell&#8221; objects?</p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fblog.danielwaechter.com%2Fprogramming%2Fmaking-smalltalk-applications%2F&amp;linkname=Making%20Smalltalk%20%28applications%29"><img src="http://blog.danielwaechter.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://blog.danielwaechter.com/programming/making-smalltalk-applications/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Thoughts on Rails</title>
		<link>http://blog.danielwaechter.com/programming/thoughts-on-rails/</link>
		<comments>http://blog.danielwaechter.com/programming/thoughts-on-rails/#comments</comments>
		<pubDate>Wed, 14 Feb 2007 00:17:00 +0000</pubDate>
		<dc:creator>Daniel Waechter</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Rails]]></category>

		<guid isPermaLink="false">http://blog.danielwaechter.com/?p=5</guid>
		<description><![CDATA[So lately, I have been stretching my legs in a &#8220;new&#8221; framework &#8211; Ruby on Rails. While it is not so new in Internet terms, it&#8217;s still maturing and slowly gaining new users. I may not be contributing anything particularly new with this blog entry, but I needed a place to organize my thoughts on [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.rubyonrails.com/"><img src="/images/rails.png" style="float: right;margin: 5px;" alt="Ruby on Rails" /></a><br />
So lately, I have been stretching my legs in a &#8220;new&#8221; framework &#8211; <a href="http://www.rubyonrails.com/">Ruby on Rails</a>.  While it is not so new in Internet terms, it&#8217;s still maturing and slowly gaining new users.  I may not be contributing anything particularly new with this blog entry, but I needed a place to organize my thoughts on the subject.</p>
<h3>Rails Philosophy</h3>
<p>So, the primary Rails philosophy is &#8220;Convention over Configuration&#8221;.  This is the biggest selling point for any domain-specific application framework, to me &#8211; how much boiler-plate do I have to write before I can start mucking with actual logic?  Some of the nicest parts of Rails are the things that it Just Does out of the box.  Database access and abstraction, file structure organization, standards for separation of concerns and unit tests &#8211; all of these normal tasks that affect <em>every</em> web application are taken care of for you ahead of time.  That is a remarkably powerful tool.</p>
<p>Of course, this alone is nothing unique or original with Rails.  One of the things I liked the most about the <a href="http://www.fusebox.org/">Fusebox</a> framework for <a href="http://www.adobe.com/products/coldfusion/">ColdFusion</a> was that it provides several of these abstractions out of the box.  Now, Fusebox isn&#8217;t nearly as complex of a framework as Rails &#8211; it doesn&#8217;t begin to approach things like ORM, pluggable modules, AJAX support, etc.  Even its handling of templates is pretty rudimentary by comparison.  But it <em>does</em> have &#8220;opinions&#8221; about software development, and those made it a joy to architect in versus something like raw ColdFusion, PHP, or ASP.</p>
<h3>A Java Interlude</h3>
<p>Compare this with <a href="http://www.devx.com/ibm/Article/16365">&#8220;Hello World&#8221; in J2EE</a>.   Look at the steps involved for a &#8220;typical distributed J2EE application&#8221;:</p>
<ol>
<li>Create the EJB project and the HelloWorldEntity container-managed entity bean (CMP)</li>
<li>Create the EJB to RDB mapping using Cloudscape for the HelloWorldEntity CMP</li>
<li>Create a HelloWorldSession stateless session bean</li>
<li>Generate WebSphere deployed code</li>
<li>Create a server project</li>
<li>Binding the datasource to the HelloWorldEntity CMP</li>
<li>Create a data source and Cloudscape database tables</li>
<li>Creating a Java application client project and implementation</li>
<li>Create the Web project and a simple Java bean to read and write properties</li>
<li>Create the HelloWorldServlet servlet</li>
<li>Create the HTML home page</li>
<li>Create the JSP for final presentation to the user</li>
<li>Create a reference to the EJB session bean</li>
<li>Run the full application on the server</li>
</ol>
<p>Does this really provide so much more than Rails and its ilk to be worth it?  I&#8217;m not seeing it.</p>
<p>While J2EE certainly has <em>some</em> conventions, they are at a very low level of abstraction.  This may provide flexibility for producing any sort of application you want.  But at the same time, that much time spent writing boiler-plate in every app has to be a pain.  I will admit that I am no expert in J2EE (I&#8217;ve never written anything serious in it), so if this is an unfair characterization, let me know.  But it seems to me that any J2EE web application would take at least twice as long to write as a simple scripting language like PHP, and probably an order of magnitude longer to write than something in Rails or <a href="http://www.djangoproject.com/">Django</a>.  Even with static typing, code generators, and IntelliJ, there seems that so much complexity can only complicate matters and ultimately <em>introduce</em> errors (or bad practices) in all but the most careful teams.</p>
<p>But enough dumping on Java.  The truth is, as a language, I like it better than a lot of others.  And I have a lot of respect for Guy Steele when he <a href="http://people.csail.mit.edu/gregs/ll1-discuss-archive-html/msg04045.html">writes</a>:</p>
<blockquote><p>&#8220;And you&#8217;re right: we were not out to win over the Lisp programmers;<br />
we were after the C++ programmers.  We managed to drag a lot of them about halfway to Lisp.  Aren&#8217;t you happy?&#8221;</p></blockquote>
<p>But at least from afar, the whole Java web application world seems ridiculous.</p>
<h3>Back to Rails</h3>
<p>Another thing I like about Rails is the Ruby language itself.  It definitely has the feel of a Smalltalk-Lisp-Perl hybrid &#8211; with its emphasis on &#8220;everything-is-an-object&#8221; and blocks, combined with a seat-of-your-pants, &#8220;static typing? what&#8217;s that?&#8221; scripting language feel.  Look at some of these little snippets:</p>
<p>Using ActiveSupport&#8217;s <a href="http://api.rubyonrails.com/classes/Symbol.html#M000007">Symbol#to_proc</a>:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">1</span>, <span style="color:#006666;">2</span>, <span style="color:#006666;">3</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">map</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&amp;</span>:to_s<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#008000; font-style:italic;">#=&gt; [&quot;1&quot;, &quot;2&quot;, &quot;3&quot;]</span></pre></div></div>

<p>Array shuffling:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">class</span> <span style="color:#CC0066; font-weight:bold;">Array</span>
  <span style="color:#9966CC; font-weight:bold;">def</span> shuffle
    n = <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006600; font-weight:bold;">&#93;</span>
    <span style="color:#9966CC; font-weight:bold;">while</span> !empty?
      n <span style="color:#006600; font-weight:bold;">&lt;&lt;</span> delete_at<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0066; font-weight:bold;">rand</span><span style="color:#006600; font-weight:bold;">&#40;</span>size<span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
    n
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
<span style="color:#008000; font-style:italic;"># Usage</span>
<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">1</span>,<span style="color:#006666;">2</span>,<span style="color:#006666;">3</span>,<span style="color:#006666;">4</span>,<span style="color:#006666;">5</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">shuffle</span> <span style="color:#008000; font-style:italic;">#=&gt; [2, 4, 5, 1, 3]</span></pre></div></div>

<p><a href="http://www.nobugs.org/developer/ruby/method_finder.html">MethodFinder</a>, in particular, kind of blew me away:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">irb<span style="color:#006600; font-weight:bold;">&gt;</span> MethodFinder.<span style="color:#9900CC;">show</span><span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color:#996600;">&quot;hello&quot;</span>, <span style="color:#006666;">5</span> <span style="color:#006600; font-weight:bold;">&#41;</span>
<span style="color:#996600;">&quot;hello&quot;</span>.<span style="color:#9900CC;">length</span> == <span style="color:#006666;">5</span>
<span style="color:#996600;">&quot;hello&quot;</span>.<span style="color:#9900CC;">size</span> == <span style="color:#006666;">5</span>
<span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;length&quot;</span>, <span style="color:#996600;">&quot;size&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span>
&nbsp;
irb<span style="color:#006600; font-weight:bold;">&gt;</span> MethodFinder.<span style="color:#9900CC;">show</span><span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color:#996600;">&quot;foo&quot;</span>, <span style="color:#996600;">&quot;foobar&quot;</span>, <span style="color:#996600;">&quot;bar&quot;</span> <span style="color:#006600; font-weight:bold;">&#41;</span>
<span style="color:#996600;">&quot;foo&quot;</span>.<span style="color:#006600; font-weight:bold;">&lt;&lt;</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;bar&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span> == <span style="color:#996600;">&quot;foobar&quot;</span>
<span style="color:#996600;">&quot;foo&quot;</span>.<span style="color:#9900CC;">concat</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;bar&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span> == <span style="color:#996600;">&quot;foobar&quot;</span>
<span style="color:#996600;">&quot;foo&quot;</span>.<span style="color:#006600; font-weight:bold;">+</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;bar&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span> == <span style="color:#996600;">&quot;foobar&quot;</span>
<span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;&lt;&lt;&quot;</span>, <span style="color:#996600;">&quot;concat&quot;</span>, <span style="color:#996600;">&quot;+&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span>
irb<span style="color:#006600; font-weight:bold;">&gt;</span> MethodFinder.<span style="color:#9900CC;">show</span><span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color:#006666;">3.14159</span>, <span style="color:#006666;">3</span> <span style="color:#006600; font-weight:bold;">&#41;</span>
3.14159.<span style="color:#9900CC;">round</span> == <span style="color:#006666;">3</span>
3.14159.<span style="color:#9900CC;">truncate</span> == <span style="color:#006666;">3</span>
3.14159.<span style="color:#9900CC;">to_i</span> == <span style="color:#006666;">3</span>
3.14159.<span style="color:#9900CC;">prec_i</span> == <span style="color:#006666;">3</span>
3.14159.<span style="color:#9900CC;">floor</span> == <span style="color:#006666;">3</span>
3.14159.<span style="color:#9900CC;">to_int</span> == <span style="color:#006666;">3</span>
<span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;round&quot;</span>, <span style="color:#996600;">&quot;truncate&quot;</span>, <span style="color:#996600;">&quot;to_i&quot;</span>, <span style="color:#996600;">&quot;prec_i&quot;</span>, <span style="color:#996600;">&quot;floor&quot;</span>, <span style="color:#996600;">&quot;to_int&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span></pre></div></div>

<p>(though of course, this could be extremely dangerous in the wrong hands)</p>
<p>(<acronym title="Hat-Tip">HT</acronym>: <a href="http://blog.codahale.com/2006/08/01/stupid-ruby-tricks-stringto_proc/">Coda Hale</a>, <a href="http://concentrationstudios.com/2006/12/20/12-days-of-stupid-ruby-tricks">Concentration Studios</a>, and <a href="http://www.nobugs.org/developer/ruby/method_finder.html">Andrew Birkett</a>)</p>
<p>Clearly, Ruby has inherited much of the power of its Smalltalk heritage.  When developer coding time is a priority, anonymous message passing with a method_missing handler is a Good Thing.</p>
<p>In general, dynamic, weakly typed languages &#8211; with all of their drawbacks &#8211; have always been my favorite coding environment.  I&#8217;ve rarely felt too much enforcement of type safety to be worth the costs, though trust me that I do understand the reasons for it.  It is rare that I find an object&#8217;s type to be ambiguous outside of classic ASP.</p>
<h3>Conclusions</h3>
<p>Though I&#8217;ve been playing with Rails on the side for a few months, I&#8217;m really only just getting my feet wet.  I&#8217;m sure that there are aspects of the framework which will put me off; its Unicode support is poor (though that has <a href="http://weblog.rubyonrails.org/2007/1/19/rails-1-2-rest-admiration-http-lovefest-and-utf-8-celebrations">gotten better in 1.2</a>), raw performance is very poor (fingers crossed that a VM will be completed sooner rather than later), and DHH will probably continue to attempt to push away the enterprise market.  But at the same time, I&#8217;m looking forward to getting my hands dirty in what is really still a very new framework, despite being over two years old.  Thinking about architecture with the new CRUD features and ActiveResource alone should keep my mind occupied in between <a href="http://mitpress.mit.edu/sicp/">SICP</a> and <a href="http://en.wikipedia.org/wiki/Latin">Latin</a>.</p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fblog.danielwaechter.com%2Fprogramming%2Fthoughts-on-rails%2F&amp;linkname=Thoughts%20on%20Rails"><img src="http://blog.danielwaechter.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://blog.danielwaechter.com/programming/thoughts-on-rails/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk
Page Caching using disk (enhanced)
Database Caching 9/15 queries in 0.015 seconds using disk

Served from: blog.danielwaechter.com @ 2010-09-08 14:10:22 -->