<?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:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Zor&#039;s Blog</title>
	<atom:link href="http://xtzgzorex.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://xtzgzorex.wordpress.com</link>
	<description>Seeing Sharp</description>
	<lastBuildDate>Thu, 29 Dec 2011 05:45:09 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='xtzgzorex.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Zor&#039;s Blog</title>
		<link>http://xtzgzorex.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://xtzgzorex.wordpress.com/osd.xml" title="Zor&#039;s Blog" />
	<atom:link rel='hub' href='http://xtzgzorex.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Overloaded Functional Types</title>
		<link>http://xtzgzorex.wordpress.com/2011/11/04/overloaded-functional-types/</link>
		<comments>http://xtzgzorex.wordpress.com/2011/11/04/overloaded-functional-types/#comments</comments>
		<pubDate>Fri, 04 Nov 2011 20:03:47 +0000</pubDate>
		<dc:creator>XTZGZoReX</dc:creator>
				<category><![CDATA[Cesura]]></category>
		<category><![CDATA[F#]]></category>
		<category><![CDATA[Haskell]]></category>
		<category><![CDATA[MCI]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://xtzgzorex.wordpress.com/?p=801</guid>
		<description><![CDATA[As some of you may know, I&#8217;m working on a compiler infrastructure written in D. While the framework itself is rather high-level (it&#8217;s very close to actually being half of a compiler front end), an actual compiler implementation is needed to see if the whole thing will work out as well as I hope. Thus, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xtzgzorex.wordpress.com&amp;blog=13381977&amp;post=801&amp;subd=xtzgzorex&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>As some of you may know, I&#8217;m working on a compiler infrastructure written in D. While the framework itself is rather high-level (it&#8217;s very close to actually being half of a compiler front end), an actual compiler implementation is needed to see if the whole thing will work out as well as I hope.</p>
<p>Thus, Tony and I set out to design a simplistic functional programming language. It is heavily inspired by Haskell and OCaml, and has many similarities, though it does not have much in the way of OOP. In short, it&#8217;s a language with first-class functions, generics, records/discriminated unions, and finally, treats everything as a value (much like most FP languages). We call it Cesura.</p>
<p>So far, nothing of what I&#8217;ve mentioned is particularly new or innovative. In fact, very few FP languages don&#8217;t have the features I mentioned. However, one interesting feature that we thought up (and which, to our knowledge, hasn&#8217;t been used in any other language) is what we call <em>overloaded functional types</em>. I&#8217;ll spare you from any category theory and jump straight to the problem.</p>
<p>You&#8217;re given this code:</p>
<pre>sqr x : Int -&gt; Int = x * x
sqr x : Float -&gt; Float = x * x
f = sqr</pre>
<p>The problem is immediately obvious: Which of the two functions does f refer to?</p>
<p>You could perhaps solve the problem by doing:</p>
<pre>f : Float -&gt; Float = sqr</pre>
<p>This, however, completely defeats type inference and has lots of corner cases. If you passed sqr directly to a function, what would you do then?</p>
<p>We came to the conclusion that in order to maintain type inference and still have overloaded functions, we&#8217;d need to carry the overloads directly in the type system. This means:</p>
<pre>f = sqr // The type of f is now: Int -&gt; Int | Float -&gt; Float</pre>
<p>Here, we introduce the concept of an <em>overload set</em>. The type of f is a function that has an overload set consisting of Int -&gt; Int and Float -&gt; Float.</p>
<p>There are several advantages in this sort of type system. One of them is the fact that any function value is implicitly convertible to any function type whose overload set is a subset of the overload set of the function value&#8217;s function type.</p>
<p>But that&#8217;s not all. You might ask: What happens if I try to call f (from above)? How will the compiler know which function in the overload set I intend to call? The answer to this question is actually <em>very</em> simple:</p>
<pre>x = f 2
y = f 4.0</pre>
<p>Given this code, look at what&#8217;s passed to f in the first call. Clearly, it&#8217;s an integer. Thus, we know that a call to the Int -&gt; Int overload was intended. In the second call, we&#8217;re passing a floating-point value, and therefore we&#8217;re calling the Float -&gt; Float overload. So, x is of type Int and y is of type Float.</p>
<p>You might ask why we didn&#8217;t just choose to incorporate type classes, considering I claim that we&#8217;re heavily inspired by Haskell. The answer to this boils down to simplicity: Cesura needs to be a simple language utilizing as many features of the MCI framework as possible. We&#8217;re creating a simple, practical language, not a language utilizing extremely complex (but certainly beautiful) type system techniques.</p>
<p>Lastly, we&#8217;d really like some input on this approach. We&#8217;re still not entirely sure that it is the right way to go about this, though it does seem to be the most promising solution that isn&#8217;t overly complicated to implement. Also, if you know of some other language that uses this technique, please let us know!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xtzgzorex.wordpress.com/801/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xtzgzorex.wordpress.com/801/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xtzgzorex.wordpress.com/801/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xtzgzorex.wordpress.com/801/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/xtzgzorex.wordpress.com/801/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/xtzgzorex.wordpress.com/801/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/xtzgzorex.wordpress.com/801/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/xtzgzorex.wordpress.com/801/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xtzgzorex.wordpress.com/801/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xtzgzorex.wordpress.com/801/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xtzgzorex.wordpress.com/801/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xtzgzorex.wordpress.com/801/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xtzgzorex.wordpress.com/801/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xtzgzorex.wordpress.com/801/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xtzgzorex.wordpress.com&amp;blog=13381977&amp;post=801&amp;subd=xtzgzorex&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://xtzgzorex.wordpress.com/2011/11/04/overloaded-functional-types/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/42c54d81a5ed511408e947ccd526d858?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">XTZGZoReX</media:title>
		</media:content>
	</item>
		<item>
		<title>C#: Dynamic and Extension Methods</title>
		<link>http://xtzgzorex.wordpress.com/2011/10/14/c-dynamic-and-extension-methods/</link>
		<comments>http://xtzgzorex.wordpress.com/2011/10/14/c-dynamic-and-extension-methods/#comments</comments>
		<pubDate>Fri, 14 Oct 2011 14:11:03 +0000</pubDate>
		<dc:creator>XTZGZoReX</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://xtzgzorex.wordpress.com/?p=788</guid>
		<description><![CDATA[What does the following program do? namespace DynamicExtensionMethods { internal static class Program { private static int Square(this int i) { return i * i; } private static void Main() { ((dynamic)1).Square(); } } } Answer: It crashes. Unhandled Exception: Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: 'int' does not contain a definition for 'Square' Apparently, RuntimeBinder doesn&#8217;t take extension methods [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xtzgzorex.wordpress.com&amp;blog=13381977&amp;post=788&amp;subd=xtzgzorex&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>What does the following program do?</p>
<pre>namespace DynamicExtensionMethods
{
    internal static class Program
    {
        private static int Square(this int i)
        {
            return i * i;
        }

        private static void Main()
        {
            ((dynamic)1).Square();
        }
    }
}</pre>
<p>Answer: It crashes.</p>
<pre>Unhandled Exception: Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: 'int' does not contain a definition for 'Square'</pre>
<p>Apparently, RuntimeBinder doesn&#8217;t take extension methods into account. On one hand, it&#8217;s surprising because the dynamic binder supposedly acts like the C# compiler&#8217;s binder. On the other, RuntimeBinder is a framework thing and extension methods are a language feature. This makes me wonder if there would be any problematic corner cases with supporting extension methods in dynamic method calls&#8230;</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xtzgzorex.wordpress.com/788/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xtzgzorex.wordpress.com/788/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xtzgzorex.wordpress.com/788/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xtzgzorex.wordpress.com/788/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/xtzgzorex.wordpress.com/788/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/xtzgzorex.wordpress.com/788/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/xtzgzorex.wordpress.com/788/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/xtzgzorex.wordpress.com/788/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xtzgzorex.wordpress.com/788/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xtzgzorex.wordpress.com/788/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xtzgzorex.wordpress.com/788/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xtzgzorex.wordpress.com/788/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xtzgzorex.wordpress.com/788/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xtzgzorex.wordpress.com/788/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xtzgzorex.wordpress.com&amp;blog=13381977&amp;post=788&amp;subd=xtzgzorex&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://xtzgzorex.wordpress.com/2011/10/14/c-dynamic-and-extension-methods/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/42c54d81a5ed511408e947ccd526d858?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">XTZGZoReX</media:title>
		</media:content>
	</item>
		<item>
		<title>Three Reasons I Love Functional Programming</title>
		<link>http://xtzgzorex.wordpress.com/2011/10/11/three-reasons-i-love-functional-programming/</link>
		<comments>http://xtzgzorex.wordpress.com/2011/10/11/three-reasons-i-love-functional-programming/#comments</comments>
		<pubDate>Tue, 11 Oct 2011 13:25:11 +0000</pubDate>
		<dc:creator>XTZGZoReX</dc:creator>
				<category><![CDATA[Erlang]]></category>
		<category><![CDATA[F#]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://xtzgzorex.wordpress.com/?p=774</guid>
		<description><![CDATA[I realize a lot of people reading my blog are imperative programmers who haven&#8217;t looked into functional programming before. I figured I&#8217;d write a bit about why I find functional programming interesting and worthwhile. You might think that I like functional programming because of first-class functions. You might think that I like it because of [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xtzgzorex.wordpress.com&amp;blog=13381977&amp;post=774&amp;subd=xtzgzorex&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I realize a lot of people reading my blog are imperative programmers who haven&#8217;t looked into functional programming before. I figured I&#8217;d write a bit about why I find functional programming interesting and worthwhile.</p>
<p>You might think that I like functional programming because of first-class functions. You might think that I like it because of purity and immutability. Hell, you might even think that I like it because of natural recursion and tail calls. But no. Below are the three reasons I like the paradigm.</p>
<p><strong>Everything is an expression:</strong> Typing return everywhere is a pain in the ass. The fact that the last expression in a function will be its result <em>really</em> cuts down on typing and reading. Additionally, this means that what you would usually call an if statement is actually an if <em>expression</em>. This implies that the last expression in the true/false paths are the result of the if expression. The same goes for match expressions, loop expressions, and so on. This makes it possible to write very clear code compared to the imperative equivalent.</p>
<p><strong>Pattern matching:</strong> Basically the switch statement on steroids. Some (me being among them) will argue that this is what the switch statement always should have been, and that the switch statement in its current form is a language design mistake. Being able to match any value against any value makes for much more readable code, as compared to an if/else forest.</p>
<p><strong>Discriminated unions:</strong> Ever wanted C unions but with less insanity and more safety? DUs allow you to use any type for your cases and with well-defined behavior. That alone is already great, but DUs truly shine when combined with fluent pattern matching syntax.</p>
<p>Most of the features I described here are present in all functional languages in one form or another, but they are particularly important in F# and Erlang which are the functional languages I take most interest in.</p>
<p>It might surprise some people that I didn&#8217;t list first-class functions and immutability. I like those concepts too, but I don&#8217;t think they&#8217;re what makes functional programming <em>truly</em> beautiful. This is ironic, because they&#8217;re probably the most basic traits of a functional programming language. But, in the time I&#8217;ve worked with functional languages, I haven&#8217;t found those two features to be the <em>most</em> appealing to me (don&#8217;t take that the wrong way; they are still great).</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xtzgzorex.wordpress.com/774/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xtzgzorex.wordpress.com/774/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xtzgzorex.wordpress.com/774/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xtzgzorex.wordpress.com/774/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/xtzgzorex.wordpress.com/774/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/xtzgzorex.wordpress.com/774/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/xtzgzorex.wordpress.com/774/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/xtzgzorex.wordpress.com/774/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xtzgzorex.wordpress.com/774/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xtzgzorex.wordpress.com/774/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xtzgzorex.wordpress.com/774/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xtzgzorex.wordpress.com/774/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xtzgzorex.wordpress.com/774/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xtzgzorex.wordpress.com/774/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xtzgzorex.wordpress.com&amp;blog=13381977&amp;post=774&amp;subd=xtzgzorex&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://xtzgzorex.wordpress.com/2011/10/11/three-reasons-i-love-functional-programming/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/42c54d81a5ed511408e947ccd526d858?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">XTZGZoReX</media:title>
		</media:content>
	</item>
		<item>
		<title>Life: Status Update</title>
		<link>http://xtzgzorex.wordpress.com/2011/09/12/life-status-update/</link>
		<comments>http://xtzgzorex.wordpress.com/2011/09/12/life-status-update/#comments</comments>
		<pubDate>Mon, 12 Sep 2011 16:59:12 +0000</pubDate>
		<dc:creator>XTZGZoReX</dc:creator>
				<category><![CDATA[Life]]></category>
		<category><![CDATA[MCI]]></category>
		<category><![CDATA[Mono]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://xtzgzorex.wordpress.com/?p=759</guid>
		<description><![CDATA[I really don&#8217;t blog about my life often, but a lot of interesting stuff has been happening lately that I&#8217;d like to share. First, I&#8217;ve just become an intern at Xamarin. I&#8217;ll be working on the documentation build system and integration into the website and the MonoDevelop IDE. I was hired after GSoC was over, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xtzgzorex.wordpress.com&amp;blog=13381977&amp;post=759&amp;subd=xtzgzorex&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I really don&#8217;t blog about my life often, but a lot of interesting stuff has been happening lately that I&#8217;d like to share.</p>
<p>First, I&#8217;ve just become an intern at <a href="http://xamarin.com/">Xamarin</a>. I&#8217;ll be working on the documentation build system and integration into the website and the MonoDevelop IDE. I was hired after GSoC was over, following a recommendation from Miguel. I&#8217;m really looking forward to working with Xamarin; it&#8217;s an awesome team of skilled hackers.</p>
<p>Second, I&#8217;ve been accepted into university, starting February 1 (at <a href="http://www.ucnorth.dk/">the UCN</a>). The Danish name for the course I&#8217;m taking is &#8220;datamatiker&#8221;. They call it computer science in English, but it&#8217;s actually much more practically oriented than that (i.e. actual software development rather than theory). I was accepted based on my ability in the software development field, as I don&#8217;t fulfill the formal requirements (yet). This means I&#8217;ll probably quit high school, as I&#8217;d rather pursue something software-related than natural sciences.</p>
<p>In other (less life-related) news, I&#8217;ve also been putting some time into writing a compiler infrastructure library. I&#8217;ll be posting more about the goals and directions of that later.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xtzgzorex.wordpress.com/759/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xtzgzorex.wordpress.com/759/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xtzgzorex.wordpress.com/759/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xtzgzorex.wordpress.com/759/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/xtzgzorex.wordpress.com/759/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/xtzgzorex.wordpress.com/759/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/xtzgzorex.wordpress.com/759/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/xtzgzorex.wordpress.com/759/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xtzgzorex.wordpress.com/759/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xtzgzorex.wordpress.com/759/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xtzgzorex.wordpress.com/759/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xtzgzorex.wordpress.com/759/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xtzgzorex.wordpress.com/759/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xtzgzorex.wordpress.com/759/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xtzgzorex.wordpress.com&amp;blog=13381977&amp;post=759&amp;subd=xtzgzorex&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://xtzgzorex.wordpress.com/2011/09/12/life-status-update/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/42c54d81a5ed511408e947ccd526d858?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">XTZGZoReX</media:title>
		</media:content>
	</item>
		<item>
		<title>GSoC and the State of ILAsm</title>
		<link>http://xtzgzorex.wordpress.com/2011/08/23/gsoc-and-the-state-of-ilasm/</link>
		<comments>http://xtzgzorex.wordpress.com/2011/08/23/gsoc-and-the-state-of-ilasm/#comments</comments>
		<pubDate>Tue, 23 Aug 2011 17:59:53 +0000</pubDate>
		<dc:creator>XTZGZoReX</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[GSoC]]></category>
		<category><![CDATA[ILAsm]]></category>
		<category><![CDATA[Mono]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://xtzgzorex.wordpress.com/?p=735</guid>
		<description><![CDATA[GSoC 2011 is now officially over, and I figure I should write some sort of status post. First of all, the project is not completely done. I had anticipated this early on, and discussed with JB which parts I should focus on for the deadline. I did get a fair bit done for the deadline, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xtzgzorex.wordpress.com&amp;blog=13381977&amp;post=735&amp;subd=xtzgzorex&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>GSoC 2011 is now officially over, and I figure I should write some sort of status post.</p>
<p>First of all, the project is not completely done. I had anticipated this early on, and discussed with JB which parts I should focus on for the deadline. I did get a fair bit done for the deadline, but I wouldn&#8217;t quite say it&#8217;s ready for production use yet. I did, however, pass the final evaluation, as JB agreed to let me finish the project outside of GSoC (which I fully intend to do).</p>
<p>The project actually ended up being more involved than originally planned. The idea was to simply swap the PEAPI back end with Cecil, but I quickly realized that this was not quite as trivial as it seemed back then. I ended up ripping out the old code generation completely, emptying the code of every last parser production, updating the parser to .NET 4.0, and finally, adding the Cecil code generation back end in. You might think that all of this would have taken most of the entire GSoC period, but a lot of time was spent on spec reading too, not to mention figuring out weird quirks and corner cases in the Microsoft implementation of ILAsm. It&#8217;s scary just how much of the ILAsm language is poorly documented or not documented at all.</p>
<p>I&#8217;d like to extend my thanks to everyone in #cecil @ irc.gnome.org for helping me understand ILAsm, CIL, and the CLI in general.</p>
<p>I&#8217;ve also made some progress on the ILDasm front. It&#8217;s still missing a lot of features, but it does disassemble types and methods decently at this point. I&#8217;ll work more on it later; ILAsm comes first.</p>
<p>I recently switched ILAsm to a deferred type resolution model. This was JB&#8217;s idea, as a way to solve <a href="http://xtzgzorex.wordpress.com/2011/07/19/ilasm-the-mono-implementation/">the generic parameter issue I blogged about earlier</a>, and it&#8217;s worked nicely so far. This was probably the last major issue in the new ILAsm, so I expect to be doing more ILDasm work soon (there are only a couple of known ILAsm issues left).</p>
<p>During GSoC I also wrote a command line interface to the Mono soft debugger (SDB). It&#8217;s available <a href="https://github.com/alexrp/sdb-cli">here</a>. I wrote it primarily because using MonoDevelop (which was the only existing interface to SDB at the time) as a debugger for a command line application was not very convenient. This debugger also has a few cool features such as decompilation of code with no source code (through ICSharpCode.Decompiler).</p>
<p>Overall, it&#8217;s been a very fun and educational program for me. I now know a lot of things about the CLI that I didn&#8217;t have the slightest clue about before, and I finally managed to contribute something really significant to Mono. Working with JB and the Mono community has been an awesome experience, as everyone&#8217;s very helpful and easily approachable. I would definitely do this again if I get the chance.</p>
<p>I&#8217;ll probably make a final blog post whenever I get this entire project merged into mainline Mono.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xtzgzorex.wordpress.com/735/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xtzgzorex.wordpress.com/735/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xtzgzorex.wordpress.com/735/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xtzgzorex.wordpress.com/735/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/xtzgzorex.wordpress.com/735/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/xtzgzorex.wordpress.com/735/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/xtzgzorex.wordpress.com/735/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/xtzgzorex.wordpress.com/735/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xtzgzorex.wordpress.com/735/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xtzgzorex.wordpress.com/735/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xtzgzorex.wordpress.com/735/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xtzgzorex.wordpress.com/735/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xtzgzorex.wordpress.com/735/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xtzgzorex.wordpress.com/735/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xtzgzorex.wordpress.com&amp;blog=13381977&amp;post=735&amp;subd=xtzgzorex&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://xtzgzorex.wordpress.com/2011/08/23/gsoc-and-the-state-of-ilasm/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/42c54d81a5ed511408e947ccd526d858?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">XTZGZoReX</media:title>
		</media:content>
	</item>
		<item>
		<title>D: Building DMD and Phobos on Linux</title>
		<link>http://xtzgzorex.wordpress.com/2011/07/31/d-building-dmd-and-phobos-on-linux/</link>
		<comments>http://xtzgzorex.wordpress.com/2011/07/31/d-building-dmd-and-phobos-on-linux/#comments</comments>
		<pubDate>Sat, 30 Jul 2011 23:25:16 +0000</pubDate>
		<dc:creator>XTZGZoReX</dc:creator>
				<category><![CDATA[D]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://xtzgzorex.wordpress.com/?p=714</guid>
		<description><![CDATA[I&#8217;ve recently been having a deeper look into the D programming language, because writing a JIT on top of .NET turned out to be extremely hard without interfering with the .NET runtime. I didn&#8217;t quite want to use C, as that&#8217;s too low-level for the stuff I&#8217;m doing, and C++ is just broken. D seems [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xtzgzorex.wordpress.com&amp;blog=13381977&amp;post=714&amp;subd=xtzgzorex&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve recently been having a deeper look into <a href="http://www.d-programming-language.org/">the D programming language</a>, because writing a JIT on top of .NET turned out to be extremely hard without interfering with the .NET runtime. I didn&#8217;t quite want to use C, as that&#8217;s <em>too</em> low-level for the stuff I&#8217;m doing, and C++ is just broken. D seems to be both languages done right, and so I settled on that.</p>
<p>You can program D perfectly fine with the latest Digital Mars D (DMD) release, but I ended up having to contribute some patches to the standard libraries, and figured I might as well build everything from source.</p>
<p>First, you&#8217;re going to need Git, as <a href="https://github.com/D-Programming-Language">everything is hosted on GitHub</a>.</p>
<p>Next, do the following clones:</p>
<ul>
<li>/usr/src/dmd -&gt; https://github.com/D-Programming-Language/dmd.git</li>
<li>/usr/src/druntime -&gt; https://github.com/D-Programming-Language/druntime.git</li>
<li>/usr/src/phobos -&gt; https://github.com/D-Programming-Language/phobos.git</li>
<li>/usr/src/dtools -&gt; https://github.com/D-Programming-Language/tools.git</li>
</ul>
<p>In all of the makefiles, the MODEL variable specifies what bitness to build for. Here, I&#8217;m going to build for x86-64, so I&#8217;ll use 64. To build for x86, just use 32.</p>
<p>To build DMD, do:</p>
<pre>cd /usr/src/dmd/src;
gmake -f posix.mak MODEL=64;</pre>
<p>Everything should Just Work in the compile process. I&#8217;m using gmake because the makefiles are designed for GNU&#8217;s Make, and some systems don&#8217;t map make to that by default.</p>
<p>Unfortunately, DMD (and related repositories) don&#8217;t have any standard install target that we can use, so we&#8217;re just going to copy things into the file system. I&#8217;m using /usr/local/bin, /usr/local/lib, and /usr/local/include:</p>
<pre>cp dmd /usr/local/bin;
cp dmd.conf /etc;</pre>
<p>Verify that you have a DMD matching your system&#8217;s bitness:</p>
<pre>dmd;</pre>
<p>This should print:</p>
<pre>DMD64 D Compiler v2.055</pre>
<p>DMD32 should be printed for a 32-bit installation.</p>
<p>Now to build the core runtime libraries:</p>
<pre>cd /usr/src/druntime;
gmake -f posix.mak MODEL=64;</pre>
<p>If the build succeeds, we can copy the resulting interface files to our file system:</p>
<pre>mkdir /usr/local/include/d2;
cp -r import/* /usr/local/include/d2;</pre>
<p>Next, we build Phobos, which is the standard library containing facilities for concurrency, regular expressions, I/O, signals, math, text manipulation, and so on:</p>
<pre>cp /usr/src/phobos;
gmake -f posix.mak MODEL=64;</pre>
<p>Again, we copy library and interface files:</p>
<pre>cp generated/linux/release/64/libphobos2.a /usr/local/lib;
cp -r std /usr/local/include/d2;</pre>
<p>In the copy command for libphobos2.a, replace 64 with 32 if you built for x86.</p>
<p>With these in place, we should be able to build the additional D utilities:</p>
<pre>cd /usr/src/dtools;
dmd catdoc.d;
dmd rdmd.d;
cp catdoc /usr/local/bin;
cp rdmd /usr/local/bin;</pre>
<p>You should now have a fully functional installation of DMD! Feel free to post here if you run into trouble, or have some tip you&#8217;d like added to this tutorial.</p>
<p>I&#8217;d like to extend a thank you to everyone on #d @ irc.freenode.net for putting up with my questions. You guys are awesome. :)</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xtzgzorex.wordpress.com/714/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xtzgzorex.wordpress.com/714/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xtzgzorex.wordpress.com/714/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xtzgzorex.wordpress.com/714/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/xtzgzorex.wordpress.com/714/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/xtzgzorex.wordpress.com/714/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/xtzgzorex.wordpress.com/714/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/xtzgzorex.wordpress.com/714/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xtzgzorex.wordpress.com/714/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xtzgzorex.wordpress.com/714/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xtzgzorex.wordpress.com/714/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xtzgzorex.wordpress.com/714/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xtzgzorex.wordpress.com/714/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xtzgzorex.wordpress.com/714/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xtzgzorex.wordpress.com&amp;blog=13381977&amp;post=714&amp;subd=xtzgzorex&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://xtzgzorex.wordpress.com/2011/07/31/d-building-dmd-and-phobos-on-linux/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/42c54d81a5ed511408e947ccd526d858?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">XTZGZoReX</media:title>
		</media:content>
	</item>
		<item>
		<title>ILAsm: The Mono Implementation</title>
		<link>http://xtzgzorex.wordpress.com/2011/07/19/ilasm-the-mono-implementation/</link>
		<comments>http://xtzgzorex.wordpress.com/2011/07/19/ilasm-the-mono-implementation/#comments</comments>
		<pubDate>Tue, 19 Jul 2011 11:06:37 +0000</pubDate>
		<dc:creator>XTZGZoReX</dc:creator>
				<category><![CDATA[GSoC]]></category>
		<category><![CDATA[ILAsm]]></category>
		<category><![CDATA[Mono]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://xtzgzorex.wordpress.com/?p=704</guid>
		<description><![CDATA[This time, I&#8217;ll write about some issues I faced during development of Mono&#8217;s ILAsm and how I got around them. I&#8217;ve had to make several changes that make Mono&#8217;s ILAsm stricter than MS.NET&#8217;s or outright incompatible. First of all, we have generic parameters. In MS.NET&#8217;s ILAsm, !0 and !!0 are simply emitted as VAR 0 [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xtzgzorex.wordpress.com&amp;blog=13381977&amp;post=704&amp;subd=xtzgzorex&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This time, I&#8217;ll write about some issues I faced during development of Mono&#8217;s ILAsm and how I got around them. I&#8217;ve had to make several changes that make Mono&#8217;s ILAsm stricter than MS.NET&#8217;s or outright incompatible.</p>
<p>First of all, we have generic parameters. In MS.NET&#8217;s ILAsm, !0 and !!0 are simply emitted as VAR 0 and MVAR 0 in the metadata, meaning that you could do something like:</p>
<pre>.method public static !!0 Foo(!!1 bar)
{
    ldarg bar
    ret
}</pre>
<p>Even though !!1 refers to a generic parameter that does not exist, MS.NET&#8217;s ILAsm will gladly emit it, and not even warn you. Due to an API &#8220;limitation&#8221; in Cecil, Mono&#8217;s ILAsm cannot do this. All GenericParameter objects must have an owner (i.e. the type or method definition/reference) and must be contained in that owner&#8217;s GenericParameters collection at the correct index. Therefore, Mono&#8217;s ILAsm would throw an error for the above code, since !!0 is out of bounds. This is a slightly annoying incompatibility, but there&#8217;s not much I can do about it other than patching Cecil. That&#8217;s only going to happen, though, if it won&#8217;t cause API breaks for version 1.0.</p>
<p>Second, properties like .file alignment, .imagebase, and .stackreserve aren&#8217;t fully supported. Cecil currently has no way of setting these on a module. ILAsm will check the values and error if they&#8217;re invalid, though.</p>
<p>Third, several native and variant types are not supported in marshal signatures. These include variant, void, syschar, decimal, date, objectref, nested struct and null, void, int64, uint64, unsigned int64, lpstr, lpwstr, safearray, hresult, carray, userdefined, record, filetime, blob, stream, storage streamed_object, stored_object, blob_object, cf, clsid, as well as pointers/references/vectors of these. The reason is that Cecil doesn&#8217;t expose any way to set these types. Either way, most of these are deprecated nowadays. All other native/variant types are supported.</p>
<p>Fourth, support for .data declarations is very limited (we actually only do a weak attempt at emulating them). Cecil has no way of emitting data constants, and they&#8217;re implementation-defined anyway. Currently, the only thing we do with them is copy them to the InitialValue property of field definitions where appropriate. This is far from correct, but it&#8217;s the best we can do. Either way, you should avoid using these declarations. They don&#8217;t make a whole lot of sense in managed land.</p>
<p>Fifth, we have no support for parsing System.Reflection-notation strings (yet). This means that things like custom marshalers aren&#8217;t supported (the syntax will simply be ignored). A type parsing API will supposedly be exposed in Cecil 1.0.</p>
<p>Sixth, support for declarative security syntax is limited. While we support the full syntax specified by the standard, we don&#8217;t support all of the syntax MS.NET&#8217;s ILAsm does (specifically, the syntax resembling verbal custom attribute initialization).</p>
<p>Seventh, exported types are unfinished because Cecil lacks a way to manipulate the File table directly, and because of the lack of a type parser.</p>
<p>Eighth, we can&#8217;t emit custom attributes on manifest resources and assembly references. This is a Cecil limitation which should be relatively easy to fix.</p>
<p>Lastly, the .vtable/.vtfixup/.vtentry directives are unsupported. Again, these will be implemented once Cecil has support for them.</p>
<p>There are some other incompatibilities, but they&#8217;re very subtle and you&#8217;re unlikely to ever encounter them. And even if you do, ILAsm will warn you.</p>
<p>Generally, the differences between the two implementations will only be encountered in obscure features that most users are highly unlikely to be using, or when attempting to use nonstandard syntax. Rule of thumb: Stay away from these things and you&#8217;re safe.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xtzgzorex.wordpress.com/704/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xtzgzorex.wordpress.com/704/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xtzgzorex.wordpress.com/704/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xtzgzorex.wordpress.com/704/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/xtzgzorex.wordpress.com/704/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/xtzgzorex.wordpress.com/704/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/xtzgzorex.wordpress.com/704/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/xtzgzorex.wordpress.com/704/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xtzgzorex.wordpress.com/704/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xtzgzorex.wordpress.com/704/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xtzgzorex.wordpress.com/704/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xtzgzorex.wordpress.com/704/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xtzgzorex.wordpress.com/704/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xtzgzorex.wordpress.com/704/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xtzgzorex.wordpress.com&amp;blog=13381977&amp;post=704&amp;subd=xtzgzorex&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://xtzgzorex.wordpress.com/2011/07/19/ilasm-the-mono-implementation/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/42c54d81a5ed511408e947ccd526d858?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">XTZGZoReX</media:title>
		</media:content>
	</item>
		<item>
		<title>ReSharper and Code Contracts</title>
		<link>http://xtzgzorex.wordpress.com/2011/06/26/resharper-and-code-contracts/</link>
		<comments>http://xtzgzorex.wordpress.com/2011/06/26/resharper-and-code-contracts/#comments</comments>
		<pubDate>Sun, 26 Jun 2011 13:20:39 +0000</pubDate>
		<dc:creator>XTZGZoReX</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Visual Basic]]></category>

		<guid isPermaLink="false">http://xtzgzorex.wordpress.com/?p=697</guid>
		<description><![CDATA[I just ran into this today. It makes ReSharper shut up about possible null references when you use Code Contracts in your C#/VB projects. The XML file provided there is not complete, however. I&#8217;ve added the ContractInvariantMethodAttribute and ContractClassForAttribute attributes to the annotations so that ReSharper won&#8217;t claim that your contract classes and invariant methods [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xtzgzorex.wordpress.com&amp;blog=13381977&amp;post=697&amp;subd=xtzgzorex&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I just ran into <a href="http://www.infinitec.de/post/2010/11/18/Using-Code-Contracts-Visual-Studio-and-with-Resharper.aspx">this</a> today. It makes ReSharper shut up about possible null references when you use Code Contracts in your C#/VB projects.</p>
<p>The XML file provided there is not complete, however. I&#8217;ve added the ContractInvariantMethodAttribute and ContractClassForAttribute attributes to the annotations so that ReSharper won&#8217;t claim that your contract classes and invariant methods are unused.</p>
<p>The XML is <a href="http://www.pastie.org/2124578">here</a>.</p>
<p>Just drop this into C:\Program Files (x86)\JetBrains\ReSharper\v5.1\Bin\ExternalAnnotations\mscorlib as Microsoft.Contracts.xml or so.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xtzgzorex.wordpress.com/697/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xtzgzorex.wordpress.com/697/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xtzgzorex.wordpress.com/697/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xtzgzorex.wordpress.com/697/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/xtzgzorex.wordpress.com/697/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/xtzgzorex.wordpress.com/697/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/xtzgzorex.wordpress.com/697/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/xtzgzorex.wordpress.com/697/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xtzgzorex.wordpress.com/697/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xtzgzorex.wordpress.com/697/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xtzgzorex.wordpress.com/697/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xtzgzorex.wordpress.com/697/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xtzgzorex.wordpress.com/697/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xtzgzorex.wordpress.com/697/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xtzgzorex.wordpress.com&amp;blog=13381977&amp;post=697&amp;subd=xtzgzorex&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://xtzgzorex.wordpress.com/2011/06/26/resharper-and-code-contracts/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/42c54d81a5ed511408e947ccd526d858?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">XTZGZoReX</media:title>
		</media:content>
	</item>
		<item>
		<title>Managed JIT Compilation</title>
		<link>http://xtzgzorex.wordpress.com/2011/06/25/managed-jit-compilation/</link>
		<comments>http://xtzgzorex.wordpress.com/2011/06/25/managed-jit-compilation/#comments</comments>
		<pubDate>Sat, 25 Jun 2011 18:59:36 +0000</pubDate>
		<dc:creator>XTZGZoReX</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[MCI]]></category>
		<category><![CDATA[Mono]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://xtzgzorex.wordpress.com/?p=687</guid>
		<description><![CDATA[So these are some ideas I&#8217;ve thinking about for a good while, and I&#8217;m finally going to do something with them. A good while back, I blogged about how bytecode is evil. This post will explain what I intend to do with the AST idea. The project I&#8217;m working on consists of five major components: [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xtzgzorex.wordpress.com&amp;blog=13381977&amp;post=687&amp;subd=xtzgzorex&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>So these are some ideas I&#8217;ve thinking about for a good while, and I&#8217;m finally going to do something with them.</p>
<p>A good while back, I blogged about <a href="http://xtzgzorex.wordpress.com/2011/02/03/bytecode-is-evil/">how bytecode is evil</a>. This post will explain what I intend to do with the AST idea.</p>
<p>The project I&#8217;m working on consists of five major components:</p>
<ul>
<li>A new executable format consisting of binary-form ASTs</li>
<li>A managed JIT compiler</li>
<li>A new assembly-like intermediate language</li>
<li>An abstract bare-bones type system</li>
<li>An AST/assembly optimization layer</li>
</ul>
<p>The new executable format will be similar to the CIL format, but without all the PE bloat, and with one major difference: Code is stored as binary-serialized ASTs rather than bytecode. This allows easy introspection of compiled code, opening the doors for many interesting scenarios, such as translation from one language to another at runtime. I&#8217;ve chosen to call the format CAST (Compiled Abstract Syntax Trees).</p>
<p>To make the AST format actually interesting, a new JIT compiler needs to be implemented. This JIT compiler will understand the AST and operate on it for things such as optimization. For compatibility reasons, the AST will have a sort of RawCodeNode that contains plain assembly language (something similar to CIL but with registers). This is useful when one wants to emit non-AST code such as CIL/ILAsm, Java bytecode, Erlang BEAM, etc. I&#8217;ve chosen to call this JIT compiler Mono.Jit.</p>
<p>The new assembly-like intermediate language will be similar in nature to CIL. However, unlike CIL, this language will be based on registers and a stack, rather than locals and a stack. While the CIL approach is generally much prettier here, it&#8217;s less abstract and in some cases it is impossible to translate code to CIL (such as x86 machine code). I&#8217;m not sure what to call this yet, so for now, I&#8217;ll refer to it as IAL (Intermediate Assembly Language).</p>
<p>For CAST, I&#8217;ll eventually need to implement a compiler/decompiler, but for now, plans are to create a fluent API to create CAST code from .NET land. For IAL, I&#8217;ll just make a simple assembler/disassembler.</p>
<p>Now, in order for the AST to have any sort of meaning, a type system is needed. The type system in Mono.Jit is extremely simple; it supports only fields and methods on types. The JIT doesn&#8217;t need to know anything else in order to emit code. I do, however, plan to make an interface that allows giving the JIT optimization hints (such as &#8220;this type is completely immutable&#8221;, &#8220;this method makes no modification to members&#8221;, etc.). The JIT&#8217;s type system currently supports generics (types and methods), but I&#8217;m strongly contemplating delegating this to code loaders unless there is a compelling reason for the JIT to be aware of them.</p>
<p>Lastly, an optimization layer needs to be written. This layer will primarily concern itself with the AST input to the JIT, because that&#8217;s the entire point of this project. As mentioned, IAL is just a fallback for when you don&#8217;t have an AST to feed to the JIT. I don&#8217;t have any particular plans for optimization of IAL other than simple stuff like constant folding/propagation.</p>
<p>That&#8217;s it for now. More details will come as I write more code.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xtzgzorex.wordpress.com/687/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xtzgzorex.wordpress.com/687/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xtzgzorex.wordpress.com/687/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xtzgzorex.wordpress.com/687/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/xtzgzorex.wordpress.com/687/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/xtzgzorex.wordpress.com/687/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/xtzgzorex.wordpress.com/687/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/xtzgzorex.wordpress.com/687/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xtzgzorex.wordpress.com/687/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xtzgzorex.wordpress.com/687/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xtzgzorex.wordpress.com/687/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xtzgzorex.wordpress.com/687/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xtzgzorex.wordpress.com/687/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xtzgzorex.wordpress.com/687/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xtzgzorex.wordpress.com&amp;blog=13381977&amp;post=687&amp;subd=xtzgzorex&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://xtzgzorex.wordpress.com/2011/06/25/managed-jit-compilation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/42c54d81a5ed511408e947ccd526d858?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">XTZGZoReX</media:title>
		</media:content>
	</item>
		<item>
		<title>ILAsm: The Microsoft Implementation</title>
		<link>http://xtzgzorex.wordpress.com/2011/06/09/ilasm-the-microsoft-implementation/</link>
		<comments>http://xtzgzorex.wordpress.com/2011/06/09/ilasm-the-microsoft-implementation/#comments</comments>
		<pubDate>Thu, 09 Jun 2011 10:09:54 +0000</pubDate>
		<dc:creator>XTZGZoReX</dc:creator>
				<category><![CDATA[GSoC]]></category>
		<category><![CDATA[ILAsm]]></category>
		<category><![CDATA[Mono]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://xtzgzorex.wordpress.com/?p=660</guid>
		<description><![CDATA[So, we&#8217;re now 3 weeks into GSoC, and I figure I should start blogging about my work. This post will be about the ILAsm standard (specified in ECMA 335) and the Microsoft implementation. There are several annoying differences and incompatibilities between the two. As part of figuring them out, I&#8217;ve been reading Expert .NET 2.0 [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xtzgzorex.wordpress.com&amp;blog=13381977&amp;post=660&amp;subd=xtzgzorex&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>So, we&#8217;re now 3 weeks into GSoC, and I figure I should start blogging about my work.</p>
<p>This post will be about the ILAsm standard (specified in ECMA 335) and the Microsoft implementation. There are several annoying differences and incompatibilities between the two. As part of figuring them out, I&#8217;ve been reading <a href="http://www.amazon.com/Expert-NET-Assembler-Serge-Lidin/dp/1590596463">Expert .NET 2.0 IL Assembler</a> and <a href="http://msdn.microsoft.com/en-us/netframework/aa569283">the Microsoft-annotated ECMA 335 standard</a>.</p>
<p>The first difference is that MS.NET&#8217;s ILAsm does not respect the unsigned modifier on integer types. This means that an unsigned int32 will in effect be treated as an int32 (signed). I&#8217;ve chosen to break compatibility with Microsoft and correctly emit an unsigned integer, primarily because I think this is an outright stupid bug. Note that you can still get an unsigned integer by using uint32 with MS.NET. The latter form is preferred, anyway.</p>
<p>Second, MS.NET does not have the platformapi keyword. Instead, you have to use the winapi keyword, which makes your ILAsm source code unportable. In Mono&#8217;s ILAsm, we support both, in order to aid portability.</p>
<p>Third, MS.NET allows #line instead of .line for specifying source line information. This seems to be for compatibility reasons. Mono&#8217;s ILAsm supports both notations.</p>
<p>Fourth, MS.NET has a bunch of directives that just don&#8217;t exist in the standard. Specifically .file alignment, .imagebase, .language, and .namespace. We support all of them, though the first two currently have no actual effect. Note that use of .namespace is considered bad practice.</p>
<p>Fifth, MS.NET&#8217;s ILAsm doesn&#8217;t use .culture for specifying culture information, but rather .locale. This is directly against the standard, and the assembler won&#8217;t even recognize .culture. Mono&#8217;s ILAsm supports both notations.</p>
<p>Sixth, the MS.NET ILAsm doesn&#8217;t require the .hash directive; if it&#8217;s not specified, the hash will automatically be computed.</p>
<p>Seventh, the MS.NET ILAsm allows using &#8220;value class&#8221; in place of &#8220;valuetype&#8221; for indicating value types. This is relatively easy to handle, and Mono&#8217;s ILAsm does so. It is, however, considered bad notation.</p>
<p>Lastly, the MS.NET ILAsm allows specifying things like calling convention, type attributes, method attributes, field attributes, parameter attributes, and so on using flags(int32) notation. I&#8217;m sure this was done for a reason, but it seems like a great way to give developers the opportunity to make their programs unportable or impossible to run at all.</p>
<p>There are a lot of other incompatibilities, but they&#8217;re less annoying and easier to work around/implement.</p>
<p>That&#8217;s it for the this post. Next time: Implementation details of Mono&#8217;s ILAsm.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xtzgzorex.wordpress.com/660/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xtzgzorex.wordpress.com/660/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xtzgzorex.wordpress.com/660/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xtzgzorex.wordpress.com/660/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/xtzgzorex.wordpress.com/660/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/xtzgzorex.wordpress.com/660/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/xtzgzorex.wordpress.com/660/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/xtzgzorex.wordpress.com/660/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xtzgzorex.wordpress.com/660/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xtzgzorex.wordpress.com/660/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xtzgzorex.wordpress.com/660/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xtzgzorex.wordpress.com/660/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xtzgzorex.wordpress.com/660/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xtzgzorex.wordpress.com/660/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xtzgzorex.wordpress.com&amp;blog=13381977&amp;post=660&amp;subd=xtzgzorex&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://xtzgzorex.wordpress.com/2011/06/09/ilasm-the-microsoft-implementation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/42c54d81a5ed511408e947ccd526d858?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">XTZGZoReX</media:title>
		</media:content>
	</item>
	</channel>
</rss>
