<?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:creativeCommons="http://backend.userland.com/creativeCommonsRssModule">

<channel>
	<title>Blog of Anders Rune Jensen &#187; c#</title>
	<atom:link href="http://people.iola.dk/arj/tag/c/feed/" rel="self" type="application/rss+xml" />
	<link>http://people.iola.dk/arj</link>
	<description>metalinguistic musings and other related ramblings</description>
	<lastBuildDate>Sun, 13 Jun 2010 18:00:06 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
<creativeCommons:license>http://creativecommons.org/licenses/by-sa/2.5/dk/</creativeCommons:license>		<item>
		<title>Programming nirvana part 4: the repl</title>
		<link>http://people.iola.dk/arj/2010/01/28/programming-nirvana-part-4-the-repl/</link>
		<comments>http://people.iola.dk/arj/2010/01/28/programming-nirvana-part-4-the-repl/#comments</comments>
		<pubDate>Thu, 28 Jan 2010 19:51:33 +0000</pubDate>
		<dc:creator>Anders Rune Jensen</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[clojure]]></category>
		<category><![CDATA[debugging]]></category>
		<category><![CDATA[firebug]]></category>
		<category><![CDATA[lisp]]></category>

		<guid isPermaLink="false">http://people.iola.dk/arj/?p=428</guid>
		<description><![CDATA[<p>A <a href="http://en.wikipedia.org/wiki/REPL">repl</a> is a very important tool in the arsenal of a programmer. It allows one to test bits and pieces of code and then assembling that into a running program. Examples of this includes the excellent firebug utility for firefox and various shells (like the python shell). There has even been <a href="http://tirania.org/blog/archive/2008/Sep-08.html">tries</a> to bring a repl to C#, but the languages is not at all designed for this purpose, so it&#8217;s a crude hack at best.</p>
<p>Often developing using the repl consists of a lot of copy pasting back and forth between then editor and the repl. Moving the repl into the editor makes this even less painful, but I would argue that in order to fully embrace a repl one has to have something like lisp, or a very good editor (that I havn&#8217;t seen yet). In lisp it&#8217;s very easy to take parts of a function and evaluation only that part simply by finding the right parenthesis and evaluation that. Using Emacs and SLIME it&#8217;s a simple two-key-gesture.</p>
<p>But one can take it one step further. Why not simply start your program as a repl, instead of adding a repl to your program. That way also the running state of the program can be determined. But in order for that to work, one has to be able to redefine functions without stopping the program. <a href="http://clojure.org/dynamic">Clojure</a> allows that, and it&#8217;s the key that makes it all work.</p>
<p>Programming in clojure is a process of organically growing your program in a bottom-up fashion where the running state of the program allows one to inspect, debug and fix programs all without shutting it down.</p>
<p>The best way to do this is to start up a repl in a seperate process and then to connect to that process, that way one can always disconnect and reconnect again when the need arises.</p>
]]></description>
		<wfw:commentRss>http://people.iola.dk/arj/2010/01/28/programming-nirvana-part-4-the-repl/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Programming nirvana part 2: be agile</title>
		<link>http://people.iola.dk/arj/2010/01/13/programming-nirvana-part-2/</link>
		<comments>http://people.iola.dk/arj/2010/01/13/programming-nirvana-part-2/#comments</comments>
		<pubDate>Wed, 13 Jan 2010 21:28:29 +0000</pubDate>
		<dc:creator>Anders Rune Jensen</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[agile]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[compilation]]></category>
		<category><![CDATA[django]]></category>
		<category><![CDATA[golang]]></category>
		<category><![CDATA[lisp]]></category>

		<guid isPermaLink="false">http://people.iola.dk/arj/?p=416</guid>
		<description><![CDATA[<p>In <a href="http://people.iola.dk/arj/2010/01/11/programming-nirvana-part-1/">part 1</a> I made the very brief argument that compiling sucks. I really like that cartoon since there is a lot of truth to it. Compiling sucks mainly because it breaks flow. There has been <a href="http://msdn.microsoft.com/en-us/vcsharp/aa336809.aspx">several</a> <a href="http://golang.org/">tries</a> to fix <a href="http://en.wikipedia.org/wiki/C%2B%2B">it</a> by lowering the time it takes to compile but in the end, it&#8217;s still the same loop: write, compile, &#8220;debug&#8221;.</p>
<p>There is another layer to it as well, one that dynamic languages doesn&#8217;t necessarily imply: Developing a program should be having a running program that can be used while it is being written. This is one of the pillars of agile programming. Step one in achieving this goal is to separate the UI from the backend. Web is a natural way to do this.</p>
<p>Django comes very close to achieving this with it&#8217;s automatic reloading on change, but the biggest problem is that it&#8217;s not able to automatically migrate the most basic model changes. On the other hand Django has many other things going for it so it is by no means a bad choice. But there might be a better one lurking in the dark.</p>
<p><img class="aligncenter" title="Lisp" src="http://imgs.xkcd.com/comics/lisp_cycles.png" alt="" width="486" height="160" /></p>
]]></description>
		<wfw:commentRss>http://people.iola.dk/arj/2010/01/13/programming-nirvana-part-2/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Go</title>
		<link>http://people.iola.dk/arj/2009/11/11/go/</link>
		<comments>http://people.iola.dk/arj/2009/11/11/go/#comments</comments>
		<pubDate>Wed, 11 Nov 2009 09:19:34 +0000</pubDate>
		<dc:creator>Anders Rune Jensen</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[erlang]]></category>
		<category><![CDATA[functional]]></category>
		<category><![CDATA[go]]></category>
		<category><![CDATA[OO]]></category>

		<guid isPermaLink="false">http://people.iola.dk/arj/?p=398</guid>
		<description><![CDATA[<p>Google released a new <a href="http://golang.org/"><em>system</em> programming language</a>. I wonder if the names of <a href="http://golang.org/doc/go_lang_faq.html#history">Robert Pike and Ken Thomsen</a> will make it more appealing to C people <img src='http://people.iola.dk/arj/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>It&#8217;s clearly meant to go head to head with C++. The two most interesting design decisions to me is their take on <a href="http://golang.org/doc/go_faq.html#Is_Go_an_object-oriented_language">OO</a> (feels like templates done right and no crappy inteheritance in the ordinary sense) and <a href="http://golang.org/doc/go_lang_faq.html#csp">concurrency</a> which looks a lot like Erlang because it&#8217;s CSP. Both of these things make it feel very functional.</p>
<p>So many languages to tinker with and so little time <img src='http://people.iola.dk/arj/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />  Oh yeah and it doesn&#8217;t run on Windows <em>yet</em> <img src='http://people.iola.dk/arj/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></description>
		<wfw:commentRss>http://people.iola.dk/arj/2009/11/11/go/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Python scoping</title>
		<link>http://people.iola.dk/arj/2009/11/09/python-scoping/</link>
		<comments>http://people.iola.dk/arj/2009/11/09/python-scoping/#comments</comments>
		<pubDate>Mon, 09 Nov 2009 10:30:08 +0000</pubDate>
		<dc:creator>Anders Rune Jensen</dc:creator>
				<category><![CDATA[python]]></category>
		<category><![CDATA[3000]]></category>
		<category><![CDATA[3k]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[scoping]]></category>

		<guid isPermaLink="false">http://people.iola.dk/arj/?p=388</guid>
		<description><![CDATA[<p>Last friday, Lau discovered an interesting edge case of python. Something that at first appeared to be a bug, but later revealed a deeper <em>truth</em> about the scoping of Python. I guess coming from a C++ background spoils one in some regards. Scoping in C++ is simple and uniform, I have never in many years of programming C++ got bitten by the scope of the language, something that I also can&#8217;t say about <a href="http://people.iola.dk/arj/2009/01/02/scoping-rules-in-c/">C#</a>.</p>
<p>The problem boils down to how Python treats local variable and global variables. The following example, stolen and modified from <a href="http://stackoverflow.com/questions/370357/python-variable-scope-question">here</a>, shows the edge case in its most simple form:</p>
<pre>a, b = (1, 2)

print(a, b)

def test():
    print(a)
    print(b)    # (A)
    #b=1       # (B)

test()</pre>
<p>(A) works as long as (B) is commented out. The strange thing is that changing (B) into += produces the same result. Actually it is the case that += a global variable will never work, unless you have declared it in the local scope first. This comes back to the way Python threats variables in the local scope. The following link has more <a href="http://www.saltycrane.com/blog/2008/01/python-variable-scope-notes/">examples</a> to illustrate how scoping works and also how this is different in Python 3k. As explained on <a href="http://stackoverflow.com/questions/370357/python-variable-scope-question">Stackoverflow</a>, using the dis functionality sheds some light on strange cases like these. All this said, the scoping has one good thing going for it. The following is quite useful and perfectly legal in Python:</p>
<pre>i = 0</p>
<p>def ex1():<br />
   if i &lt; 0:<br />
      b = 10<br />
   else:<br />
      b = 20<br />
   print b</p>
<p>ex1()</re></p>
]]></description>
		<wfw:commentRss>http://people.iola.dk/arj/2009/11/09/python-scoping/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Profiling multithreading applications</title>
		<link>http://people.iola.dk/arj/2009/09/25/profiling-multithreading-applications/</link>
		<comments>http://people.iola.dk/arj/2009/09/25/profiling-multithreading-applications/#comments</comments>
		<pubDate>Fri, 25 Sep 2009 12:16:51 +0000</pubDate>
		<dc:creator>Anders Rune Jensen</dc:creator>
				<category><![CDATA[profiling]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[mono]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://people.iola.dk/arj/?p=370</guid>
		<description><![CDATA[<p>I&#8217;ve written about profiling <a href="http://people.iola.dk/arj/2006/02/08/profiling-mmsv2/">before</a> in the general case. But when it comes to <a href="http://en.wikipedia.org/wiki/Multithreading">multithreading</a>, there are a few more factors to consider such as lock contention and cache invalidation that affect performance. And this is where <a href="http://0pointer.de/blog/projects/mutrace">mutrace</a> (mutex profiler) comes into the picture. The profiler has a very low overhead compared (no perceived delay for me) to other solutions and gives quite nice results. I tested it on <a href="http://mymediasystem.org/">My Media System</a> (C++) and <a href="http://www.iola.dk/nemo/">Nemo</a> (C#) and got interesting results for both. I knew more or less what the results for mms would be, but the results for Nemo was a bit suprising. The lock contention was significantly higher than for mms, even though I didn&#8217;t really use a multithreaded design for Nemo. So I guess it comes from the mono platform itself. Sadly it seems that mono programs aren&#8217;t compiled with -rdynamic, so the results that one gets are quite hard to decipher.</p>
]]></description>
		<wfw:commentRss>http://people.iola.dk/arj/2009/09/25/profiling-multithreading-applications/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>On designing libraries</title>
		<link>http://people.iola.dk/arj/2009/05/14/on-designing-libraries/</link>
		<comments>http://people.iola.dk/arj/2009/05/14/on-designing-libraries/#comments</comments>
		<pubDate>Thu, 14 May 2009 10:01:15 +0000</pubDate>
		<dc:creator>Anders Rune Jensen</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[devexpress]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://people.iola.dk/arj/?p=318</guid>
		<description><![CDATA[<p>I recently finished up a big project at <a href="http://www.iola.dk">IOLA</a> which used two major components: Javascript and c# (.NET). It was interesting for me to see the big difference in the libraries for these platforms. For Javascript we used the excellent <a href="http://www.jquery.com">jQuery</a> library. For .NET we used the very buggy <a href="http://www.devexpress.com">Devexpress</a> library. jQuery, like Javascript, is very simple. .NET on the other hand is overload with interfaces and concepts. What is interesting of course is that this philosophy shines through in libraries build on top of both platforms.</p>
<p>Devexpress is overloaded with concepts and the size of the library is just insane, the latest release is 221MB excluding kitching sink. Compared to jQueries 19KB. jQuery on the other hand focuses on a simple core with just the right amount of abstractions (very lispy), and delegates specific functionality to plugins, such as <a href="http://code.google.com/p/flot/">flot</a>. The difference of course in part comes from the fact that jQuery is an open source project, while devexpress is a commercial project.</p>
<p>You just have to look at the release notes for each of these projects in order to see the difference. jQuery focused on making their already working code faster and fixing bugs. While devexpress spend most of their time added a number of new features. The problem is that in a commercial project fixing bugs doesn&#8217;t pay up as well as implementing new features. Or at least that used to be the case. In the era of google that simply is not true. Anyone can put in devexpress and find out if the library sucks (which it to a large degree does) or if it rocks. The sooner they realise that small is the new big, the sooner we will start getting better libraries.</p>
]]></description>
		<wfw:commentRss>http://people.iola.dk/arj/2009/05/14/on-designing-libraries/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Scoping rules in c#</title>
		<link>http://people.iola.dk/arj/2009/01/02/scoping-rules-in-c/</link>
		<comments>http://people.iola.dk/arj/2009/01/02/scoping-rules-in-c/#comments</comments>
		<pubDate>Fri, 02 Jan 2009 15:32:12 +0000</pubDate>
		<dc:creator>Anders Rune Jensen</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[language design]]></category>
		<category><![CDATA[microsoft]]></category>

		<guid isPermaLink="false">http://people.iola.dk/arj/?p=242</guid>
		<description><![CDATA[<p>What a dull subject. Exactly so because it&#8217;s supposed to be a done deal, I don&#8217;t hear many people arguing about scope rules anymore. That is why I was so suprised when the compiler complained about some perfectly valid code I had written.  At first I thought it was only a peculiarity of the way closures are implemented in c#, but as I dug deeper, the scoping rules of c# seems to be&#8230; well just annoyingly stupid. Lets start with a simple case:</p>
<blockquote><p>OleDbCommand command = SQLServer.CreateCommand();</p>
<p>&#8230;</p>
<p>if (true)</p>
<p>{</p>
<p>OleDbCommand command = SQLServer.CreateCommand();</p>
<p>}</p></blockquote>
<p>I don&#8217;t think many people would argue that is just bad programming practice, but look what happens if we just change it a little:</p>
<blockquote><p>if (true)</p>
<p>{</p>
<p>OleDbCommand command = SQLServer.CreateCommand();</p>
<p>}</p>
<p>OleDbCommand command = SQLServer.CreateCommand();</p></blockquote>
<p>This fails with the exact same error. Apparently the command of the if statement prevents the other command from being declared, but since you can use command anymore this is just plainly wrong.  Furthermore closures behave the same way:</p>
<blockquote><p>VoidFunction t = delegate</p>
<p>{</p>
<p>OleDbCommand command = SQLServer.CreateCommand();</p>
<p>}</p>
<p>OleDbCommand command = SQLServer.CreateCommand();</p></blockquote>
<p>Please note that the closure has just been declared. For more discussion of the examples see <a href="http://stackoverflow.com/questions/404899/scope-of-variables-in-a-delegate">this thread on stackoverflow</a>.  I followed up with a <a href="http://stackoverflow.com/questions/405116/why-is-the-scope-of-if-and-delegates-this-way-in-c">question</a> of why the language guys at microsoft would have made such a bonehead mistake and there wasn&#8217;t any good reason in my mind.  I&#8217;m still puzzled why the compiler wouldn&#8217;t just issue a warning, but maybe warnings is one of those things they hated about C++ and decided it was just easier to swing the big No-hammer and be done with it.</p>
]]></description>
		<wfw:commentRss>http://people.iola.dk/arj/2009/01/02/scoping-rules-in-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
