Paul Gielens:ThoughtsService

another Endpoint to my thoughts

News

Syndication

Ads


Favorites

Projects

The Future of C# (4.0)

fcsharp

C# 1.0 Managed code

C# 2.0 Generics

C# 3.0 Language integrated query

C# 4.0 Dynamic programming

C# vNext Compiler as a service

Trends

  • Declarative
  • Dynamic
  • Concurrent
  • Dynamic
  • Concurrent

New paradigm is multi paradigm. C# is very object oriented, but since C# 3.0 it is also a functional programming. These trends are influencing the future of C# coming in C# 4.0

Dynamic language runtime build up out of expression trees, dynamic dispatch, call site caching. The DLR will have binders for different technologies.

Dynamic typed Objects

  • Statically typed to be dynamic
  • Dynamic conversion
  • Dynamic method invocation

example:
dynamic calc = GetCalculator();
int sum = calc.Add(10, 20);

*Anders Hejlsberg shows a pretty impressive demo in which he copies a JavaScript fragment into a .cs file and runs it by changing explicit typed variables with the new dynamic keyword.

How does this work? IDynamicTypedObject is the new interface to implement. Implementing the object GetMember(..) and void SetMember(..) of these interface definition is enough to create dynamic objects.

*You can think of this as native support for DuckTyping. Perhaps this will even bring Arjen over to the bright side.

Optional and named parameters

*A restriction is that a named parameter must come last.

Improved COM interoperability

  • Automatic object -> dynamic mapping
  • Optional and named parameters
  • Indexed property
  • Optional "ref" modifier
  • Interop type embedding ("No PIA") no primary interop assembly

Co- and contra-variance

objects[0] = "Hello";            // OK
objects[1] = new Button(); // Exception!

  • .NET arrays are co-variant, but not safely co-variant
  • Until now generics have been invariant

C# 4.0 now supports safe co-and contra invariance.

IEnumerable<out T>

out = Covariant output positions only.

IComparer<in T>

in = Contra-variant input positions only.

Variance in C# 4.0

  • Supported for interfaces and delegate types
  • "Statically checked definition-site variance"
  • Value types are always invariant
  • Ref and out parameters need invariant type

*Some of the interfaces in the .NET Framework are using this new feature.

Beyond C# 4.0

  • Meda-data programming
  • Support for domain specific languages

*We need a compiler that isn't just a black box.

Example:
CSharpEvaluator ev = new CSharpEvaluator ();
ev.Add("System");
ev.Eval("int Sqr(int x) { return x * x; }");

*Anders Hejlsberg shows a couple of very, very impressive demo's. Incredible!

See http://code.msdn.microsoft.com/csharpfuture for more information.

Posted: Oct 27 2008, 05:57 PM by p.gielens | with 7 comment(s)
Filed under: ,

Comments

TechnetGuy said:

very nice blog. I had one similar blog at http://www.technetguy.com/blog :)

# October 28, 2008 12:32 AM

Darius Damalakas said:

At the momment i am very interested in both duck typing and CSharpEvaluator and what will be the feature difference comparing to Boo

# October 28, 2008 2:37 AM

Techie.notepad said:

The Future of C# 4.0 and then 5.0

# October 28, 2008 8:11 AM

rascunho » Blog Archive » links for 2008-10-28 said:

Pingback from  rascunho  &raquo; Blog Archive   &raquo; links for 2008-10-28

# October 28, 2008 4:07 PM

Abu Ismail, Microsoft MVP Since 2005 in Visual Developer ASP.NET, loves .NET said:

&quot;What&#39;s Next?&quot; - Everybody is interested to about new upcoming this. When I purchase new

# December 1, 2008 1:34 AM

Abu Ismail, Microsoft MVP Since 2005 in Visual Developer ASP.NET, loves .NET said:

&quot;What&#39;s Next?&quot; - Everybody is interested to know about new and upcoming things. While I

# December 1, 2008 6:34 AM

Abu's blog said:

&quot;What&#39;s Next?&quot; - Everybody is interested to know about new and upcoming things. While I

# December 26, 2008 1:29 AM
Leave a Comment

(required) 

(required) 

(optional)

(required)