<?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>Preston Lee&#039;s Blog &#187; code</title>
	<atom:link href="http://www.prestonlee.com/tag/code/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.prestonlee.com</link>
	<description>Technologist, businessman and entrepreneur.</description>
	<lastBuildDate>Fri, 23 Jul 2010 23:47:47 +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>What If Ruby Had Final Variables Like Java Or Erlang?</title>
		<link>http://www.prestonlee.com/2009/01/01/what-if-ruby-had-final-variables-like-java-or-erlang/</link>
		<comments>http://www.prestonlee.com/2009/01/01/what-if-ruby-had-final-variables-like-java-or-erlang/#comments</comments>
		<pubDate>Thu, 01 Jan 2009 22:13:01 +0000</pubDate>
		<dc:creator>preston.lee</dc:creator>
				<category><![CDATA[computer]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[erlang]]></category>
		<category><![CDATA[final]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[openrain]]></category>
		<category><![CDATA[opinion]]></category>
		<category><![CDATA[pastie]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.prestonlee.com/?p=454</guid>
		<description><![CDATA[After a long confusing Ruby debate today at OpenRain on the merits of functional, Erlang-esque write-once-read-many variables, I&#8217;m going to step onto the podium and just say it&#8230; Ruby should get &#8220;final&#8221; or &#8220;const&#8221; variables in a similar semantic style to Java, except at runtime. Rather than ramble on for 12 paragraphs explaining exactly how this might work, [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignright size-full wp-image-309" title="ruby" src="http://www.prestonlee.com/wp-content/uploads/2008/09/ruby.png" alt="ruby" width="100" /></p>
<p><a href="http://openrain.com">After a long confusing Ruby debate today at OpenRain</a> on the merits of functional, Erlang-esque write-once-read-many variables, I&#8217;m going to step onto the podium and just say it&#8230; <strong>Ruby should get &#8220;final&#8221; or &#8220;const&#8221; variables</strong> in a similar semantic style to Java, except at runtime. Rather than ramble on for 12 paragraphs explaining exactly how this might work, <a href="http://pastie.org/350206">read this fictitious Ruby code snippet</a> instead. (Optional: Also check out the chapter on &#8220;final&#8221; in <a href="http://oreilly.com/catalog/9780596005689/">Hardcore Java</a>.)</p>
<p><strong>Final variables like this are really just an inline TDD mechanism.</strong></p>
<p>Allowing local stack data to be constant provides no functional enhancements to the software, but alleviates the need for certain types of tests by using the compiler and/or runtime to assert certain memory is immutable. The &#8220;friend_best&#8221; method variant in the code snippet would obviously break most existing Ruby programs, but ups the bar for defensive programming by preventing many common bugs out-of-the-box while still providing support for traditional Ruby variables. At the very least we should have something like &#8220;friend_better&#8221;. Adding this information to the parse tree will also make it easier for IDEs to provide features more easily implemented for static languages.</p>
<p>TDD/BDD is in&#8211;no qualms about it&#8211;but we can make our code safer, cleaner and more concise by applying some of the lessons learned by our statically-typed language cousins over the last few decades.</p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save"><img src="http://www.prestonlee.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://www.prestonlee.com/2009/01/01/what-if-ruby-had-final-variables-like-java-or-erlang/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
