S. Somasegar is the corporate vice president of the Developer Division at Microsoft. Learn more about Somasegar.
In my last few blog posts, I’ve highlighted significant advancements our teams have made as part of the Visual Studio 11 Developer Preview released at //BUILD/, and I’ll continue that series in future posts. Today, however, I want to highlight some innovative work our teams have been doing that is even more forward looking.
I’m excited to announce that we’ve just released the Microsoft “Roslyn” CTP, which enables the C# and Visual Basic compilers to be used as a service. While we’ve been busy working on C# 5 and Visual Basic 11, via Roslyn we’ve been working concurrently on a complete rewrite of the C# and Visual Basic compilers. Whereas today’s compilers are implemented in native C++, in Roslyn we’ve rewritten the compilers from the ground up, implementing the C# compiler in C# and the Visual Basic compiler in Visual Basic. That in and of itself isn’t entirely noteworthy, as it’s long been a tradition for a language compiler to be implemented in its target language, something that’s been true of both our F# and Visual C++ compilers. What’s quite noteworthy are the scenarios and services this work enables.
Historically, the managed compilers we’ve shipped in Visual Studio have been opaque boxes: you provide source files, and they churn those files into output assemblies. Developers haven’t been privy to the intermediate knowledge that the compiler itself generates as part of the compilation process, and yet such rich data is incredibly valuable for building the kinds of higher-level services and tools we’ve come to expect in modern day development environments like Visual Studio.
With these compiler rewrites, the Roslyn compilers become services exposed for general consumption, with all of that internal compiler-discovered knowledge made available for developers and their tools to harness. The stages of the compiler for parsing, for doing semantic analysis, for binding, and for IL emitting are all exposed to developers via rich managed APIs. As an example, in the following screenshot I’m taking advantage of the Roslyn APIs to parse some code and display the tree of syntax nodes.
The Visual Studio language services for C# and Visual Basic have been rewritten to use these new APIs. And new tools have been introduced to take advantage of all of these services. For example, the new C# Interactive window enables scripting and exploration in C#:
Roslyn represents an exciting opportunity for developers to build richer tools, such as refactorings and deep visualizations, utilizing the same support that Visual Studio and its compilers would use for their work. It should be noted, however, that this is an early look at this compilation infrastructure, as the Roslyn work is focused towards a post-Visual Studio 11 release. This CTP will help to illuminate the kinds of exciting end-to-end experiences that are possible with such technology, but at the same time this particular release only supports a subset of each language and is intended for exploration and to enable us to gather feedback from you on the direction.
For more information on Roslyn, to download the CTP, and to let us know what you think, visit http://www.msdn.com/roslyn.