Yesterday, Microsoft has released the C# compiler to the public under the Apache open source licence. The compiler, code named Roslyn can be downloaded from Git. The instructions can be found here http://msdn.microsoft.com/en-us/vstudio/roslyn.aspx.

I’ve reviewed some of the features planned for implementation in the language and have made a few pick I’d like to mention in this post.

Primarily, I was impressed with the plan to implement Null propagation. Null propagation would work something like this, following an example from the Language feature status page:

Say that you want to access customer object’s member array called Orders, and within it select the sixth element’s price object’s member.

Normally, you’d have to check if the customer object is not null and then if Orders array has six or more elements in order to access the sixth one. Then, if the sixth element exists and is not null and is an instance of a class that has a price member, you would then access the price member element. All this requires a lot of code, unless you wish to enclose every piece of code with try-catch.

However, with null propagation, you can say it like this:

customer?.Orders?[5]?.$price

This is a nice concept.

Another one I’ve liked is String interpolation which would enable developers to use something similar to what PHP has. I’ll just post the same example from the source page and everything should be very clear:

"\{p.First} \{p.Last} is \{p.Age} years old."

And finally, for those of us who work with binary data a lot in our programs, having a simpler way to write byte arrays would be warmly welcomed. This would be accomplished with the planned Digit separators. An example follows:

0xEF_FF_00_A0

This features seems to have been implemented in VB, but I’d like to see it in C# just as well.

Well, once again, I have to admit that I’m surprised that Microsoft is actually capable of planning and/or creating something useful for a change. I hope these concepts will be implemented in other languages as well, such as Java and PHP.