<?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>Alain M. Lafon &#187; C#</title> <atom:link href="http://blog.dispatched.ch/tag/c/feed/" rel="self" type="application/rss+xml" /><link>http://blog.dispatched.ch</link> <description>code, life and struggles thereof</description> <lastBuildDate>Mon, 16 Jan 2012 13:44:17 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <item><title>C# 4.0&#8242;s dynamicity</title><link>http://blog.dispatched.ch/2010/05/10/c-40s-dynamicity/</link> <comments>http://blog.dispatched.ch/2010/05/10/c-40s-dynamicity/#comments</comments> <pubDate>Mon, 10 May 2010 21:23:21 +0000</pubDate> <dc:creator>Alain M. Lafon</dc:creator> <category><![CDATA[articles]]></category> <category><![CDATA[C#]]></category> <category><![CDATA[python]]></category> <guid
isPermaLink="false">http://blog.dispatched.ch/?p=985</guid> <description><![CDATA[I just found an article ranking highly on Hacker News (my favourite read) concerning the release of C# 4.0 &#8211; you can find it on blogs.msdn.com. On this blog Microsoft claims a couple of highly sophistacated new features. Being the spoiled guy I am, they just seem natural to me. Since they started their article [...]]]></description> <content:encoded><![CDATA[<p>I just found an article ranking highly on <a
href="http://news.ycombinator.com">Hacker News</a> (my favourite read) concerning the release of C# 4.0 &#8211; you can find it on <a
href="http://blogs.msdn.com/csharpfaq/archive/2010/04/12/get-ready-for-c-4-0.aspx">blogs.msdn.com</a>. On this blog Microsoft claims a couple of highly sophistacated new features. Being the spoiled guy I am, they just seem natural to me. Since they started their article with the words &#8220;The <strong>dynamic</strong> keyword is a key feature of this release.&#8221;, let me demonstrate the <em>new</em> features in a really dynamically typed language where they have been around for quite some time: Python</p><h3>Dynamic</h3><table><tr><td><h4>C#</h4></td><td>&nbsp;</td><td><pre class="brush: cpp; title: ; notranslate">
                        dynamic contact = new ExpandoObject();
                        contact.Name = &quot;Patrick Hines&quot;;
                        contact.Phone = &quot;206-555-0144&quot;;
                        </pre></td></tr><tr><td><h4>Python</h4></td><td>&nbsp;</td><td><pre class="brush: python; title: ; notranslate">
                        class contact: None
                        contact.Name = &quot;Patrick Hines&quot;
                        contact.Phone = &quot;206-555-0144&quot;
                        </pre></td></tr></table><h3>Optional (or Default) Parameters</h3><table><tr><td><h4>C#</h4></td><td>&nbsp;</td><td><pre class="brush: cpp; title: ; notranslate">
                        public static void SomeMethod(int optional = 0) { }
                        SomeMethod(); // 0 is used in the method.
                        SomeMethod(10);
                        </pre></td></tr><tr><td><h4>Python</h4></td><td>&nbsp;</td><td><pre class="brush: python; title: ; notranslate">
                        def some_method(optional = 0): pass
                        some_method()
                        some_method(10)
                        </pre></td></tr></tr></table><h3>Named Arguments</h3><table><tr><td><h4>C#</h4></td><td>&nbsp;</td><td><pre class="brush: cpp; title: ; notranslate">
                        var sample = new List&lt;String&gt;();
                        sample.InsertRange(collection: new List&lt;String&gt;(), index: 0);
                        sample.InsertRange(index: 0, collection: new List&lt;String&gt;());
                        </pre></td></tr><tr><td><h4>Python</h4></td><td>&nbsp;</td><td><pre class="brush: python; title: ; notranslate">
                        def foo(bar, foobar): None
                        foo(bar='asdf', foobar=12)
                        foo(foobar=12, bar='asdf')
                        </pre></td></tr></table><p>I honestly know that a comparison of a statically typed language on the CLR and an interpreted <emph>dynamic</emph> language doesn&#8217;t account for too much. But since Microsoft is making a fuzz about dynamic being <b>the</b> keyword of the new release, I felt the urge to drop this note.</p><p>The Python code was tested with v2.5 &#8211; that&#8217;s the oldest installation I&#8217;ve got. However, it&#8217;s old enough, because .NET didn&#8217;t even have decent IPC back then (i.e. Named pipes were <a
href="http://msdn.microsoft.com/en-us/library/system.io.pipes.namedpipeserverstream.aspx[+]" class="broken_link">added</a> in .NET 3.5).</p><p>Well, that&#8217;s my rant for the night &#8211; I&#8217;m going back to teaching myself a real programmers language(<a
href="http://clojure.org">Clojure</a>) &#8211; as you should, too(;</p><table
border="0"><tbody><tr><td><script type="text/javascript">tweetmeme_url = 'http://blog.dispatched.ch/2010/05/10/c-40s-dynamicity/';</script><br
/> <script src="http://tweetmeme.com/i/scripts/button.js" type="text/javascript"></script></td><td>&nbsp;&nbsp;&nbsp;</td><td> If you liked the article, follow me on twitter <a
href="http://twitter.com/preek">here</a><br
/> <a
href="http://twitter.com/preek"><img
class="alignnone" style="border: 0pt none;" title="twitter_preek" src="http://blog.dispatched.ch/wp-content/uploads/2009/05/twitter_preek.gif" border="0" alt="twitter_preek" width="180" height="18" /></a></td></tr></tbody></table> ]]></content:encoded> <wfw:commentRss>http://blog.dispatched.ch/2010/05/10/c-40s-dynamicity/feed/</wfw:commentRss> <slash:comments>1</slash:comments> </item> </channel> </rss>

<!-- W3 Total Cache: Minify debug info:
Engine:             disk: basic
Theme:              44184
Template:           tag
-->
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Served from: blog.dispatched.ch @ 2012-02-04 17:42:51 -->

<!-- W3 Total Cache: Page cache debug info:
Engine:             disk: basic
Cache key:          w3tc_blog.dispatched.ch_1_page_d79b5ebbf3c31d57428455e974973547_gzip
Caching:            enabled
Status:             not cached
Creation Time:      0.411s
Header info:
ETag:               "274915380f43058ea86f113a32d41d8b"
Last-Modified:      Mon, 16 Jan 2012 13:44:17 GMT
Vary:               Accept-Encoding, Cookie
X-Powered-By:       W3 Total Cache/0.9.2.4
Content-Encoding:   gzip
X-Pingback:         http://blog.dispatched.ch/xmlrpc.php
Content-Type:       text/xml; charset=UTF-8
-->
