This is probably one of the must attend sessions at this PDC with Anders Hejlsberg himself, and as always he has a very relaxing and laybacked presentation style that works very well.
Anders started with summerizing three trends in programming languages: Declarative, Dynamic and Concurrent. He also shortly mentions that languages are not just OO anymore, or just dynamic, but rather heavilly influensed by each other. For example C# is in many ways both OO and Functional today. (Magnus talked about it in his blog post here.)
Declarativ is really about what you want to do, instead of todays focus on how to do things. With more what-focus there will be new possibilities for the platform to make optimizations, that is not generally possible today, even if LINQ is one example where it is more possible (for example making it parallel).
Dynamic is about getting features from the dynamic languages, like duck typing and other.
Concurrent is about the fact that processors does not get any faster, but rather getting more cores. To make use of more cores we need to split the work in parallel tasks and how can languages make that easier.
C# history: Version 1 was all about managed code, version 2 completed version 1 and added generics, version 3 added LINQ and version 4 will be about dynamic languages.
C# 4 will uses the Dynamic Language Runtime (DLR) that is developed for IronPython and IronRuby. The problem they want to solve is that today all "late binding" code differ a lot, for example .NET Reflection and calls to javascript from Silverlight looks very different, and most important of all it looks very different from the regular C# code that you write. The DLR has differnet "binders" that makes it possible to expose the same syntax in the language, but that is bound to different techonlogy as .NET objects, javascript, python, COM and so on. This will probably be a little bit clearer with a sample.
dynamic calc = GetCalculator();
int sum = calc.Add(10, 20);
The dynamic keyword is used to declare a variable that is statically typed to be dynamic. On the next line there is a dynamically method invocation to the Add method and the result is dynamically converted to an integer. What really happens here is that the resolution is defered until run-time, instead of happening at compile time. This is features that are very useful for example when developing Silverlight applications and in COM-interop scenarios. An interesting effect of this is also that it will be very easy to move javascript code to C# and to mix code with dynamic languages as Python.
Other new features in version 4.0:
- Optional and named parameters. This have been available in Visual Basic since first version of Visual Basic .NET.
- Improved COM interoperability because:
- Automatic object -> dynamic mapping
- Optional and named parameters
- Indexed properties
- Optional "ref" modifier
- Interop type embedding (= no Primary Interop Assemblies (PIA))
- CO- and Contra-variance which very shortly can be described as making it possible to do things that you thought should have been able to do today. For example sending a List<string> to a method that takes IEnumerable<object> as a parameter (not possible in C# 3.0)
Moving beyond version 4, one of the things that they are working on is to re-write the compiler in C#. This is to make it possible to have the compiler as a Service. This enables Meta-programming (Ruby-on-rails), Language Object Model and DSL Embedding.