<?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/"
	xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Handwaving</title>
	<atom:link href="http://surana.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://surana.wordpress.com</link>
	<description>"glossing over detail for the sake of time or clarity"</description>
	<lastBuildDate>Fri, 19 Jun 2009 16:38:14 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<image>
		<url>http://www.gravatar.com/blavatar/d542eb9d394a2819faed49760c6dbe1f?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>Handwaving</title>
		<link>http://surana.wordpress.com</link>
	</image>
			<item>
		<title>Why is building software difficult?</title>
		<link>http://surana.wordpress.com/2009/06/19/why-is-building-software-difficult/</link>
		<comments>http://surana.wordpress.com/2009/06/19/why-is-building-software-difficult/#comments</comments>
		<pubDate>Fri, 19 Jun 2009 16:38:14 +0000</pubDate>
		<dc:creator>Pinku</dc:creator>
				<category><![CDATA[Business]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://surana.wordpress.com/2009/06/19/why-is-building-software-difficult/</guid>
		<description><![CDATA[Software projects are late and over-budget, yet still fail to meet all requirements and are buggy. What is the problem with software engineering processes and tools that lead to such terrible results? Nothing. Most complex projects are late and over-budget, and still fail to meet all requirements and are buggy. Boeing is paying sizable penalties [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=surana.wordpress.com&blog=1937801&post=111&subd=surana&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Software projects are late and over-budget, yet still fail to meet all requirements and are buggy. What is the problem with software engineering processes and tools that lead to such terrible results? Nothing. <em>Most complex projects are late and over-budget, and still fail to meet all requirements and are buggy.</em> Boeing is paying sizable penalties to customers because their latest plane is late and over-budget. Most defense contracts are late and over-budget. In fact, it’s rare to find a contractor that can fix your house without being late and over-budget. These problems are not unique to software; therefore, software isn’t the problem.</p>
<p>The problem is entirely people. The person managing the task is forced to guess when the task will be complete (when will you cure cancer?). The guess inevitably becomes a hard deadline. The task is ill-defined and vague (make the game more fun). The employees may not have the right skills to do the job effectively. Add to this the general dysfunction of any bureaucracy and there is very little hope of accomplishing anything on time. Shuffling people into different roles and slapping on new processes and tools will do nothing to solve the core problem: most people and organizations are not capable of delivering results efficiently. </p>
<p>Should you throw your hands up in despair? Yes. Most IT organizations are asking too much of their staff. It’s like asking a nurse to perform surgery. If management lowers their expectations, they can get good, consistent results from their IT staff. Otherwise, they are doomed to failure no matter what software engineering bandwagon they jump on. If companies with great talent and tools and experience (MS, Sun, IBM, Google, etc.) still have significant problems building software, how can anyone else do a good job? Stop trying and you’ll be much happier. </p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/surana.wordpress.com/111/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/surana.wordpress.com/111/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/surana.wordpress.com/111/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/surana.wordpress.com/111/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/surana.wordpress.com/111/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/surana.wordpress.com/111/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/surana.wordpress.com/111/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/surana.wordpress.com/111/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/surana.wordpress.com/111/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/surana.wordpress.com/111/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=surana.wordpress.com&blog=1937801&post=111&subd=surana&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://surana.wordpress.com/2009/06/19/why-is-building-software-difficult/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a000c344e2f086f6f97b02c16065397e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Pinku</media:title>
		</media:content>
	</item>
		<item>
		<title>Tail Call Optimization</title>
		<link>http://surana.wordpress.com/2009/04/23/tail-call-optimization/</link>
		<comments>http://surana.wordpress.com/2009/04/23/tail-call-optimization/#comments</comments>
		<pubDate>Thu, 23 Apr 2009 14:35:50 +0000</pubDate>
		<dc:creator>Pinku</dc:creator>
				<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://surana.wordpress.com/2009/04/23/tail-call-optimization/</guid>
		<description><![CDATA[Guido van Rossum, the benevolent dictator for life of the Python language, recently posted that he does not believe Python needs to support tail call optimization (TCO). However, he demonstrates his ignorance of TCO, as do many of these comments on Reddit. What is TCO? Whenever you make a function call, the language saves your [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=surana.wordpress.com&blog=1937801&post=110&subd=surana&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Guido van Rossum, the benevolent dictator for life of the <a href="http://www.python.org" target="_blank">Python language</a>, recently <a href="http://neopythonic.blogspot.com/2009/04/tail-recursion-elimination.html" target="_blank">posted</a> that he does not believe Python needs to support tail call optimization (TCO). However, he demonstrates his ignorance of TCO, as do many of these <a href="http://www.reddit.com/r/programming/comments/8en6p/why_guido_doesnt_like_tail_recursion_elimination/" target="_blank">comments on Reddit</a>. What is TCO? Whenever you make a function call, the language saves your state on the stack and creates a new frame for the next function. If you make a huge number of calls, then you could potentially run out of stack space. The obvious answer, therefore, is not to write programs that make lots of recursive calls. This is acceptable for every mainstream language, none of which support TCO. </p>
<p>So why is TCO useful? It allows you to create complex recursive programs that behave like loops. The most common example is the least compelling: </p>
<div style="border-bottom:silver 1px solid;text-align:left;border-left:silver 1px solid;line-height:12pt;background-color:#f4f4f4;width:96.76%;font-family:&#39;direction:ltr;height:122px;max-height:200px;font-size:8pt;overflow:auto;border-top:silver 1px solid;cursor:text;border-right:silver 1px solid;margin:20px 0 10px;padding:4px;" id="codeSnippetWrapper">
<div style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0;" id="codeSnippet">
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   1:</span> <span style="color:#0000ff;">int</span> sumList (Node n, <span style="color:#0000ff;">int</span> sum) {</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   2:</span>   <span style="color:#0000ff;">if</span> (n != <span style="color:#0000ff;">null</span>)</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   3:</span>     <span style="color:#0000ff;">return</span> sumList (n.next, sum+n.val) ;</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   4:</span>   <span style="color:#0000ff;">else</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   5:</span>     <span style="color:#0000ff;">return</span> sum ;</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   6:</span> }</pre>
<p><!--CRLF--></div>
</div>
<p>For very large lists, the recursive call to sumList will run out of stack space and raise an exception. TCO will adjust the recursive call to reuse the same stack frame; therefore, this recursion will work on very large lists without using any extra space. The reason this example is lame is because it can easily be rewritten to use a while loop. A better example is to use recursion for stream-based programming (just a sketch in C#-ish code):</p>
<div style="border-bottom:silver 1px solid;text-align:left;border-left:silver 1px solid;line-height:12pt;background-color:#f4f4f4;width:97.5%;font-family:&#39;direction:ltr;height:229px;max-height:200px;font-size:8pt;overflow:auto;border-top:silver 1px solid;cursor:text;border-right:silver 1px solid;margin:20px 0 10px;padding:4px;" id="codeSnippetWrapper">
<div style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0;" id="codeSnippet">
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   1:</span> <span style="color:#0000ff;">abstract</span> <span style="color:#0000ff;">class</span> Plugin {</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   2:</span>   Plugin nextStep ;</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   3:</span>   <span style="color:#0000ff;">public</span> <span style="color:#0000ff;">int</span> Process (<span style="color:#0000ff;">int</span> input) {</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   4:</span>     <span style="color:#0000ff;">return</span> nextStep.Process (DoWork(<span style="color:#0000ff;">int</span>)) ;</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   5:</span>   }</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   6:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   7:</span>   <span style="color:#0000ff;">public</span> <span style="color:#0000ff;">abstract</span> <span style="color:#0000ff;">int</span> DoWork (<span style="color:#0000ff;">int</span> x) ;</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   8:</span> }</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   9:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  10:</span> stream = <span style="color:#0000ff;">new</span> ReadData (<span style="color:#0000ff;">new</span> Plugin1 (<span style="color:#0000ff;">new</span> Plugin2 (<span style="color:#0000ff;">new</span> Plugin3 ()))) ;</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  11:</span> stream.endPoint = stream ;</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  12:</span> stream.readFile (file) ;</pre>
<p><!--CRLF--></div>
</div>
<p>The idea here is you can glue together any set of Plugins to build a pipeline that processes a stream of data in a big recursive circle of calls. Normally this would blow the stack, but TCO turns this into a loop that doesn’t use any extra stack space. You could rewrite this to avoid recursion, but you end up implementing a weak form of TCO yourself. When you don’t have to worry about it, you can write more complex code and trust the compiler to optimize it for you. As an analogy, you can write programs in languages that don’t have GC, but it’s annoying to manage memory manually. </p>
<p>Guido lists three points against the inclusion of TCO: (1) TCO doesn’t give you nice stack traces when things fail because it drops all the intermediate stack frames; (2) Once you add TCO, every implementation must support it;&#160; (3) He doesn’t “believe in recursion as the basis of <strong>all</strong> programming”. #1 &amp; #2 are true, but #3 is an exaggeration. Recursion is a nice feature that makes programming easier in some respects, but not the basis of everything. Instead, I think #2 is a strong argument against TCO for Python because it would be inefficient in some implementations, and very few Python programmers would understand it anyway. I just hope the next scripting fad will have this feature. </p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/surana.wordpress.com/110/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/surana.wordpress.com/110/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/surana.wordpress.com/110/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/surana.wordpress.com/110/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/surana.wordpress.com/110/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/surana.wordpress.com/110/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/surana.wordpress.com/110/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/surana.wordpress.com/110/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/surana.wordpress.com/110/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/surana.wordpress.com/110/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=surana.wordpress.com&blog=1937801&post=110&subd=surana&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://surana.wordpress.com/2009/04/23/tail-call-optimization/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a000c344e2f086f6f97b02c16065397e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Pinku</media:title>
		</media:content>
	</item>
		<item>
		<title>Javascript is like 10 year old C code</title>
		<link>http://surana.wordpress.com/2009/04/03/javascript-is-like-10-year-old-c-code/</link>
		<comments>http://surana.wordpress.com/2009/04/03/javascript-is-like-10-year-old-c-code/#comments</comments>
		<pubDate>Fri, 03 Apr 2009 04:07:18 +0000</pubDate>
		<dc:creator>Pinku</dc:creator>
				<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://surana.wordpress.com/2009/04/03/javascript-is-like-10-year-old-c-code/</guid>
		<description><![CDATA[Paul Buchheit was noting the improved performance of Java relative to C. He tried Javascript and said, &#8220;Compiled JS is about 9x slower than C on this test. If CPU speed doubles every 18 months, then JS in 2007 performs like C in 2002.&#8221; That&#8217;s a very good point. Most of the software written in [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=surana.wordpress.com&blog=1937801&post=109&subd=surana&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Paul Buchheit was <a href="http://paulbuchheit.blogspot.com/2007/06/java-is-faster-than-c.html" target="_blank">noting</a> the improved performance of Java relative to C. He tried Javascript and said, &#8220;Compiled JS is about 9x slower than C on this test. If CPU speed doubles every 18 months, then JS in 2007 performs like C in 2002.&#8221; That&#8217;s a very good point. Most of the software written in C/C++ on circa 2000 hardware could now be written with a scripting language. Since performance&nbsp; in 2000 was good enough to power everything around us, a scripting language should be good enough for most systems today. </p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/surana.wordpress.com/109/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/surana.wordpress.com/109/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/surana.wordpress.com/109/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/surana.wordpress.com/109/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/surana.wordpress.com/109/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/surana.wordpress.com/109/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/surana.wordpress.com/109/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/surana.wordpress.com/109/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/surana.wordpress.com/109/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/surana.wordpress.com/109/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=surana.wordpress.com&blog=1937801&post=109&subd=surana&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://surana.wordpress.com/2009/04/03/javascript-is-like-10-year-old-c-code/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a000c344e2f086f6f97b02c16065397e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Pinku</media:title>
		</media:content>
	</item>
		<item>
		<title>Pigovian Tax on Meat</title>
		<link>http://surana.wordpress.com/2009/03/27/pigovian-tax-on-meat/</link>
		<comments>http://surana.wordpress.com/2009/03/27/pigovian-tax-on-meat/#comments</comments>
		<pubDate>Fri, 27 Mar 2009 15:29:57 +0000</pubDate>
		<dc:creator>Pinku</dc:creator>
				<category><![CDATA[Economics]]></category>
		<category><![CDATA[Society]]></category>

		<guid isPermaLink="false">http://surana.wordpress.com/2009/03/27/pigovian-tax-on-meat/</guid>
		<description><![CDATA[There is finally a growing recognition that the industrialized production of meat is bad for people and the planet. When something has a significant negative externality (e.g. pollution) a Pigovian tax is used to add the social costs to that product&#8217;s price. That&#8217;s why many economists support a tax on gasoline. The negative externalities include [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=surana.wordpress.com&blog=1937801&post=108&subd=surana&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>There is finally a <a href="http://www.time.com/time/health/article/0,8599,1887266,00.html?iid=perma_share" target="_blank">growing recognition</a> that the industrialized production of meat is bad for people and the planet. When something has a significant negative externality (e.g. pollution) a <a href="http://en.wikipedia.org/wiki/Pigovian_tax" target="_blank">Pigovian tax</a> is used to add the social costs to that product&#8217;s price. That&#8217;s why many economists support a tax on gasoline. The negative externalities include production of greenhouse gases and undermining our security interests by sending too much money to unfriendly countries. For meat, there are several negative externalities.</p>
<ul>
<li>Grazing animals produce more greenhouse gases (belching and farting) than cars.</li>
<li>Industrial farms seriously degrade water quality because of large amounts of feces.</li>
<li>It&#8217;s an inefficient use of water and arable land, both of which are subsidized by the gov&#8217;t. </li>
<li>Over-consumption of meat leads to poor health, which adds to our total health care costs.</li>
</ul>
<p>By adding a tax and/or removing agricultural subsidies for meat production, it raises the price to match the real total cost of a double cheeseburger. Though it is impossible to expect people to suddenly become vegetarians (I&#8217;ve struggled for 10 years), it is trivial for people to reduce the amount of meat they eat. Americans are grotesquely obese because they eat too much of everything. Reducing total food consumption means less meat consumption which leads to lower rates of obesity. Raising the cost of meat should hopefully push people to eat more fruits and vegetables. I think the biggest problem is America&#8217;s meat &amp; potatoes food culture. People just don&#8217;t know what to do with vegetables. Incidentally, I asked <a href="http://gregmankiw.blogspot.com/" target="_blank">Greg Mankiw</a>, Bush&#8217;s economics advisor, about this and he agreed with a Pigovian tax on meat. (Isn&#8217;t the Internet great?) So you could likely get bourgeoisie support, but the overweight proletariat will riot to get cheap bacon. Mmmmmmm, bacon.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/surana.wordpress.com/108/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/surana.wordpress.com/108/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/surana.wordpress.com/108/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/surana.wordpress.com/108/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/surana.wordpress.com/108/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/surana.wordpress.com/108/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/surana.wordpress.com/108/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/surana.wordpress.com/108/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/surana.wordpress.com/108/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/surana.wordpress.com/108/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=surana.wordpress.com&blog=1937801&post=108&subd=surana&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://surana.wordpress.com/2009/03/27/pigovian-tax-on-meat/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a000c344e2f086f6f97b02c16065397e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Pinku</media:title>
		</media:content>
	</item>
		<item>
		<title>The Joys of Real Hardware</title>
		<link>http://surana.wordpress.com/2009/03/19/the-joys-of-real-hardware/</link>
		<comments>http://surana.wordpress.com/2009/03/19/the-joys-of-real-hardware/#comments</comments>
		<pubDate>Thu, 19 Mar 2009 23:00:09 +0000</pubDate>
		<dc:creator>Pinku</dc:creator>
				<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://surana.wordpress.com/2009/03/19/the-joys-of-real-hardware/</guid>
		<description><![CDATA[Again from a presentation given by Jeff Dean, a brilliant Google engineer. These are the failure rates of hardware in a typical first year for a new cluster at Google:

~0.5 overheating (power down most machines in &#60;5 mins, ~1-2 days to recover)
~1 PDU failure (~500-1000 machines suddenly disappear, ~6 hours to come back)
~1 rack-move (plenty [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=surana.wordpress.com&blog=1937801&post=106&subd=surana&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><a href="http://surana.wordpress.com/2009/01/01/numbers-everyone-should-know/" target="_blank">Again</a> from a <a href="http://cs343-spr0607.stanford.edu/materials/jeff_dean/" target="_blank">presentation</a> given by Jeff Dean, a brilliant Google engineer. These are the failure rates of hardware in a typical first year for a new cluster at Google:</p>
<ul>
<li>~0.5 overheating (power down most machines in &lt;5 mins, ~1-2 days to recover)</li>
<li>~1 PDU failure (~500-1000 machines suddenly disappear, ~6 hours to come back)</li>
<li>~1 rack-move (plenty of warning, ~500-1000 machines powered down, ~6 hours)</li>
<li>~1 network rewiring (rolling ~5% of machines down over 2-day span)</li>
<li>~20 rack failures (40-80 machines instantly disappear, 1-6 hours to get back)</li>
<li>~5 racks go wonky (40-80 machines see 50% packet loss)</li>
<li>~8 network maintenances (4 might cause ~30-minute random connectivity losses)</li>
<li>~12 router reloads (takes out DNS and external vips for a couple minutes)</li>
<li>~3 router failures (have to immediately pull traffic for an hour)</li>
<li>~dozens of minor 30 second blips for dns</li>
<li>~1000 individual machine failures</li>
<li>~thousands of hard drive failures</li>
<li>slow disks, bad memory, misconfigured machines, flaky machines, etc. </li>
</ul>
<p><em>My comment: </em>distributed systems must deal with failure constantly and consistently. My intuition (which is usually wrong) is that Java/.NET exception handling isn&#8217;t that good because there&#8217;s no convenient way (AFAIK) to fix an exception and retry/resume the block of code like you can with Lisp conditions. Software transactional memory (STM) sort of does this, i.e. it doesn&#8217;t fix anything, but it keeps retrying the block until the transaction succeeds (the inputs haven&#8217;t changed before you update the result). I&#8217;m sure there&#8217;s a solution buried in the <a href="http://hadoop.apache.org/core/" target="_blank">Hadoop</a> code. I&#8217;ll dig it out and post it soon. </p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/surana.wordpress.com/106/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/surana.wordpress.com/106/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/surana.wordpress.com/106/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/surana.wordpress.com/106/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/surana.wordpress.com/106/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/surana.wordpress.com/106/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/surana.wordpress.com/106/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/surana.wordpress.com/106/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/surana.wordpress.com/106/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/surana.wordpress.com/106/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=surana.wordpress.com&blog=1937801&post=106&subd=surana&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://surana.wordpress.com/2009/03/19/the-joys-of-real-hardware/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a000c344e2f086f6f97b02c16065397e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Pinku</media:title>
		</media:content>
	</item>
		<item>
		<title>Computer medical records</title>
		<link>http://surana.wordpress.com/2009/03/12/computer-medical-records/</link>
		<comments>http://surana.wordpress.com/2009/03/12/computer-medical-records/#comments</comments>
		<pubDate>Thu, 12 Mar 2009 15:01:22 +0000</pubDate>
		<dc:creator>Pinku</dc:creator>
				<category><![CDATA[Business]]></category>

		<guid isPermaLink="false">http://surana.wordpress.com/2009/03/12/computer-medical-records/</guid>
		<description><![CDATA[I rarely read the AEI WSJ op-ed page, but today there was an interesting op-ed against computerized medical records by a pair of doctors. The argument is that current implementations of electronic medical records have not improved care or costs; therefore, projections by RAND of large potential savings are dubious. This is probably true, but [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=surana.wordpress.com&blog=1937801&post=104&subd=surana&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I rarely read the <strike>AEI</strike> WSJ op-ed page, but today there was an interesting <a href="http://online.wsj.com/article/SB123681586452302125.html" target="_blank">op-ed</a> against computerized medical records by a pair of doctors. The argument is that current implementations of electronic medical records have not improved care or costs; therefore, projections by RAND of large potential savings are dubious. This is probably true, but it is exactly the kind of short-sighted argument one typically faces with any new idea. The problem is that current implementations are poor copies of paper medical records. Without more intelligence in the software and wider infrastructure (i.e. connections with other doctors, hospitals and insurance companies), electronic records can&#8217;t improve anything. Read <a href="http://economix.blogs.nytimes.com/author/uwe-e-reinhardt/" target="_blank">Uwe Reinhardt posts</a> that explain some of the problems with medical care. The two big ones are (1) doctors frequently deliver incorrect or inefficient treatments and (2) different regions and hospitals charge wildly different amounts for the same treatments. A goal of electronic medical records is to reduce these problems by (1) reminding doctors what the typical treatments should be and (2) easily pinpointing hospitals/doctors that are overcharging for procedures. Another potential savings is to reduce some admin overhead, which is one significant reason the US costs so much more than comparable countries. Any guess at potential savings can be easily criticized because it is just a guess. But the history of the computers&#8217; impact on different industries makes me believe any estimate of future savings will fall far short of reality. We can&#8217;t get there unless we start today. </p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/surana.wordpress.com/104/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/surana.wordpress.com/104/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/surana.wordpress.com/104/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/surana.wordpress.com/104/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/surana.wordpress.com/104/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/surana.wordpress.com/104/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/surana.wordpress.com/104/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/surana.wordpress.com/104/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/surana.wordpress.com/104/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/surana.wordpress.com/104/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=surana.wordpress.com&blog=1937801&post=104&subd=surana&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://surana.wordpress.com/2009/03/12/computer-medical-records/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a000c344e2f086f6f97b02c16065397e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Pinku</media:title>
		</media:content>
	</item>
		<item>
		<title>Larry Kudlow is a moron</title>
		<link>http://surana.wordpress.com/2009/03/03/larry-kudlow-is-a-moron/</link>
		<comments>http://surana.wordpress.com/2009/03/03/larry-kudlow-is-a-moron/#comments</comments>
		<pubDate>Tue, 03 Mar 2009 18:52:49 +0000</pubDate>
		<dc:creator>Pinku</dc:creator>
				<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://surana.wordpress.com/?p=102</guid>
		<description><![CDATA[Sometimes, when I fail to hit mute on my TV, I am blasted by the brainless rantings of CNBC&#8217;s Larry Kudlow, whose zeal for tax cuts rivals his earlier addiction to cocaine and alcohol. He believes that returning high-income tax rates to those during the 90&#8217;s boom will lead to the destruction of mankind. If [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=surana.wordpress.com&blog=1937801&post=102&subd=surana&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Sometimes, when I fail to hit mute on my TV, I am blasted by the brainless rantings of CNBC&#8217;s Larry Kudlow, whose zeal for tax cuts rivals his earlier addiction to cocaine and alcohol. He believes that returning high-income tax rates to those during the 90&#8217;s boom will lead to the destruction of mankind. If rich people are so motivated by tax rates, then why do so many live in NYC and California? Even Kudlow lived in NYC until he was fired from his Wall St. job and went to a drug treatment center in &#8216;95. NY has a fairly high state tax that is 6.85% max and NYC adds ~3.5% max. There&#8217;s also a fairly high property tax and sales tax. Why haven&#8217;t the rich left NYC a long time ago? Financial companies can now move anywhere because the markets are mostly electronic. People could commute from upstate NY, CT or NJ to avoid some NYC tax. Some do, but many remain. More importanly, why did Kudlow live in NYC rather than commute from a lower tax area? The boat outside my house takes me to Wall St. in 10 minutes.</p>
<p>Kudlow&#8217;s addictive personality and meager education in economics made him susceptible to Arthur Laffer&#8217;s simplistic view of the world. And his pompous and pseudo-intellectual manner probably makes him popular on the right-wing cocktail party circuit. Indeed, his conversion to Catholicism is yet another example of his need to belong to a cult. My only hope is that someday Steve Liesman will strangle Kudlow live on-the-air.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/surana.wordpress.com/102/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/surana.wordpress.com/102/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/surana.wordpress.com/102/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/surana.wordpress.com/102/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/surana.wordpress.com/102/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/surana.wordpress.com/102/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/surana.wordpress.com/102/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/surana.wordpress.com/102/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/surana.wordpress.com/102/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/surana.wordpress.com/102/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=surana.wordpress.com&blog=1937801&post=102&subd=surana&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://surana.wordpress.com/2009/03/03/larry-kudlow-is-a-moron/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a000c344e2f086f6f97b02c16065397e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Pinku</media:title>
		</media:content>
	</item>
		<item>
		<title>The Seer who saw the housing bubble</title>
		<link>http://surana.wordpress.com/2009/03/02/the-seer-who-saw-the-housing-bubble/</link>
		<comments>http://surana.wordpress.com/2009/03/02/the-seer-who-saw-the-housing-bubble/#comments</comments>
		<pubDate>Mon, 02 Mar 2009 22:02:00 +0000</pubDate>
		<dc:creator>Pinku</dc:creator>
				<category><![CDATA[Business]]></category>

		<guid isPermaLink="false">http://surana.wordpress.com/?p=100</guid>
		<description><![CDATA[I accidently clicked on a link mocking the book &#8220;Are you missing the real estate boom?&#8221; by the real estate association&#8217;s lapdog, David Lereah. There I found the following brilliant book review by &#8220;Don Corleone&#8221;, dated April 19, 2005!!:

For me, this was more comic relief than any scholarly analysis. The author has a vested interest [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=surana.wordpress.com&blog=1937801&post=100&subd=surana&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I accidently clicked on a link mocking the book &#8220;Are you missing the real estate boom?&#8221; by the real estate association&#8217;s lapdog, David Lereah. There I found the following brilliant <a href="http://www.amazon.com/review/R3R4SJ8YZY5326/ref=cm_cr_dp_cmt?ie=UTF8&amp;ASIN=B000FCK0HG&amp;nodeID=133140011&amp;voteError=0&amp;2115R3R4SJ8YZY5326HelpfulReviews5.s=SUCCESS&amp;2115R3R4SJ8YZY5326HelpfulReviews5.v=1">book review by &#8220;Don Corleone&#8221;</a>, dated <span style="text-decoration:underline;">April 19, <strong>2005!!</strong></span>:</p>
<p><span id="more-100"></span></p>
<blockquote><p>For me, this was more comic relief than any scholarly analysis. The author has a vested interest in the bubble not bursting, and he&#8217;s selling his soul with this book to prove it.</p>
<p>He spins webs of demographics and interest rates, but he never ever addresses the core issues that determine housing values. What is lost here is that housing in itself creates no value, its value is completely predicated upon peoples ability to pay for it. Ergo, housing prices for the last 100 years have tracked income remarkably closely, that is, except for the last five years. Historically, the ratio of housing price to annual income has been 2.1, with very little variation. In many parts of the country, this ratio is now approaching 10.5! Can you say &#8220;major correction?&#8221; Further, the amount of leverage used to buy homes during this boom has been increased to absolutely unprecidented levels. Even during the last boom of the late 80s/early 90s, the standard was still 30 yr fixed and 20% down. Not anymore. Last year, less than 15% of borrowers put down 20% or more! Further, the 30 yr fixed has been replaced by the IO, or interest only loan. See now, we have the same borrower capable of bidding 30-40% more for a propery without any better credit or ability to repay. Neat trick, but sadly, Lereah at no point addresses any of these fundamentals.</p>
<p>Our stock/housing pattern appears remarkably similar to the one Japan had 20 years ago. First the stock market busted. Right after, the real estate market rallied, and it busted too. The current Japanese real estate market is in a 14 year slide to date, and houses are going for roughly their 1980 value.</p>
<p>Keep talking Dave &#8211; we&#8217;ll need the comic relief soon!</p></blockquote>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/surana.wordpress.com/100/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/surana.wordpress.com/100/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/surana.wordpress.com/100/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/surana.wordpress.com/100/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/surana.wordpress.com/100/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/surana.wordpress.com/100/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/surana.wordpress.com/100/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/surana.wordpress.com/100/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/surana.wordpress.com/100/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/surana.wordpress.com/100/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=surana.wordpress.com&blog=1937801&post=100&subd=surana&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://surana.wordpress.com/2009/03/02/the-seer-who-saw-the-housing-bubble/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a000c344e2f086f6f97b02c16065397e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Pinku</media:title>
		</media:content>
	</item>
		<item>
		<title>Who owns our debt?</title>
		<link>http://surana.wordpress.com/2009/03/01/who-owns-our-debt/</link>
		<comments>http://surana.wordpress.com/2009/03/01/who-owns-our-debt/#comments</comments>
		<pubDate>Mon, 02 Mar 2009 03:51:52 +0000</pubDate>
		<dc:creator>Pinku</dc:creator>
				<category><![CDATA[Politics]]></category>

		<guid isPermaLink="false">http://surana.wordpress.com/2009/03/01/who-owns-our-debt/</guid>
		<description><![CDATA[Here&#8217;s the total amount of US debt owned by foreign governments. They own about 25% of the total $10 trillion dollar debt. Here&#8217;s a breakdown of ownership of all the debt (doc) over the last 10 years. Right now China owns a mere 7% of the total US national debt. In fact, investors are withdrawing [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=surana.wordpress.com&blog=1937801&post=98&subd=surana&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Here&#8217;s the <a href="http://www.treas.gov/tic/mfh.txt" target="_blank">total amount of US debt owned by foreign governments</a>. They own about 25% of the total $10 trillion dollar debt. Here&#8217;s a <a href="http://www.fms.treas.gov/bulletin/b2008-4ofs.doc" target="_blank">breakdown of ownership of all the debt</a> (doc) over the last 10 years. Right now China owns a mere 7% of the total US national debt. In fact, investors are withdrawing their money from markets around the world and stuffing them into US Treasuries, which are perceived to be the safest place for money right now. From June&#8217;07 to June&#8217;08, foreigners bought ~$450B more and US mutual funds added ~$200B of US debt. Remember this the next time a politician stirs up nationalism and racism by complaining that China <em>owns</em> the US. Here&#8217;s a <a href="http://www.treasurydirect.gov/govt/resources/faq/faq_publicdebt.htm#DebtOwner" target="_blank">good source</a> for more info on the debt. </p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/surana.wordpress.com/98/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/surana.wordpress.com/98/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/surana.wordpress.com/98/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/surana.wordpress.com/98/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/surana.wordpress.com/98/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/surana.wordpress.com/98/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/surana.wordpress.com/98/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/surana.wordpress.com/98/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/surana.wordpress.com/98/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/surana.wordpress.com/98/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=surana.wordpress.com&blog=1937801&post=98&subd=surana&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://surana.wordpress.com/2009/03/01/who-owns-our-debt/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a000c344e2f086f6f97b02c16065397e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Pinku</media:title>
		</media:content>
	</item>
		<item>
		<title>Limited pattern matching for Java</title>
		<link>http://surana.wordpress.com/2009/03/01/limited-pattern-matching-for-java/</link>
		<comments>http://surana.wordpress.com/2009/03/01/limited-pattern-matching-for-java/#comments</comments>
		<pubDate>Sun, 01 Mar 2009 18:21:53 +0000</pubDate>
		<dc:creator>Pinku</dc:creator>
				<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://surana.wordpress.com/2009/03/01/limited-pattern-matching-for-java/</guid>
		<description><![CDATA[Project Coin on OpenJDK is soliciting ideas for small language changes for Java 7. The ideas so far appear to suggest features from C#, which is a superior language IMHO. In principle, I hate the idea of baking in cosmetic changes to a language. Scheme and Lisp macros are a profoundly better solution to syntactic [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=surana.wordpress.com&blog=1937801&post=97&subd=surana&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><a href="http://openjdk.java.net/projects/coin/#proposal_form" target="_blank">Project Coin</a> on OpenJDK is soliciting ideas for small language changes for Java 7. The <a href="http://mail.openjdk.java.net/pipermail/coin-dev/" target="_blank">ideas so far</a> appear to suggest features from C#, which is a superior language IMHO. In principle, I hate the idea of baking in cosmetic changes to a language. Scheme and Lisp macros are a profoundly better solution to syntactic issues, but mainstream programmers will never grok it. So Java has no choice but to add more stuff. Therefore, I think the <em>switch</em> statement is seriously underutilized in C-like languages. One idea is to add support for a limited degree of object pattern matching. Think of it as a painfully limited version of the <em>case</em> expression in many functional languages. </p>
<p>The <em>switch</em> in Java currently only allows a few primitive types. Change it so now you can have <em>switch(objectType)</em>. Allow the <em>case</em> arms to support a boolean expression. To simplify things, allow access to object fields like this: &#8220;.field&#8221;. So the new <em>switch</em> would look like this:</p>
<div style="border-right:gray 1px solid;border-top:gray 1px solid;font-size:8pt;overflow:auto;border-left:gray 1px solid;width:97.5%;cursor:text;max-height:200px;line-height:12pt;border-bottom:gray 1px solid;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;margin:20px 0 10px;padding:4px;">
<div style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;padding:0;">
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   1:</span> <span style="color:#0000ff;">switch</span> (myCustomer) {</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   2:</span>     <span style="color:#0000ff;">case</span> (.name == <span style="color:#006080;">"Bob"</span>): stmts ;</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   3:</span>     <span style="color:#0000ff;">case</span> (.age &gt; 21 &amp;&amp; .income &gt; 20000): stmts ;</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   4:</span>     <span style="color:#0000ff;">default</span>: stmts ;</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   5:</span> }</pre>
</div>
</div>
<p>A simpler idea is to stick with the regular <em>switch</em> statement, but support multiple switch variables. Right now, you can only do &#8220;switch (oneItem)&#8221;. Instead, you could allow &#8220;switch (oneItem, twoItem)&#8221; and more. In the <em>case</em> arms, right now they allow &#8220;case constant:&#8221;. Instead, this can be extended to allow &#8220;case constant1, constant2&#8243; and more. Obviously, each constant is matched with the switch variable in the same position. If there are too many constants, that&#8217;s a syntax error. If there are fewer constants, then ignore the remaining variables. Here&#8217;s an example:</p>
<div style="border-right:gray 1px solid;border-top:gray 1px solid;font-size:8pt;overflow:auto;border-left:gray 1px solid;width:97.5%;cursor:text;max-height:200px;line-height:12pt;border-bottom:gray 1px solid;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;margin:20px 0 10px;padding:4px;">
<div style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;padding:0;">
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   1:</span> <span style="color:#0000ff;">switch</span> (document, output) {</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   2:</span>     <span style="color:#0000ff;">case</span> <span style="color:#006080;">"pdf"</span>, <span style="color:#006080;">"printer"</span>: print it <span style="color:#0000ff;">out</span>;</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   3:</span>     <span style="color:#0000ff;">case</span> <span style="color:#006080;">"pdf"</span>, <span style="color:#006080;">"screen"</span>: use acrobat;</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   4:</span>     <span style="color:#0000ff;">case</span> <span style="color:#006080;">"jpg"</span>, <span style="color:#006080;">"printer"</span>: turn on fancy colors and print;</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   5:</span>     <span style="color:#0000ff;">default</span>: b/w print;</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   6:</span> }</pre>
</div>
</div>
<p>Finally, the absolute simplest extension to the existing <em>switch</em> statement is to allow case ranges. This is already implemented in Visual Basic.NET with their <em>Select Case</em> statement. You say &#8220;Case 1 to 10&#8243; to match that range. Lots of languages support this. This feature won&#8217;t change the world, but it does make <em>switch</em> a bit more useful. </p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/surana.wordpress.com/97/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/surana.wordpress.com/97/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/surana.wordpress.com/97/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/surana.wordpress.com/97/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/surana.wordpress.com/97/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/surana.wordpress.com/97/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/surana.wordpress.com/97/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/surana.wordpress.com/97/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/surana.wordpress.com/97/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/surana.wordpress.com/97/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=surana.wordpress.com&blog=1937801&post=97&subd=surana&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://surana.wordpress.com/2009/03/01/limited-pattern-matching-for-java/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a000c344e2f086f6f97b02c16065397e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Pinku</media:title>
		</media:content>
	</item>
	</channel>
</rss>