Behind the Scenes of Roslyn
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.
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.
Uwe Zdun, Rafael Capilla, Huy Tran, Olaf Zimmermann Mar 09, 2014
Olav Maassen, Liz Keogh & Chris Matts Mar 08, 2014