In this series of blog posts we are going to learn about the next version of .NET i.e. .NET Core. I am learning the next version of .NET and in that process I read some articles, tutorials, blog posts and watch related videos. This series of blog posts is basically the gist of what I am learning. At the end of each post, in the References section, I am going to post links to all the material that I consulted for that particular post. If you would like to know something in more detail then you can follow the links in the References section. In this post we are going to cover the basics of .NET Core as a platform.
Motivation Behind The Creation Of .NET Core
One good way of understanding .NET Core is to understand the motivation behind its creation and how the previous versions of .NET Framework worked. Following are some of the motivations behind the creation of .NET Core.
Applications That Can Span Devices
Current .NET Platform isn’t a single entity but a set of platforms (verticals in the above image: runtime + framework + application model) with separate code base, owned by different teams, and maintained independently. There are few major issues with this model -
- From the framework maintenance perspective its hard to maintain. The verticals shown in the above image are basically different implementations or forks of the .NET Platform. These implementations are owned by different teams, version independently, and have different shipping vehicles.
- From the framework consumer perspective, the consumer have to come up with a way to produce assets that work across the verticals that they want to target. This was often achieved by creating multiple projects, linked files and #if.
- To resolve the previous issue Portable Class Libraries were created. Portable class libraries present the developer with the intersection of APIs that can be shared across all the selected targets. This allows producing a single binary that is guaranteed to run on all of the targets. Portable class libraries use contract assemblies, which are used to describe capabilities of a framework, to provide a single API shape to the consumer. However, we still have different implementations or forks of the .NET platform. This makes unifying API shape an ongoing challenge: APIs are only portable when the implementation is moved forward across all the verticals but since the code bases are different that’s fairly expensive.
.NET Core provides a much better approach by unifying the implementation instead of only unifying the API shape as in the case of Portable Class Libraries. All the verticals simply share the same implementation.
Lightweight, Componentized And Cloud Optimized
The current .NET Framework is monolithic and heavy. When you install .NET Framework, you get not only the runtime, but also the entire Base Class Library (BCL) with it. .NET Core is essentially a fork of the NET Framework whose implementation is also optimized around factoring concerns. The entire .NET Core platform including Base Class Library is a set of fine grained NuGet packages. The modular design of .NET Core ensures that each application only needs to deploy what it needs.
Faster Release Cycle
It takes a while to release a new version of the .NET Framework since it is monolithic, it has a huge API shape and It requires rigorous reviews of any changes to maintain compatibility with existing applications. Since .NET Core is delivered as a set of fine grained NuGet packages it can be released in fast and agile fashion.
Application Local Framework
The current .NET Framework (frameworks before .NET Core) is a machine wide framework. Following are some of the issues with a machine wide framework.
- Any changes made to it affect all applications taking a dependency on it.
- If a developer wants to take a dependency on a recently released framework then the developer has to provide an application installer that is able to install the .NET Framework when the application is installed.
- Upgrading the .NET Framework on a particular machine can break other applications on that machine.
Again since .NET Core is delivered as a set of fine grained NuGet packages it turns it into an application local framework. You can deploy the .NET Core runtime with your application which means your application will run with this deployed version of the runtime rather than the version of the runtime that is installed on the host operating system. Your version of the runtime runs side-by-side with versions for other applications. You can update that runtime, if needed, without affecting other applications.
What Is .NET Core ?
.NET Core is a cloud optimized, use what you need, cross platform port of .NET Framework.
- .NET Core is cross platform i.e. same implementation of framework works across various platforms like desktop, web and mobile.
- .NET Core is cross operating system i.e. it works on Windows, Linux and Mac. (This is still a work in progress.)
- .NET Core is modular. It mainly consists of two components, runtime and Base Class Library, and it is delivered as a set of fine grained NuGet packages.
- .NET Core is portable and it can be deployed with your application.
In this post we learned about some of the motivations behind the creation of .NET Core, what is .NET Core and features of .NET Core. In the next post we will learn about the tools used for building .NET Core applications such as DNX, DNVM and DNU.
- Introducing .NET Core This blog post discusses in detail about all the motivations behind the creation of .NET Core and provides an overview of .NET Core.
- Sharing code across platforms This blog post talks briefly about shared projects and Portable Class Libraries.
- Overview of .NET Ecosystem in 2015 This article provides an overview of different components of .NET Ecosystem in 2015.
- Introducing ASP.NET 5 This article introduces ASP.NET 5 and talks briefly about features .NET Core.
- Problems with Portable Class Libraries This article talks in detail about Portable Class Libraries.