<?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>spiros.blog() &#187; .Net</title>
	<atom:link href="http://www.tzavellas.com/techblog/category/net/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.tzavellas.com/techblog</link>
	<description>Spiros Tzavellas’s blog, mostly on software development and Java.</description>
	<lastBuildDate>Sun, 22 Aug 2010 20:25:28 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>C# Extension methods</title>
		<link>http://www.tzavellas.com/techblog/2007/06/02/c-extension-methods/</link>
		<comments>http://www.tzavellas.com/techblog/2007/06/02/c-extension-methods/#comments</comments>
		<pubDate>Sat, 02 Jun 2007 07:45:33 +0000</pubDate>
		<dc:creator>spiros</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.tzavellas.com/techblog/2007/06/02/c-extension-methods/</guid>
		<description><![CDATA[Scott Hanselman has a post about a user who doesn&#8217;t get what is cool about Ruby. In the post you can find the below example that compares Java and Ruby in terms of code readability. The Java code: new Date&#40;new Date&#40;&#41;.getTime&#40;&#41; - 20 * 60 * 1000&#41; The Ruby code: 20.minutes.ago The article was interesting [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.hanselman.com/blog/">Scott Hanselman</a> has a <a href="http://www.hanselman.com/blog/ProgrammerIntentOrWhatYoureNotGettingAboutRubyAndWhyItsTheTits.aspx">post</a> about a user who doesn&#8217;t get what is cool about <a href="http://www.ruby-lang.org/en/">Ruby</a>.</p>
<p>In the post you can find the below example that compares <a href="http://java.sun.com">Java</a> and <a href="http://www.ruby-lang.org/en/">Ruby</a> in terms of code readability.</p>
<p>The Java code:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Date</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Date</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getTime</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">-</span> <span style="color: #cc66cc;">20</span> <span style="color: #339933;">*</span> <span style="color: #cc66cc;">60</span> <span style="color: #339933;">*</span> <span style="color: #cc66cc;">1000</span><span style="color: #009900;">&#41;</span></pre></div></div>

<p>The Ruby code:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">20.<span style="color:#9900CC;">minutes</span>.<span style="color:#9900CC;">ago</span></pre></div></div>

<p>The article was interesting but what really caught my attention was some comments from C# programmers who showed how, in a few lines of code, you can mimic the Ruby syntax in C# using extension methods.</p>
<p>The new version of C#, shipped with the <a href="http://msdn2.microsoft.com/en-us/vstudio/aa700830.aspx">Orcas</a> release of Visual Studio, has a new feature called extension methods. Extension methods were added to the .Net languages to support <a href="http://msdn2.microsoft.com/en-us/netframework/aa904594.aspx">LINQ</a> and they provide a way to attach methods to classes without changing their code.</p>
<p>The below code is copied and modified from the comments of Ian Cooper in the  aforementioned <a href="http://www.hanselman.com/blog/ProgrammerIntentOrWhatYoureNotGettingAboutRubyAndWhyItsTheTits.aspx">blog post</a>.</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF;">public</span> <span style="color: #0600FF;">static</span> <span style="color: #FF0000;">class</span> TimeExtensions <span style="color: #000000;">&#123;</span>
&nbsp;
  <span style="color: #0600FF;">public</span> <span style="color: #0600FF;">static</span> TimeSpan Minutes<span style="color: #000000;">&#40;</span><span style="color: #0600FF;">this</span> <span style="color: #FF0000;">int</span> numberOfMinutes<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
    <span style="color: #0600FF;">return</span> <span style="color: #008000;">new</span> TimeSpan<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">0</span>, numberOfMinutes, <span style="color: #FF0000;">0</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
  <span style="color: #000000;">&#125;</span>
&nbsp;
  <span style="color: #0600FF;">public</span> <span style="color: #0600FF;">static</span> DateTime Ago<span style="color: #000000;">&#40;</span><span style="color: #0600FF;">this</span> TimeSpan numberOfMinutes<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
    <span style="color: #0600FF;">return</span> DateTime.<span style="color: #0000FF;">Now</span>.<span style="color: #0000FF;">Subtract</span><span style="color: #000000;">&#40;</span>numberOfMinutes<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
  <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>In the above code we defined a class, called <code>TimeExtensions</code>, which contains two extension methods. Notice the <code>this</code> keyword on the left of the fist parameter (both methods take one parameter in the example code) of the methods. The <code>this</code> keyword tells the C# compiler that a method is an extension method. The parameter annotated with the <code>this</code> keyword is the object on which the extension method is called. If I am correct, the methods are not really added to the classes (you can&#8217;t find them via reflection), the compiler at-compile-time translates them into static method calls.</p>
<p>In our example the first method, called <code>Minutes</code>, will be added to the <code>int</code> class (probably via auto-boxing) and the second method, called <code>Ago</code>, will be added to the <code>TimeSpan</code> class.</p>
<p>Now, to use the extension methods that we defined above we have to import them using the <code>using TimeExtensions</code> statement. This is a really good thing since the usage of extension methods is always explicit. You have to import them to use them and if you don&#8217;t want to use them you don&#8217;t import them.</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF;">using</span> <span style="color: #008080;">System</span><span style="color: #008000;">;</span>
<span style="color: #0600FF;">using</span> <span style="color: #008080;">TimeExtensions</span><span style="color: #008000;">;</span>
&nbsp;
<span style="color: #0600FF;">public</span> <span style="color: #FF0000;">class</span> HelloWorld <span style="color: #000000;">&#123;</span>
  <span style="color: #0600FF;">public</span> <span style="color: #0600FF;">static</span> <span style="color: #0600FF;">void</span> Main<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
    Console.<span style="color: #0000FF;">WriteLine</span><span style="color: #000000;">&#40;</span> 20.<span style="color: #0000FF;">Minutes</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">Ago</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
  <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p><code>20.Minutes().Ago()</code> is pretty close to <code>20.minutes.ago</code> <img src='http://www.tzavellas.com/techblog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>For a nice tutorial about C# 3.0 extension methods see: <a href="http://weblogs.asp.net/scottgu/archive/2007/03/13/new-orcas-language-feature-extension-methods.aspx">New &#8220;Orcas&#8221; Language Feature: Extension Methods</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tzavellas.com/techblog/2007/06/02/c-extension-methods/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Thinking in Code</title>
		<link>http://www.tzavellas.com/techblog/2006/06/12/thinking-in-code/</link>
		<comments>http://www.tzavellas.com/techblog/2006/06/12/thinking-in-code/#comments</comments>
		<pubDate>Mon, 12 Jun 2006 19:26:25 +0000</pubDate>
		<dc:creator>spiros</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[C/C++]]></category>
		<category><![CDATA[OOP]]></category>
		<category><![CDATA[Podcast]]></category>

		<guid isPermaLink="false">http://www.tzavellas.com/techblog/?p=54</guid>
		<description><![CDATA[Bruce Eckel has a podcast with 12 interviews of various software luminaries. All the interviews took place in 2003 but Eckel only recently released them. You can find interviews of Anders Hejlsberg, Guido Van Rossum, Joshua Bloch, Martin Fowler, Ron Jeffries and others.]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.mindviewinc.com/">Bruce Eckel</a> has a <a href="http://www.mindviewinc.com/mediacast/interviews/Index.php">podcast</a> with 12 interviews of various software luminaries. All the interviews took place in 2003 but Eckel only recently released them. You can find interviews of Anders Hejlsberg, Guido Van Rossum, Joshua Bloch, Martin Fowler, Ron Jeffries and others.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tzavellas.com/techblog/2006/06/12/thinking-in-code/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Two new C# 3.0 features that Java needs</title>
		<link>http://www.tzavellas.com/techblog/2005/09/28/two-new-c-30-features-that-java-needs/</link>
		<comments>http://www.tzavellas.com/techblog/2005/09/28/two-new-c-30-features-that-java-needs/#comments</comments>
		<pubDate>Tue, 27 Sep 2005 23:36:25 +0000</pubDate>
		<dc:creator>spiros</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://www.tzavellas.com/techblog/?p=24</guid>
		<description><![CDATA[C# 3.0 is out. You can get the specification, a compiler other goodies from here. I am programming in Java almost exclusively for the last two years. In this post I will discuss two new features of C# 3.0 that I&#8217;d like to see in the next versions of Java. Below there is a code [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://msdn.microsoft.com/vcsharp/future/">C# 3.0</a> is out. You can get the specification, a compiler other goodies from <a href="http://msdn.microsoft.com/vcsharp/future/">here</a>.</p>
<p>I am programming in <a href="http://java.sun.com">Java</a> almost exclusively for the last two years. In this post I will discuss two new features of <a href="http://msdn.microsoft.com/vcsharp/future/">C# 3.0</a> that I&#8217;d like to see in the next versions of <a href="http://java.sun.com">Java</a>.</p>
<p>Below there is a code fragment from the <a href="http://download.microsoft.com/download/4/7/0/4703eba2-78c4-4b09-8912-69f6c38d3a56/XLinq.wmv"><em>XLinq in action</em></a> video that demonstrates my two new favorite features (local variable type inference and lambda expressions):</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;">var contacts <span style="color: #008000;">=</span> doc.<span style="color: #0000FF;">Descendants</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;contact&quot;</span><span style="color: #000000;">&#41;</span>
	.<span style="color: #0000FF;">Where</span><span style="color: #000000;">&#40;</span> a <span style="color: #008000;">=&gt;</span> <span style="color: #000000;">&#40;</span><span style="color: #FF0000;">string</span><span style="color: #000000;">&#41;</span>a.<span style="color: #0000FF;">Attribute</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;category&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">==</span> <span style="color: #666666;">&quot;home&quot;</span><span style="color: #000000;">&#41;</span></pre></div></div>

<p>The above code fragment will query an <a href="http://www.w3.org/XML/">XML</a> document (the <code>XDocument</code> object that is assigned to the <code>doc</code> variable) to retrieve all <code>contact</code> elements with the <code>category</code> attribute matching <code>&quot;home&quot;</code>.</p>
<p>In the above code we didn&#8217;t specify the type of the <code>contacts</code> variable in the variable declaration. Instead we used the new <a href="http://msdn.microsoft.com/vcsharp/future/">C# 3.0</a> keyword <code>var</code>. When we use the keyword <code>var</code> in a variable declaration the type of the variable is inferred by the compiler for us and we do not have to specify it. This is called <em>local variable type inference</em>. The type is inferred at compile-time after checking the type of the expression on the right of the assignment.</p>
<p>Please note that the variable <code>contacts</code> has a type and its type remains the same (statically typed). You cannot reassign something that has a different type from the above expression to the contacts variable. This is in contrast with dynamically typed languages like <a href="http://www.python.org">Python</a> and <a href="http://www.ruby-lang.org/">Ruby</a> where you also do not declare the type of variables but the type of the variables is determined at run-time and the type of a variable can change dynamically (you can assign a string to a variable and then assign an integer to the same variable).</p>
<p>Three people have asked for this feature with a RFE to the <a href="http://bugs.sun.com/bugdatabase/index.jsp">SUN&#8217;s Java bug database</a>. All of the RFEs are in “Closed, will not be fixed” state because people at <a href="http://www.sun.com">SUN</a> believe that types in variable declarations provide readability and valuable redundancy.</p>
<p>Below I have included information about the RFEs.</p>
<p>Bug ID:  <a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4879776">4879776</a><br />
Synopsis:  Constructor type inference (JSR14 + JSR65 ++)<br />
Submit Date: 17-JUN-2003</p>
<p>Bug ID:  <a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4459053">4459053</a><br />
Synopsis:  Type inference for variable declarations<br />
Submit Date:  15-MAY-2001</p>
<p>Bug ID:  <a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6242254">6242254</a><br />
Synopsis:  Language support for type inference<br />
Submit Date:  17-MAR-2005</p>
<p>I agree that repetition is good and many times helps readability but now that <a href="http://java.sun.com/j2se/1.5.0/index.jsp">Java 5</a> has generics the variable declarations can be very long and noisy.</p>
<p>Consider the below code fragments:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// 1. Non generics with construction</span>
Pair p <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Pair<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span>, <span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// 2. Generics with construction</span>
Pair<span style="color: #339933;">&lt;</span>integer , Integer<span style="color: #339933;">&gt;</span> p <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Pair<span style="color: #339933;">&lt;</span>integer , Integer<span style="color: #339933;">&gt;</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span>, <span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// 3. Generics with type inference and construction</span>
var p <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Pair<span style="color: #339933;">&lt;</span>integer , Integer<span style="color: #339933;">&gt;</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span>, <span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// 4. Generics with method invocation</span>
Pair<span style="color: #339933;">&lt;</span>integer , Integer<span style="color: #339933;">&gt;</span> p <span style="color: #339933;">=</span> o.<span style="color: #006633;">getPair</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// 5. Type inference with method invocation</span>
var p <span style="color: #339933;">=</span> o.<span style="color: #006633;">getPair</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Compare (1) with (2). (2) is very long compared to the non-generic version and the repetition is annoying. I believe that type inference in (3) is very clean and easy to read. Now add to this that most Java types have really long names. Breaking simple variable declarations to multiple lines isn&#8217;t very easy to read.</p>
<p>Now let us consider (4) and (5). In (4) we do not have repetition of the type information and the declaration is easy to read and understand. In (5) we have type inference and the programmer does not immediately see the type of the variable <code>p</code>. I agree that since the programs are read more times than they are written and if the programmer does not use a modern IDE (like <a href="http://www.eclipse.org">Eclipse</a>, <a href="http://www.netbeans.org">Netbeans</a> or <a href="http://www.jetbrains.com/idea/">IDEA</a>) this makes the program harder to understand. But if the language supports type inference a programmer is free to use (4) instead of (5) and (3) instead of (2) to get the best of both worlds.</p>
<p>I will also like to add that code like this</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">HashMap<span style="color: #339933;">&lt;</span>integer , LinkedList<span style="color: #339933;">&gt;</span>, Integer<span style="color: #339933;">&gt;&gt;</span> map <span style="color: #339933;">=</span>
	<span style="color: #000000; font-weight: bold;">new</span> HashMap<span style="color: #339933;">&lt;</span>integer , LinkedList<span style="color: #339933;">&gt;</span>, Integer<span style="color: #339933;">&gt;&gt;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>is acceptable only because we use sophisticated IDEs with code complete (we have to write <code>HashMap&lt;Integer, LinkedList&lt;Integer&gt;&gt;</code> twice). Why the same argument cannot be used to accept the code in example (5)?</p>
<p>My conclusion is that we do not lose in type safety and we improve productivity and code readability with just a minor syntactic change. I wonder why statically typed languages like <a href="http://java.sun.com">Java</a> and <a href="http://msdn.microsoft.com/vcsharp/future/">C#</a> did adopt type inference earlier or from the start like functional languages as <a href="http://www.smlnj.org/">SML</a> and <a href="http://haskell.org/">Haskell</a>.</p>
<p>The other feature that I like is <em>lambda expressions</em>. Lambda expressions (or if you prefer closures) are the basic building block of functional programming. Lambda expressions can be found in functional programming languages like <a href="http://www.lisp.org/">LISP,</a> <a href="http://haskell.org/">Haskell</a> and <a href="http://www.smlnj.org/">SML</a> and also in modern scripting languages like <a href="http://www.perl.org/">PERL</a>, <a href="http://www.python.org/">Python</a>, <a href="http://www.ruby-lang.org/">Ruby</a> and <a href="http://groovy.codehaus.org/">Groovy</a>.</p>
<p>Now I might be a little biased because I learned to program in <a href="http://www.schemers.org/">Scheme</a> and <a href="http://www.smlnj.org/">SML</a> but I do believe that functional programming provides very elegant solutions to a lot of problems. IMHO the existence of lambda expressions in languages like <a href="http://www.ruby-lang.org/">Ruby</a> and <a href="http://groovy.codehaus.org/">Groovy</a> is one of the reasons why so many <a href="http://java.sun.com">Java</a> developers are using them.</p>
<p>Consider the below code where I have implemented the equivalent code with the  <a href="http://msdn.microsoft.com/netframework/future/linq/">XLinq</a> example in <a href="http://java.sun.com">Java</a> with <a href="http://dom4j.org/">dom4j</a>. (<a href="http://dom4j.org/">Dom4j</a> is a great and fast <a href="http://www.w3.org/DOM/">DOM</a> API for <a href="http://www.w3.org/XML/">XML</a> processing in <a href="http://java.sun.com">Java</a>)</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #003399;">Document</span> doc <span style="color: #339933;">=</span> ...
<span style="color: #003399;">Document</span> contacts <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Document</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span> <span style="color: #003399;">Iterator</span> i <span style="color: #339933;">=</span> doc.<span style="color: #006633;">elementIterator</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;contact&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> i.<span style="color: #006633;">hasNext</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #003399;">Element</span> contact <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">Element</span><span style="color: #009900;">&#41;</span> i.<span style="color: #006633;">next</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;home&quot;</span>.<span style="color: #006633;">equals</span><span style="color: #009900;">&#40;</span>contact.<span style="color: #006633;">getAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getValue</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
        contacts.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span>contact<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span></pre></div></div>

<p>In my humble opinion the <a href="http://msdn.microsoft.com/vcsharp/future/">C#</a> version is not only more short but more clean and elegant. <a href="http://martinfowler.com/">Martin Fowler</a> recently wrote a <a href="http://martinfowler.com/bliki/CollectionClosureMethod.html">post</a> on his <a href="http://martinfowler.com/bliki/">blog</a> about how closures (lambda expressions) and collections fit nicely together. I suggest that you read it since it provides a lot of examples (in <a href="http://ruby-lang.org">Ruby</a>) where the functional way of doing things is simpler and more elegant.</p>
<p>There are two RFEs at the<a href="http://bugs.sun.com/bugdatabase/index.jsp"> SUN&#8217;s Java bug database</a> about adding lambda expressions to the Java programming language. Both of the RFE&#8217;s are in “In progress, request for enhancement” state so we can vote to bring this feature to <a href="http://java.sun.com">Java</a>.</p>
<p>Also Graham Hamilton, Mark Reinhold and Gilad Bracha in their “Evolving the Java Language” talk this year at JavaOne said that they are considering to add closures/method references (lambda expressions) to the next version of Java. (Please note that I wasn&#8217;t at JavaOne and I have only seen this in their slides. I am eagerly waiting for the multimedia content of the presentations to become available online).</p>
<p>If you are a <a href="http://java.sun.com">Java</a> programmer who things that lambda expressions (closures) could be useful in the <a href="http://java.sun.com">Java</a> programming language take five minutes of your time and vote for both of the below RFEs.</p>
<p>Bug ID: <a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5014235">5014235</a><br />
Synopsis: Closures support instead of annonymous inner classes<br />
Votes: 13<br />
Submit Date: 16-MAR-2004</p>
<p>Bug ID: <a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4483171">4483171</a><br />
Synopsis: Adding support for delegates and method references<br />
Votes: 8<br />
Submit Date: 23-JUL-2001</p>
<p>BTW <a href="http://blogs.tedneward.com/">Ted Neward</a> has written a very good <a href="http://blogs.tedneward.com/CommentView,guid,a938fb77-c9ad-41b0-ba3b-28bd9eeddbc0.aspx">overview</a> of all the new C# 3.0 features.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tzavellas.com/techblog/2005/09/28/two-new-c-30-features-that-java-needs/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
<enclosure url="http://download.microsoft.com/download/4/7/0/4703eba2-78c4-4b09-8912-69f6c38d3a56/XLinq.wmv" length="3756970" type="video/x-ms-wmv" />
		</item>
		<item>
		<title>Cool demos of mono applications</title>
		<link>http://www.tzavellas.com/techblog/2005/03/08/natorgdemos/</link>
		<comments>http://www.tzavellas.com/techblog/2005/03/08/natorgdemos/#comments</comments>
		<pubDate>Tue, 08 Mar 2005 01:17:08 +0000</pubDate>
		<dc:creator>spiros</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[Linux/Unix]]></category>
		<category><![CDATA[Mono]]></category>

		<guid isPermaLink="false">http://www.tzavellas.com/techblog/?p=6</guid>
		<description><![CDATA[In this page Nat Friedman (of Gnome and Ximian fame) has created some really nice demos showing Beagle and Mono. Mono is an OSS implmentation of Microsoft&#8217;s .Net platform. Nat has created two demos for Monodoc (the Mono documentation browser) and for creating GUIs with Glade and Gtk#. Beagle is a cool OSS application written [...]]]></description>
			<content:encoded><![CDATA[<p>In <a href="http://nat.org/demos">this</a> page <a href="http://nat.org">Nat Friedman</a> (of <a href="http://www.gnome.org">Gnome</a> and <a href="http://www.ximian.com">Ximian</a> fame) has created some really nice demos showing <a href="http://www.gnome.org/projects/beagle">Beagle</a> and <a href="http://www.mono-project.com">Mono</a>.</p>
<p><a href="http://www.mono-project.com">Mono</a> is an <acronym title="Open Source Software">OSS</acronym> implmentation of Microsoft&#8217;s .Net platform. Nat has created two demos for <a href="http://monohandbook.monoforge.com/monkeyguide/tools/monodocbrowser.html">Monodoc</a> (the Mono documentation browser) and for creating <acronym title="Graphical User Interface">GUI</acronym>s with <a href="http://glade.gnome.org/">Glade</a> and <a href="http://gtk-sharp.sourceforge.net/">Gtk#</a>.</p>
<p><a href="http://www.gnome.org/projects/beagle">Beagle</a> is a cool <acronym title="Open Source Software">OSS</acronym> application written in C#. If I am correct, it currently runs on <a href="http://www.linux.org">Linux</a> using <a href="http://gtk-sharp.sourceforge.net/">Gtk#</a> and there is an ongoing effort to port it to Windows. <a href="http://www.gnome.org/projects/beagle">Beagle</a> is a desktop search tool. It indexes your data (doc, pdf, images, html,&#8230; files) and let&#8217;s you search them efficiently.</p>
<p>I really like the fact that <a href="http://www.gnome.org/projects/beagle">Beagle</a> integrates well with other desktop applications (mail, IM, photo albums,&#8230;) and that supports many file types. The coolest feature of Beagle is live incremental indexing of files. It indexes your files as you create them without having to rebuild its indexes. See it <a href="http://nat.org/demos/beagle-2.html">here</a> in action.</p>
<p>Beagle is backed by <a href="http://www.dotlucene.net/">DotLucene</a> the .Net (C#) port of the fabulous <a href="jakarta.apache.org/lucene">Lucene</a> text search engine library.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tzavellas.com/techblog/2005/03/08/natorgdemos/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
