BT
x Your opinion matters! Please fill in the InfoQ Survey about your reading habits!

Behind the Scenes of Roslyn

by Jeff Martin on Dec 07, 2011 |

 

Microsoft's Channel 9 has released an interview with the principal developers of the Roslyn project. Karen Ng, Matt Warren, Peter Golde, Anders Hejlsberg provides some useful information on the project's goals and what the team is trying to accomplish.

The team has found that developers who want to build their own re-factoring tools have been limited in their ability to easily do so as it required them to build and maintain their own C# compiler. As Hejlsberg stated, “...I think a whole number of people want to build their own refactorings, or would want to build their own refactorings if it wasn't so hard...” The Roslyn project aims to lower the barrier to entry by opening up the compiler and the compilation process to C# and Visual Basic developers.

Performance

As the Roslyn project is written in managed code (C# or Visual Basic), the team was asked if this creates a performance hit. Hejlsberg and Ng responded that development in ASP.NET can see performance benefits from running Roslyn on the server since assemblies can be retained in memory. Golde indicated that in their experimentation, solutions that have several (10-30) smaller projects can see performance benefits when compiling as Roslyn keeps more data in memory. Warren followed that by saying that its too early for an overall performance comparison as the non-Roslyn C# compiler is quite fast but that testing and development work continues.

Hejlsberg noted that the current current C# compiler primarily uses 1 core, whereas the Roslyn compiler series is parallelized. The ability to introduce multi-core compatible code comes from the implementation of a more functional design in its internal architecture. Hejlsberg commented that “actually a lot of learnings from functional programming [were used] in how we implemented the compiler this time around”. As another example, Roslyn takes advantage of C# method bodies that are completely independent of each other which allows them to be compiled in parallel.

Uses Beyond Refactoring

Ng noted that many developers have a need for parsers that support the C#/VB languages. Another need is for applications that want to be able to understand C# as an embedded scripting language. Hejlsberg thought another important area is meta programming; once the compiler becomes a service there are more opportunities for user interaction.

Meta-programming is defined by Hejlsberg as “programs generating programs”. Upon being asked about template programming, Hejlsberg replied that he feels C++ template programming really involves two languages: C++ and then template-specific C++. By comparison, dynamic programming languages such as Ruby use the same object and meta languages. According to Hejlsberg Roslyn works the same way as C# can be used to extend C# without learning a new language or specialized dialect of a language.

C# / VB Compiler Revelations

The Roslyn project has also contributed to the amount of “dogfooding”, or the practice of a company using its own products internally. Golde observes that “...even more interesting than writing the C# compiler in C# has been writing the VB compiler in VB... to be honest internally we haven't had a whole lot of VB development... this is the largest piece of 'shipping code' that we've written in VB”. Warren added “...previously both compilers [C# and VB] were written in C, so all the compiler developers were C experts” but not necessarily experts in the language they were writing the compiler for. The self-hosted nature of the Roslyn compilers is then leading to situations where Microsoft developers can become more familiar with the “the beast that you are building” as Hejlsberg described it.

 

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread
Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Discuss

Educational Content

General Feedback
Bugs
Advertising
Editorial
InfoQ.com and all content copyright © 2006-2014 C4Media Inc. InfoQ.com hosted at Contegix, the best ISP we've ever worked with.
Privacy policy
BT