the first step

I suppose that I should begin with an introduction. My name is Wes Dyer and I am a developer on the C# compiler team. I have many interests in the area of computing including but not limited to compilers, artificial intelligence (especially machine learning), data mining, and enterprise software. Previously, I was doing research in areas related to search, data mining, and machine learning. I absolutely love the C# language. I first encountered the language as an enterprise application developer and later as a consultant. I am very excited to work on the C# compiler and I am thrilled about the upcoming language features in Orcas.

When I'm not at work, I can be found with my wife and two children. I love the outdoors (mountain biking, hiking, ...), sports (softball, volleyball, ultimate frisbee, football, ...), reading (recent reads include Modern Compiler Design, Les Miserables, and the new Harry Potter book), programming (current side projects include lex and yacc for .NET, automatic trail guide generators using GPS data, and roborally in .NET), and many other things.

The focus of this blog will be the C# language and other pertinent topics. I found a beautiful quote that motivates a detailed investigation into the C# language:

   The limits of my language mean the limits of my world.
   Ludwig Wittgenstein (1889-1951), Tractatus Logico-Philosophicus (1922)

Although Wittgenstein is speaking of natural languages, it is apparent that this applies to programming languages as well. The language that we employ and our understanding of that language colors and defines the way we think about the solution to various problems we encounter. That being said, it is worth the effort to understand the languages that we use and take full advantage of their power.

Feel free to email me questions, comments, or suggestions for topics and I will discuss them here as I have time.

I received an email a few weeks ago where a friend stated:

ValueTypes don't behave correctly when they are "boxed". If you make
a function equals(object, object) and then pass call equals(1, 1), they
won't be equal. Why not? Because if you treat ValueTypes like objects
without specifically down casting them, they won't behave correctly.
This makes a generic behavior an even bigger pain.

I suppose that my friend had written something like the following:

using

System;

class Program {
private static bool IsEqual(object o1, object o2)
{
return o1 == o2;
}

private static void Main()
{
Console.WriteLine(IsEqual(1, 1));
}
}

The problem is that the IsEqual method checks for reference equality; it would have been more aptly named IsSame. If the implementation looked instead like:

using System;

class Program {
private static bool IsEqual(object o1, object o2)
{

      return o1 == null ? o2 == null : o1.Equals(o2);
   }

   private static void Main()
{
      Console.WriteLine(IsEqual(1, 1));
}
}

Then the desired effect would have occurred. The IsEqual method first tests to see if o1 is null, if it is then it checks to see if o2 is also null otherwise it runs the Equals method to see if o1 is equal to o2. Note that the Equals method can be overridden for any type thus allowing the designer of a type to decide what equality means for the new type.