Q&A: Microsoft's Lisa Feigenbaum Talks About C#
Microsoft's community program manager for the Visual Studio Managed Languages Team talks about the new capabilities in C# 4 and what we can expect going forward.
Last month in the Visual Studio Magazine .NET Insight newsletter, we featured in-depth coverage of the C# programming language, including a rundown of new capabilities in C# 4. As a follow up to that coverage, we managed to post a series of C#-related questions to Lisa Feigenbaum, community program manager for the Visual Studio Managed Languages team and a member of the Visual Studio team since 2004.
Michael Desmond: When Anders Hejlsberg a couple years back articulated a vision of reshaping C# with dynamic, functional and parallel attributes, it drew some vocal concern among readers of Redmond Developer News at the time. How has the transition with C# 4 come off? What are the aspects of the new, hybridized capabilities that have been most welcomed? What areas might yet need work?
Lisa Feigenbaum: As you mention, three major trends that we see impacting programming languages are: the rise of dynamic languages, a more declarative style of programming as in functional languages, and the need for better concurrent programming models to support distributed applications and many-core CPUs. We expect next-generation programming languages to feature all of these attributes, and would like to enable C# developers to be successful with these programming models.
One of the most welcomed enhancements in C# 4 has been the vastly improved experience for Office development. The newly introduced C# dynamic support plays a key part in this experience, since it enables you to treat the occurrences of type object in COM signatures as type dynamic (late bound), thereby eliminating the need for casting that was required in C# 3. The new type dynamic allows C# developers to write more elegant and succinct code when working with dynamic objects. Another trend that has been positively received is that of declarative and functional programming in C# 2 and C# 3, with lambda expressions and LINQ queries. These features increase the level of abstraction and expressiveness of the language so you can focus on "what" you want the program to do, rather than "how" the compiler needs to do it.
An area where we hope to further advance the C# language in the future is in concurrent and asynchronous programming. There were some great innovations in this space in the Visual Studio 2010 release, including the Task Parallel Library, Parallel LINQ, new concurrent data structures and tooling. We'd like to build on that work even further, and make it as easy as possible from the language to make synchronous code run asynchronously.
MD: Is Microsoft still heading toward its vision of the "compiler as a service" for future versions of the C# compiler?
LF: Yes, very much so. "Compiler as a service" is a project in which we're re-writing the C# compiler in C#. In the process, we're opening up the compiler and exposing managed API's, so that you can query the compiler for information that was previously hidden behind a "black box." This change will enable several scenarios, including a richer language object model to support third-party extensions, the creation of a Read-Eval-Print-Loop, DSL embedding, and the ability to host C# in other contexts. We started on this project a couple of years ago, and plan to ship it in a future release, yet to be determined. It is a huge undertaking, and will take some time still to complete.
MD: .NET 4 and Visual Studio 2010 codified the "co-evolution" strategy for C# and Visual Basic. There are obvious and critical benefits here -- not the least of which is respecting the core value of .NET as a universal framework -- but what challenges does Microsoft need to manage as VB and C# evolve? Is there, from a language development standpoint, a strategy behind the strategy?
LF: Yes, while there had been attempts in the past to differentiate C# and Visual Basic, we've found that both developers actually want the same features, and therefore we've committed to providing the same major features in both languages. This is quite evident in the Visual Studio 2010 release, where new features were added to both languages together, and parity features were added to fill in existing gaps.
From a language design perspective, our philosophy is to add the same functionality to both languages, but to implement features in a way that feels natural to each language. Both C# and Visual Basic have their own unique styles, and we want to preserve that. Therefore, we won't necessarily implement features in a way that looks exactly the same in both languages.
One challenge we faced when pursuing this strategy in the VS 2010 release was determining the best practices and processes to implement it. On the language side, we have joint language design meetings where we discuss the high level feature plans, and then break up into C# and Visual Basic meetings to iron out the syntax. On the IDE side, we can do even more in common and we generally have one specification and one team to implement the feature for both C# and Visual Basic.
MD: Scott Wiltamuth in his blog said that the language team is not "100 percent there" when it comes to unifying language tooling such as IntelliSense and refactoring features. What are the biggest challenges here and is there a timeline for finishing this work?
LF: Scott's statement actually applies to both the language and the IDE. In both spaces, we've made significant progress towards co-evolution in the Visual Studio 2010 release, but still are not at 100 percent parity. However, it is not actually our goal to reach 100 percent parity. While going forward we want to create new features together, looking back we want to fill major feature holes that the other language would benefit having from a productivity standpoint (not just for the sake of parity). At some point, we believe we'll reach a point of diminishing returns, where the value of adding a parity feature is not as great as the value of the next new feature, and at that point we will declare our co-evolution work complete. We expect to reach that point in the next one to two releases.
MD: What do you feel is the biggest improvement in C# 4 and why?
On the IDE side, I'm really enjoying using "Navigate To" to quickly move around my solution, or IntelliSense PascalCase matching to quickly select the member I'm looking for. However the biggest improvement would have to be the rich extensibility support enabled by the new WPF-based Editor. There are a number of great features that this enabled in the box, such as Editor zoom and Multi-Monitor support, as well as a myriad of Visual Studio extensions now available on VisualStudioGallery.com.
Finally there are many extremely powerful capabilities included in the Visual Studio 2010 release. The IntelliTrace debugger and Task Parallel Library are a couple of my favorites. There is also great tooling support for Microsoft platforms including SharePoint, Azure, and Windows Phone. You can find a complete list of Visual Studio 2010 features here.
MD: Counterpoint: What feature or features are C# users requesting most?
LF: Given the number of C# developers, you can imagine that we receive an enormous number of requests! I'll share a few of the most popular ones: tuples, immutable types, non-nullable types, a null propagating member access operator, an "infoof" operator, XML literals, arithmetic constraints on generics, and extension everything (properties, events, etc.).
While we have hundreds of feature requests, it's interesting to note that we actually wouldn't want to program in a language that had all of the features we want in it -- it would be too complex! Figuring out which subset of features to include is part of the art of language design.
MD: In C# 3.x, IEnumerable<T> didn't get a "ForEach" method. In C# 4.0, it still doesn't have ForEach. It's probably one of the most common extension methods written by developers. Why do we still not have a ForEach<T> (Action<T>) on IEnumerable<T>?
LF: The C# 3 LINQ sequence operators follow functional programming paradigms, avoiding state and mutable data. However, ForEach doesn't return any values, so it would only be used to produce side effects. This conflicts with the functional design principles for sequence operators, and is one of the key reasons why it was not introduced.
Fortunately, if you'd like to proceed with this approach anyway, it is just a one-line extension method that you have to write.
MD: For parallel development, why would I want to use the Task Parallel Library (TPL) instead of just spawning a new thread? What benefits do I get with the TPL?
LF: Tasks are a new type introduced in .NET 4, and provide an extra level of abstraction over threads. The purpose of the Task Parallel Library (TPL) is to make developers more productive by simplifying the process of adding parallelism and concurrency to applications. Parallel code that is based on the TPL automatically scales, without recompilation, to manycore computers.
The TPL uses the .NET ThreadPool, and scales the degree of concurrency dynamically to most efficiently use all the processors that are available. Parallel LINQ (PLINQ) uses tasks and is a great example where TPL simplifies the steps required to parallelize code. Another advantage of using tasks over threads is the rich task management APIs available, including waiting, cancellation, continuations, robust exception handling, detailed status, custom scheduling, and more.
Bio: Lisa Feigenbaum is a Community Program Manager for the Visual Studio Managed Languages team, which includes Visual Basic, Visual C#, Visual F#, IronRuby, and IronPython. She manages the Community program, including gathering customer feedback to drive product planning, as well as generating content such as videos, blogs, Web sites and conference presentations. Lisa has been a member of the Visual Studio team since 2004. Before her current role, she was a Feature Program Manager for the Visual Basic Editor and Debugger. You can find Lisa on twitter at http://twitter.com/lisafeig and read her blog posts at http://blogs.msdn.com/lisa. Before joining Microsoft, Lisa earned an M.Sc. and B.A. in Applied Mathematics from Harvard University.
Michael Desmond is an editor and writer for 1105 Media's Enterprise Computing Group.