Welcome to the 50th issue of Community Convergence. Now that Visual Studio 2010 Beta is out, I think it might be helpful to draw attention to the new dynamic programming and office development features from the C# team that appear in that release. The C# team defines the core syntax found in C# 4.0, and the IDE features that make it easy for developers to access those features. In this post, I’ll focus on language features, in upcoming post, I’ll focus on IDE features.
There are, of course, many new tools and APIs that will appear in Visual Studio 2010. In this post I’m focusing exclusively on core language features from the C# team itself, as opposed to features that come from the WPF, WCF, Silverlight, or other teams.
The text presented here is meant to provide a high level overview of these features. At the end of the article I will point you to more technical resources that will allow you to explore these features in more depth, and to read more precise, rigorous definitions of the new features in C# 4.0.
Dynamic programming and enhanced interaction with Office are the main theme in C# 4.0. Dynamic programming is a means of writing code that does not rely on a static types linked at compile time. Traditionally C# has been a strongly typed language defined in large part by static types that must be declared explicitly at compile time. For instance, string, int, and object are all strongly typed static types that are resolved at compile time. A dynamic type is not linked at compile time, but is instead resolved at run time.
Why should C# developers care about dynamic programming? Isn’t the strongly typed nature of the C# language one of the language’s best features? The answer to this question is a resounding yes. Strong typing is one of the great advantages of the C# language, and the team expects most developers to continue to write strongly typed code nearly all the time. There is nothing in the new C# 4.0 features that prevents you from continuing to exclusively write strongly typed code, if that is what you prefer.
However, there are occasions when it is convenient to write dynamic code. For instance, languages such as Python and Ruby are dynamically typed. It is awkward, and sometimes nearly impossible, to call into these languages from a strongly typed language such as C# 3.5. The Office API is also difficult to call from C# 3.5; it has long been awkward for C# developers to call into Office using the current set of language features.
C# 4.0 is adding dynamic features so that it will be easier for developers to call into dynamic languages such as Python, and into more flexible APIs such as Office. You can think of the entire dynamic programming effort as a move by the C# team to fill in existing holes in the language. C# has always provided a great way to write strongly typed code, now we’re adding support for dynamic code, and for calling into Office applications.
The team has broken out the new features in C# 4.0 into four categories, all but the last of which are directly related to dynamic programming or Office development:
IEnumerable<string> strings = new List<string>(); IEnumerable<object> objects = strings;
That’s the end of our quick overview of the new features in the C# 4.0 language. Again, remember that there are many other new features of in Visual Studio, and many new enhancements to existing technologies such as WPF, WCF, Silverlight and LINQ. In this post, I’ve focused exclusively on changes to the basic syntax of the language that have been implemented by the C# team itself.
Here are few references for people who want to explore this subject in more depth. A guide for developers interested in all things related to C# 4.0 is the C# Futures site on Code Gallery. There you will find a downloads page that contains the following key resources:
Other important resources include C# 4.0 sections Eric Lippert’s and Sam Ng’s blogs: