
C# 6 and .NET Core 1.0

.NET Framework, .NET Core, and .NET Native are related platforms for developers to build applications and services upon.
Microsoft's .NET Framework is a development platform that includes a Common Language Runtime (CLR) that manages the execution of code and a rich library of classes for building applications.
Microsoft designed the .NET Framework to have the possibility of being cross-platform, but Microsoft put their implementation effort into making it work best with Windows.
Practically speaking, the .NET Framework is Windows-only.
The open source community developed a cross-platform .NET implementation named the Mono project (http://www.mono-project.com/).
Mono is cross-platform, but it fell well behind Microsoft's implementation of .NET Framework. It has found a niche as the foundation of the Xamarin mobile platform.
Today, we live in a truly cross-platform world. Modern mobile and cloud development have made Windows a much less important operating system. So, Microsoft has been working on an effort to decouple the .NET Framework from its close ties with Windows.
While rewriting .NET to be truly cross-platform, Microsoft has taken the opportunity to refactor .NET, to remove major parts that are no longer considered "core".
This new product is branded as the .NET Core 1.0, which includes a cross-platform implementation of the CLR, known as CoreCLR , and a streamlined library of classes known as CoreFX.
.NET Core 1.0 is much smaller than the current version of the .NET Framework because a lot has been removed.
For example, Windows Forms and Windows Presentation Foundation (WPF) can be used to build graphical user interface (GUI) applications, but they are tightly-bound to Windows, so they have been removed from the .NET Core. The latest technology for building Windows apps is the Universal Windows Platform (UWP). You will learn about it in Chapter 13, Building Universal Windows Platform Apps Using XAML.
ASP.NET Web Forms and Windows Communication Foundation (WCF) are old web applications and service technologies that fewer developers choose to use today, so they have also been removed from the .NET Core. Instead, developers prefer to use ASP.NET MVC and ASP.NET Web API. These two technologies have been refactored and combined into a new product that runs on the .NET Core, named ASP.NET Core 1.0. You will learn about it in Chapter 14, Building Web Applications and Services Using ASP.NET Core.
The Entity Framework (EF) 6.x is an object-relational mapping technology for working with data stored in relational databases, such as Oracle and Microsoft SQL Server. It has gained baggage over the years, so the cross-platform version has been slimmed down and named Entity Framework Core 1.0. You will learn about it in Chapter 8, Working with Relational Data Using the Entity Framework.
Some data types in .NET that are included with both the .NET Framework and the .NET Core have been simplified by removing some members. For example, in the .NET Framework, the File
class has both a Close
and Dispose
method, and either can be used to release the file resources. In .NET Core, there is only the Dispose
method. This reduces the memory footprint of the assembly and simplifies the API.
The .NET Framework 4.6 is about 200 MB. The .NET Core 1.0 is about 11 MB. Eventually, the .NET Core may grow to a similar larger size. Microsoft's goal is not to make the .NET Core smaller than the .NET Framework. The goal is to componentize .NET Core to support modern technologies and to have fewer dependencies so that deployment requires only those components that your application really needs.
The .NET Core is the future of .NET, but in my opinion, we are not there yet. .NET Core 1.0 is a great start, but it will take another version or two to become as mature as the current version of the .NET Framework.
This book will focus features available in .NET Core, but will use the .NET Framework when features have not (yet) been implemented in the .NET Core.
One of the reasons we picked this cover image for this book is that you can think of .NET Core as a new dawn for .NET. The .NET Framework has become overgrown, like a dense forest, and the .NET Core is like finding a clearing or glade within it. It's a fresh start.
Another .NET initiative is .NET Native which compiles C# code to native CPU instructions ahead-of-time (AoT) rather than using the CLR to compile IL just-in-time (JIT) to native code later.
The .NET Native compiler improves execution speed and reduces the memory footprint for applications. It supports the following:
The following table summarizes and compares Microsoft's three .NET technologies:
Platform |
Feature set |
C# compiles to |
Host OSes |
---|---|---|---|
.NET Framework |
Mature and extensive |
Intermediate Language (IL) code |
Windows only |
.NET Core |
Brand-new and somewhat limited |
Windows, Linux, Mac OS X, Docker | |
.NET Native |
Brand-new and very limited |
Native code |
Change the font size
Change margin width
Change background colour