C# Team talks about the future with Future Focus
The C# team members of Charlie Calvert and Mads Torgersen announced they are creating Future Focus, a series of monthly blog posts detailing plans for future versions of C#.
What is Future Focus?
According to Charlie Calvert, Future Focus is:
It is important that readers of this column have the right expectations. The information in this column is meant to be a helpful guideline for C# developers, and not a binding commitment. We are not attempting to give a complete list of features in the product, but only to share what we can in a way that will be easily accessible to all C# developers. The Visual Studio schedule, unforeseen technical problems, intellectual property rights and competitive pressures may impact our schedule or our ability to share our plans. We will, however, do our best to keep you up to date on the latest news from the team as they design and implement future versions of the C# language.
Future Focus is not intended to give a detailed specification of future features but instead, give an overview in broad strokes of those features in comprehendible terms.
Future Focus I
The first installment of the C# information update talks about Dynamic Lookup. The next version of Visual Studio will include this feature which will enable all .NET languages to optionally resolve names in a program at runtime instead of at compile time. Charlie tells us that:
Work on support for dynamic lookup was begun in the CLR, but soon became part of the Dynamic Language Runtime, or DLR. The DLR provides the infrastructure on which a common set of dynamic tools can be built. For instance, the DLR provides the infrastructure for both IronRuby and IronPython. It will be the infrastructure on which the C# team implements dynamic lookup .
Support for dynamic lookup is already available in Visual Basic for .NET, where it is often known as “late binding”. The new release of .NET will provide C# developers with similar functionality, while at the same time providing a shared infrastructure for runtime name resolution across all .NET languages, including VB.
The article details common scenarios when Dynamic Lookup is useful:
Office Automation - In the next version of Visual Studio Office automation will be easier. Developers will be freed both from the need for using a bulky type library, and the need for including optional arguments in their method calls. The support for Office Automation will be part of a general effort to enhance support for COM Interop and Office PIA.
Consuming Dynamic Languages - Dynamic languages such as IronPython or IronRuby are becoming increasingly popular. At this time, those languages can call C# code, but we can’t easily call into their code. The next version of Visual Studio will simplify the steps C# developers take to call into IronPython or IronRuby classes. This will give developers access to a useful existing code base, and an alternative way to write new code.
Call Reflection - C# developers can currently use reflection to instantiate classes and call arbitrary methods that are not known at compile time. The dynamic extensions to the C# language will make it much easier to make such calls.
The development of the Dynamic Language Runtime (DLR) makes this particularly important the growing popularity of dynamic languages and the need to be able to communicate between dynamic and non-dynamic languages. Products such as Silverlight 2.0, set to be released at some point in the future, will rely heavily on the dynamic nature of the languages it hosts.
Charlie gives us a glimpse at what a dynamic lookup might look like:
The syntax that will be used for dynamic lookup has not yet been finalized. The code that I show here is therefore only a tentative sketch that reflect the team’s evolving plans.
The team is currently considering adding the keyword dynamic to the language and using it to demarcate a block of code:static void Main(string args)
object myDynamicObject = GetDynamicObject();
myDynamicObject.SomeMethod(); // call a method
myDynamicObject.someString = "value"; // Set a field
myDynamicObject = 25; // Access an indexer
All the code that occurs in a dynamic block will potentially support dynamic lookup; even if the accessed members are not known by the C# compiler to exist, it will allow the code. At runtime the DLR will look at the actual object referenced by myDynamciObject for members with those names. It will access them if they do indeed exist, otherwise an exception is thrown. Outside of a dynamic block developers can only call C# code statically, just as they do today.
Watch for future postings of Future Focus on Charlie's Blog and learn more about the future of C#.
Oracle Coherence: Data Grid for Java and .NET
Tiago Romero Garcia Mar 01, 2015
How Can We Use Our Creative Power and Technological Opportunity to Address the Challenges of the 21st Century?
Gyorgyi Galik Feb 26, 2015