I have been looking at .NET Core, an official Microsoft open source project which you can find on github and which is at the heart of Microsoft’s plans to open source most of its .NET technology.
Currently there are three Microsoft repositories for the .NET Core platform. There are the .NET Compiler Platform (“Roslyn”), ASP.NET 5, and the .NET Core Framework. Note that these are all v.Next versions of the .NET Framework. ASP.NET 5 and the .NET Core Framework are on github, but Roslyn is on CodePlex, Microsoft’s open source repository site. There is also a github repository for Entity Framework 7, currently part of ASP.NET though I am not sure that it belongs there. The current version of EF is 6.11 but the code for this is on CodePlex. The KRuntime, which is the implementation of the parts of the .NET Runtime needed to host an ASP.NET application, is also in the ASP.NET repository. Its full name is the K Runtime Environment (KRE); I am not sure what K stands for. Note that Microsoft has only promised to open source the .NET server stack, not desktop frameworks like Windows Presentation Foundation.
I had a look at the .NET Core Framework. This is the key set of libraries for .NET applications. The easiest way to build the core libraries is from the command line. Open a Visual Studio 2013 Developer Command Prompt (which sets up the path and environment for command line builds), go to your clone of the github repository and type build.
Cool. But what is in it? Not that much: System.Collections, Parallel Linq, Vectors and XML libraries.
“More is coming soon. Stay tuned!” say the docs. And in this blog post by Microsoft’s Immo Landwerth:
Consider the subset we have today a down-payment on what is to come. Our goal is to open source the entire .NET Core library stack by Build 2015.
Landwerth says that Microsoft is “currently figuring out the plan for open sourcing the runtime”; this is the native code that creates the .NET Virtual Machine which executes .NET code.
Of course there is also Mono, the old open source implementation of .NET which is from an independent code base.
This is exciting stuff for .NET developers, especially since official runtimes for Linux and Mac are also promised, but also somewhat confusing. What is .NET Core versus what we have known as the .NET Framework?
Here is a diagram from Landwerth’s blog:
I presume that the top left box (.NET Framework) has not been promised as open source, but the other two boxes have. Note that ASP.NET 5 will run on either .NET Core or the full .NET Framework; and that .NET Native – the project to compile a .NET application as true native code – sits as part of .NET Core.
Store apps (also known as Windows Runtime apps, or Metro apps) are not covered in the above diagram, but since .NET Native currently only works for Store apps, maybe .NET Core is also the .NET runtime for Store apps. Landwerth says:
.NET Core is a modular development stack that is the foundation of all future .NET platforms. It’s already used by ASP.NET 5 and .NET Native.
There are also some clues about .NET Core in the home page for the github repository:
.NET Core and the .NET Framework have (for the most part) a subset-superset relationship. .NET Core is named "Core" since it contains the core features from the .NET Framework, for both the runtime and framework libraries. For example, .NET Core and the .NET Framework share the GC, the JIT and types such as
String
andList<T>
. We’ll continue improving these components for both .NET Core and .NET Framework..NET Core was created so that .NET could be open source, cross platform and be used in more resource-constrained environments. We have also published a subset of the .NET Reference Source under the MIT license, so that you and the community can port additional .NET Framework features to .NET Core.
The second paragraph is intriguing. Microsoft has posted parts of the source for the .NET Framework library so that the community can port some of it to .NET Core. What this means I think is not that this code should be part of .NET Core (otherwise it becomes more than just core) but rather that it would run on .NET Core.
It seems, contrary to what you might have thought, that the full .NET Framework is not a superset of .NET Core, although it is intended to be close to that. This has interesting implications for future compatibility. If .NET Core is intended to be more agile and to evolve more rapidly than the .NET Framework, since it is somewhat free of backwards compatibility constraints, we will soon find that there are features in .NET Core that do not exist in the .NET Framework as well as vice versa, in other words, two incompatible stacks. That could be a problem.
Despite Microsoft’s impressive openness in publishing much of its .NET work and forming the .NET Foundation, I for one would appreciate a clearer presentation of the plans for .NET Core and .NET Framework and the extent to which .NET Framework should now be considered a legacy or Windows desktop only technology. I suspect the answer for the moment is “wait for Build.”
There’s also the question of ‘why’: if .NET Core is meant for resource constraint environments, we’re not talking about server side, while at the moment, .NET Core is seen only as a basis for server side applications. Not really ‘resource constrained’, especially if you consider Java and its JVM don’t have this problem: people can just target the JVM and that’s it, it will run.
A big problem arises for library providers if they currently target ASP.NET and are now faced with ‘shall we port to CoreCLR as well?’, as ASP.NET vNext runs on CoreCLR so not porting to CoreCLR will alienate the some of their users. However porting a large(r) codebase to CoreCLR to make it work with ASP.NET vNext isn’t simple: the framework is limited, and what’s available is likely not behaving as expected in all cases, which means every call has to be evaluated: there’s no backwards compatibility.
EF6 won’t run on CoreCLR for several reasons, one of them being the generation of dyn. proxies at runtime (something which NHibernate and linq to sql also use), likely due to the lack of appdomains on the CoreCLR and other elements. This is a big split in the road and can force teams to make harsh decisions and spent time on porting code to CoreCLR for reasons which are unknown: why is ASP.NET CoreCLR even there, when MS works with Mono to make it better? ASP.NET is a framework on top of full .NET, so why bother with using a different CLR, causing all kinds of problems?
I for one are now faced to port 500K LoC to CoreCLR to be able to have my customers use my ORM in ASP.NET vNext on CoreCLR while it already runs on Mono today, on linux. As resources are tight (I’m a single man team) I can’t afford to spent a lot of time porting code which works properly on other runtimes to a new runtime just because Fowler cs. think they have to start over from scratch. It’s not the first time the ASP.NET team comes with something that will change the world but is abandoned sometime after that.