RDN Express Blog

Blog archive

Microsoft Opens Up .NET Compilers

At BUILD Microsoft released the Visual Studio 11 Developer Preview but what may be coming next—after Visual Studio 11—promises to take code generation and refactoring to meta-programming levels. Programming legend Anders Hejlsberg, a Microsoft technical fellow and the chief architect of C#, hosted a session on the future of Visual Basic and C# at BUILD and announced an October preview of the .NET compilers as a service (codenamed the Roslyn Project), which opens up the Microsoft C# and VB compilers as public APIs. Hejlsberg first talked about the compilers as a service project at PDC 2008.

On Wednesday, Microsoft released the first CTP of the rewritten C# and Visual Basic compilers. The existing compilers are built in C++. The new compilers are rebuilt in managed code using their respective languages. (Compilers as a service are not on the roadmap for other .NET languages, according to Microsoft.) Miguel de Icaza introduced a Mono C# Compiler as a Service on Windows last April. The Mono project originally introduced the C# compiler as a service in September 2008 but only Mono users ( Linux and OSX) could use it based on Mono-specific extensions that prevented its use on the Microsoft runtime.

The purpose of the Roslyn CTP is to get developers' feedback on the new model and public APIs, according to Microsoft. The Microsoft "Roslyn" October 2011 CTP exposes an API layer that "mirrors a traditional compiler pipeline" and offers a glimpse at planned Workspace, Services and Scripting layers. The compiler services include a Syntax Tree API, Symbol API, binding and flow analysis API and emit API. The Roslyn CTP is an extension to Visual Studio 2010 SP1 that requires Windows 7, Windows Server 2008 R2 and the Visual Studio 2010 SP1 SDK.

Head of the Microsoft Developer Division, "Soma" S. Somasegar explained the post-Visual Studio 11 technology in his blog:

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.

The compilers as a service technology introduces language services and APIs that will have full fidelity with C# 4 and Visual Basic 10, according to Microsoft, but many of the language features did not make it into the October preview. The Interactive window for scripting, similar to F# Interactive, supports C# in the October preview. Visual Basic support is planned for a future release, according to Hejlsberg.

Some of the scenarios envisioned by Microsoft for the Roslyn technology include embedding C# code snippets in Domain Specific Languages, creating Read-Eval-Print-Loops (REPLs) for interactive programming and building third-party dev tools using the new language object models.

Microsoft is working hard on technology beyond C# 5.0 and Visual Basic 11, which are the latest versions supported in Visual Studio 11. Both languages have been updated to support more asynchronous programming (Async previews) and the new Windows Runtime (WinRT) for Metro style apps.

Express your thoughts on the .NET compilers as a service. Is this a good sign for the future of .NET? Drop me a line at krichards@1105media.com.

Posted by Kathleen Richards on 10/25/2011 at 7:41 PM


Reader Comments:

Wed, Nov 16, 2011 Richard Oberholz United States

How about a compiler for the MAC OS’s? If Microsoft can create Office apps for MAC, why not a compiler?

Wed, Nov 2, 2011 JohnX

With Roslyn C# and VB.NET scripting look a lot closer to reality. VBA is a technology, based on VB6 that hasn't been updated for more than a decade (VBA7 is a 64-bit hack job and doesn't count). VBA badly needs replacement and C#/VB.NET scripting looks like a nice fit. It would also be a nice addition to Powershell ;-)

Wed, Oct 26, 2011

sounds like sandcastle all over again. slow service that scrapes all your IP efforts.

Wed, Oct 26, 2011 Kirk Davis Bangkok, Thailand

I think exposing the compiler as a service raises some interesting possibilities, beyond the obvious ones of having apps able to include snippets of source code (or allowing the user to enter source code) and having it evaluated on the fly. That's already possible to do (via the CSharpCodeProvider's CreateCompiler method) anyway. One possible scenario that comes to mind (not sure how feasible this is) would be creating a WCF service that acts as a facade for the compiler service, so that an IDE could be running on another device and pass the code to be compiled to the WCF service, and have the resulting assemblies returned. That would mean somebody could create a Windows 8 "metro" IDE that runs on ARM, and has the actual compilation done remotely. I know that there are remote-build set-ups already, but it seems like it would be easier to set up this way (on second thought, I guess it wouldn't be too hard to wrap a WCF service around csc or vbc now, but handling all the compile-time errors and warnings would be a pain). I wonder if Microsoft could integrate the compiler-as-a-service into TFS, so that a Metro version of an IDE could participate in checking out code, doing a build, running the assemblies locally, etc.... sorry, sort of rambling here. My brain has been looping thru different "metro" stuff lately.

Add Your Comment:

Your Name:(optional)
Your Email:(optional)
Your Location:(optional)
Comment:
Please type the letters/numbers you see above