The Future of C# 4.0 and then 5.0

No PDC would be true to form if it didn’t leave you really really baffled and breathtaken. Anders talks tend to do that to you. This year certainly was not exception to that rule. Neither Anders talk nor PDC for breathtakenness (is that even a word?)! I just saw Anders demo cool stuff from the upcoming C# 4.0 and C# 5.0! Even though I’d already seen some of the stuff from Anders earlier talk on the languages I was still blown away! All of what I wrote in that post still applies and here are a few added points:

The über trend of all trends in programming languages today is the break down of language barriers like static/dynamic or declarative/imperative. We will se language makers infuse languages with elements of both. In C# this means that even though it is a statically typed OO language it has already and will continue to gain elements of both functional languages and dynamic languages.

Languages will move to more declarative approaches. Evidence of this is LINQ in C# but this move will continue.

VB and C# is promised to continue it’s co-evolution without the promise that it will be an exactly equal feature set in both languages. C# will not, for instance, get xml literals.

Behind the guise of the dynamic codeword is some really cool magic. dynamic in C# is a new static type! ;~) Presenters here at PDC couldn’t say that enough and couldn’t stop giggling when they did! If you call out to COM for instance (say you are doing office development) and get an object type in return. Today you have to cast it to something useful that you already know it is. Well now all of those APIs will return the static type dynamic which will infer a dynamic conversion to the type you declare. This means you don’t have to cast – it’s inferred from context in the run time! What’s cool abut this is that you can assign anything to a dynamic declaration, say an anonymous type! dynamic is a way to talk to anything that isn’t a .NET type in a type safe (though run time deferred) and efficient way. The declaration is compile time dynamic but run time static. Also method resolution is deferred to run time since you can use dynamic as parameters to methods and the run time will select the correct overload to call in the run time.

The Dynamic Language Runtime, the DLR, is to be viewed as an extension of the CLR enabling static languages and dynamic to coexist and communicate. Here I am sliding over to the talk by Jim Hugunin – Deep Dive: Dynamic Languages in Microsoft .NET. That’s OK though because the two talks were related and Anders actually stole a whole lot of Jim’s thunder during his presentation. Jim is the man behind the Iron Python project. This is done by means of expression trees, dynamic dispatch and call site caching. The DLR team have been able to isolate the features common to most languages and been able to create a way to make binders from any language to any other language over the DLR. Sort of. There are binders to .NET, Ruby, what ever. and if you want to create your own binder, either that you feel you can make a better one or you want to bind to a new language, you can. And it’s not hard to do. There was a very cool new interface called IDynamicObject that when implemented realizes all of this. It is hard to for me to describe this since I’ve only seen it once myself. But I urge you to go look at these two sessions from PDC if you are interested in more (Anders future of C# and Jims Dynamic Languages in .NET)!

In C# 4.0 we also get optional and named parameters built in. This will make it more easy and a lot more powerful to for instance create instances of objects without having a bunch of constructor overloads that only vary the parameters. Now parameters can be optional by supplying a default value. You may also call any parameter by the way of a colon “:” notation – named arguments. Non optional parameters have to be part of you call but you can order your parameters any way you like.

And there will be support for contra and co-variance. This was impossible earlier:

IEnumerable<string> strings;

DoSomethingWitObjects(strings); // This would fail!

public void DoSomethingWitObjects(IEnumerable<object> objects) { […] }

Now instead you will mark the declaration in your method with out… or was it in… I forgot. The one was covariant (out) the other was contravariant (in). They are the opposite and solve different previous problems. Hmmm… I’ll post again on that later. (There is one attempt at an explanation here: The Future of C# (4.0). A bunch of the classic interfaces have been modified with these new flags: Like IEnumerable<out T> and IComparer<in T>.

The site for the news is here: C# Future and the document with all the new features is here: New Features in C# 4.0. <- THIS is the perfect resource for all of this!

And into the future of the future…

In C# 5.0 we will see the opening up of the compiler with an API allowing you to call in to create pieces of code at run-time! This is something of the coolest and most powerful C# has gotten added with that I know of. It will take some time still before we see this addition but it will be here soon. I can’t wait! Anders showed you can make strings into runable code – a really powerful scripting engine that is – in the run time and execute them at will. This dynamic code will appear as needed and disappear when used to end. This is so awesome!

Cheers,

M.

Technorati Tags: ,,

posted @ Tuesday, October 28, 2008 1:07 PM

Print

Comments on this entry:

# 

Left by blog.pellesoft.se at 10/28/2008 4:55 PM
Gravatar
Sammanfattning Dag 2

# 

Left by blog.pellesoft.se at 10/28/2008 5:03 PM
Gravatar
Sammanfattning Dag 2

# 

Left by blog.pellesoft.se at 10/28/2008 9:50 PM
Gravatar
Sammanfattning Dag 2

# re: The Future of C# 4.0 and then 5.0

Left by web development at 10/14/2009 10:07 AM
Gravatar
Nice post,

thanks for the info and idea of languages, was really helpful, keep up the good work

Thanks

# re: The Future of C# 4.0 and then 5.0

Left by M at 10/14/2009 10:30 AM
Gravatar
Thank you so much for the nice feedback!

# re: The Future of C# 4.0 and then 5.0

Left by office cleaning at 10/28/2010 10:20 AM
Gravatar
VB and C# is promised to continue it’s co-evolution without the promise that it will be an exactly equal feature set in both languages. C# will not, for instance, get xml literal..

# re: The Future of C# 4.0 and then 5.0

Left by Freelance at 10/29/2010 10:05 AM
Gravatar
The speed of progress shown that soon we will be on 6.0.

# trading strategies

Left by trading strategies at 7/15/2011 11:06 AM
Gravatar
Great blog, I’m going to subscribe to your feed.

#  trading strategies

Left by trading strategies at 7/15/2011 11:16 AM
Gravatar
This is my first time i visit here. I found so many entertaining stuff in your blog, especially its discussion. From the tons of comments on your articles, I guess I am not the only one having all the enjoyment here! Keep up the excellent work.

# thanks

Left by Baltimore SEO at 7/19/2011 8:54 AM
Gravatar
t is hard to for me to describe this since I’ve only seen it once myself. But I urge you to go look at these two sessions from PDC if you are interested in more (Anders future of C# and Jims Dynamic Languages in .NET)!

# re: The Future of C# 4.0 and then 5.0

Left by seragam at 7/21/2011 5:48 PM
Gravatar
I am really thankful towards the author in this post in making this lovely and informative article live for us. We really appreciate ur effort. Maintain the excellent work.

# thanks

Left by healthcare it at 8/29/2011 12:24 PM
Gravatar
it will be an exactly equal feature set in both languages. C# will not, for instance, get xml literal..

# re: The Future of C# 4.0 and then 5.0

Left by Android developer at 10/17/2011 8:46 AM
Gravatar
Interesting story and i realize your enjoyment and i am also enjoy with you . Its a good entertainment blog , so thanks for providing this good timing.

# Android app developers

Left by Android app developer at 11/14/2011 11:33 AM
Gravatar
I charge we appreciate you your time and efforts you acquire in publishing this blog. I'm hoping the aforementioned best article by you after on also. Actually your creative thinking ability has encouraged me to start out my own blog.

Your comment:



 (will not be displayed)


 
 
 
Please add 1 and 4 and type the answer here:
 

Live Comment Preview: