# Anders On C# 6.0 at BUILD 2013

7/14/2013 3:23:14 AM

## Anders On C# 6.0 at BUILD 2013

Anders Hejlsberg and Charles Torre talked about a future version of C#, version 6.0, at Windows Build 2013.  http://channel9.msdn.com/Events/Build/2013/9-006 (34:30)

Visual Studio 2013 is the minor release version in an annual major/minor release cycle. The version of .NET included in VS  2013 is 4.5.1 which is an in-place upgrade of version 4.5. Major changes are expected for Visual Studio 2014 and .NET 5.0.

C# 6.0 will feature an all new C#-based compiler based on Roslyn, which will be released with VS 2014. Roslyn is currently available as a community technology preview, which opens up new compiler services for third parties. The C# team aims to make Roslyn as close to the performance of the native compiler as possible (within a factor of 2 during development and better on release), and, in some cases, Roslyn already outperforms the native compiler due to a more modern immutable AST architecture that supports parallel compilation. The immutable AST architecture is detailed in a recently filed patent.

Roslyn will enable C# to innovate faster due to a better designed codebase in a more productive language. This is good news, because languages like Scala, F#, D, and arguably C++ are currently innovating at a faster pace than C# and Java.

Anders stated that a number of frequently requested features are already being introduced into the new compiler. One of these features includes succinct syntax for class definitions, such as those found in Scala and F#. This feature may have already been introduced in TypeScript, with which C# has been exchanging design ideas. In TypeScript, properties can be declared directly from the constructor.

class Engine implements IEngine {
constructor(public horsePower: number, public engineType: string) { }
}

TypeScript/Javascript will not be replacing C# and is not a substantial diversion from Anders’s “day job,” which remains C#. A transcribed excerpt of the video interview is included here:

Charles: We noticed that there were a lot of questions about C# and Roslyn. So now Anders has kindly agreed to hangout for a little while longer and we will get to some of your questions. Right off the bat, Max wants to know if there will be another version of C# in Visual Studio 2013.

Anders: We switched to a much faster cadence. So that release will be... And we are targeting for Roslyn the next one after. We are going to start previewing Roslyn as soon as we can, because we are actually now at a point where we can. The Roslyn compilers are done and we are compiling pretty much all the managed code we can find in-house and externally. Literally we code-scraped CodePlex and Github. We keep finding little issues.

We have a very high level of stability at this point and we are working on the language services and its all finally getting there.

Charles: So, Al nice to see you again. As Anders just said, we are not going to ship in 2013, but you will probably see a preview in some point in time before 2015.

Anders: The sooner the better.

Charles: Shaggy wants to know of any new updates of Roslyn. Is there a new CTP soon?

Anders: We talked about CTPS and I think ... The way we are thinking about it right now is that we need to get VS 2013 out. We have done prepwork in VS2013 such that we can just drop the Roslyn compiler VSIX extensions, which you can enable/disable to test them. All of that infrastructure is done... so once we 2013 out, we will be able to start previewing Roslyn.

Charles: Just to be clear, the goal is that Roslyn will be the compiler for C# at some point.

Anders: Yes.. and VB and the new language services in the IDE. It's all written on top of Roslyn. So there's a huge amount of work there. It's taken longer than we thought and I will readily admit that. The thing that you can't ignore is that there are millions and millions and millions of ... and I venture to say ... probably even billions of lines of code of C# out there and we got to compile all of them exactly. We can't just go and say, oh that doesn't work anymore. This is about obtaining the elusive 100% and backwards compatibility. There are things in the old compiler that are clearly wrong. We do the right thing for this but then in this particular case, we do the wrong thing. Now should we keep the bug, because if we fixed the bug then that breaks. Is it a new warning? We are spending a lot of time getting that just right..

Charles: Now one of the questions ... The  old compiler is written in native code C/and C++. So are you noticing an increase in compiler time. So what are the performance characteristics of Roslyn..

Anders: Right from the get go of the Roslyn project, we set some tough goals. At no point during development do we want to be more the 2X of the old compiler. That was just during development and that we wanted to at least reach the same speeds as the native compiler in the final release. The way we get there is different.

One of things about the Roslyn compiler is that it's a much more modern codebase written using more modern functional algorithms and that means a lot of the data structures in the compiler are immutable like the entire ASTs. You can work on the entire API for that and it's like one big immutable data structure.

What immutability gives you is sharing for free. And that means this compiler unlike the older compiler works beautifully on multicore systems. If you have a multicore machine, we can farm out a lot of compilation work on separate cores... Yes, if you have 4 separate compilations, we can completely spin out 4 separate processes. That's a given. But even for a single compilation, we can internally parallelize IL generation for example... Each method is individually independent of each other, so we can get IL.. the emit phase can go 3-4 times faster because of the ability to take advantage of the all the latent parallelism. So in the aggregate if you look at how the new compiler is performing against the old compiler... it's actually in many cases beating the old compiler, particularly for large projects. It scales a lot better and scalability ... You wouldn't believe the size of some of these projects that people build in C#. They're enormous.

Typing responsiveness is vastly better with Roslyn. There are a lot of advantages we get out of this.

Charles: You still work on C#?

Anders: C# is my day job. I'm been pitching in on TypeScript... There was some downtown in the Roslyn project since it took longer than we thought...

Charles: Because you spend a lot of your time on TypeScript, have you learned anything from that work that you could apply back to C#?

Anders: Yeah... that's a good question. I am coming away from it with a new appreciation for the value of the dynamism or dynamic typing being completely effortless. We have support for dynamic typing in C# but sometimes it's not as smooth as how I would like it to be. For example, making it easy to dynamically dot into a JSON document... That's actually not as easy as it should be today.

Those are things that we are actually looking at right now. From a language design, it goes both ways. We actually ... We have been thinking about ways of making C# classes more succinct by looking at some things we can do with F# where you can put parameters in classes and capture them in methods. And then you can get into a very succinct style of writing code and we used some of that early on in a model of classes that we implemented in typescript.. Then the Ecmascript committee went in a different direction and we align with that instead, but that was interesting to apply work that hadn't been seen yet in C# in Typescript. We may revisit that once we get done with Roslyn.. We actually have now in earnest... design meetings for C# 6.0. So there's a bunch of new features there and we looked at all the new features that people have logged over time in C#. It's time to finally fix this issue.. We have a hitlist of features that we should now just do in the Roslyn codebase, because now that we have a codebase that is so much easier to do in. There was a big cost in the old codebase and that cost has gone down dramatically, so we should be able to move a lot faster.

Charles: The world has changed... Developers are writing mobile applications.
There are many ways it impacts.... For example, dynamic data is getting more and more important. The ability to talk to web services and so forth in a completely frictionless manner. In mobile devices and small form factors, battery consumption is important so native code is becoming more important. It costs battery performance to jit an app. So delivering native code to deices is getting more important.

Anders: Third parties out there like Xamarin like ...

Charles: Is the effort on TypeScript slowing down C#?

Anders: Actually, strangely enough, no because getting to completion to the Roslyn compiler has taken longer...