Ed Charbeneau(http://developer.telerik.com/featured/the-net-of-tomorrow/)


Exciting times lie ahead for .NET developers. During Build, Microsoft’s biggest developer event of the year, clear roadmaps were given on the future of .NET and C#. Microsoft is re-positioning .NET to be a platform that can be written anywhere and run anywhere, which is a departure from it’s long history of proprietary technologies.

Frameworks and Libraries
.NET TODAY
.NET TOMORROW
The Language of the Future is C#
ROSLYN
Conclusion

Microsoft is also reinventing itself in other ways too, like its developer tooling and the way it communicates with developers in general. This more open nature of Microsoft has even started to win over even the most skeptical of developers, such as my co-worker Cody Lindley, which you can see in his latest article, “What Has Microsoft Done For You Lately?”.

So what does all this mean for .NET developers? A well thought-out roadmap from Microsoft showing the strategy for the future of .NET. In this post, we’ll take a look at what that roadmap is.

Frameworks and Libraries

The state of .NET today is a little scattered. Restructuring projects always seem to make them worse before they get better, and this is no different. The road ahead has been a bit fuzzy since the introduction of .NET Core and perhaps got a little fuzzier with the recent announcement adding Xamarin to the mix.

While these are exciting times, they are unclear and uncertain for developers.

.NET TODAY

With the current structure of .NET, creating code that spans across different Microsoft platforms means working with portable class libraries (PCL). The PCL has shared functionality, but is very limited when compared to the .NET framework and understanding how the PCL is supported on various platforms is less than straightforward. In addition, working across the complete .NET ecosystem means working with up to three different base libraries: Base Class Library (.NET Framework), .NET Core, and Mono Class Library (Xamarin). Developer fatigue really begins to set in when trying to grasp which APIs are available for a given scenario.

.NET TOMORROW

Thankfully Microsoft understands the issue at hand and has a clear vision of how .NET things will work in the .NET of tomorrow. A big part of this strategy is to deprecate the PCL and replace it with a contract for common API support. This new contract will be called the .NET Standard Library. The .NET Standard Library will also include a specific set of reference assemblies that all .NET Platforms must support, known as the .NET Platform Standard.

The .NET Standard Library decouples the application models from the base libraries and tooling. This decoupled scenario allows for better code reuse and a shorter learning curve. Having a decoupled approach also means that the .NET Standard Library can be updated with less friction (aka breaking changes), this will mean more innovation at a faster pace. As the .NET Standard Library API surface increases with newer versions, some platforms will be left behind and become legacy. The upside is that new and yet to be created platforms have a clear foundation to build upon.

With the following table it’s easy to see that an ASP.NET Core 1.0 application has access to the full .NET Platform Standard version 1.5 APIs. In the same regard, Windows Phone 8.1 would not have access to APIs added to the standard after version 1.2.

The Language of the Future is C#


Since C# is the most popular language in .NET, it’s necessary to include it in the conversation. While C# is a very mature language, it has an exciting future as well. Much like the .NET framework, C# is being developed as an open source project. Now that C# is open source, its development will be visible to the public, including the roadmap.

Much like with the .NET Standard Library, Microsoft is promising a faster release cycle with C#. These out-of-band releases will include new language features to further enhance an already robust and mature language. In future releases we’ll see some interesting new ways for developers to write C#.

  • Local functions will allow functions inside of methods that will have access to variables in scope.

  • Tuples let functions return multiple results. The results can be named so that the code remains readable.

       1: //Local function and Tuples preview

       2: static void Main(string[] args)

       3: {

       4:   int[] numbers = { 1,2,3,4,5 };

       5:   

       6:   // Local function

       7:   (int sum, int count) Tally(IEnumerable list)

       8:   {

       9:     var r = (s: 0, c: 0);

      10:     foreach (var v in list)

      11:     {

      12:       r.s += v; r.c++;

      13:     }

      14:     return r; // return Tuple of (int:sum, int:count)

      15:   }

      16:   

      17:   var t = Tally(numbers);

      18:   WriteLine($"Sum: {t.sum}, Count {t.count}"); // => Sum: 15, Count: 5

      19:   

      20: }

  • Pattern matching extensions for C# enable many of the benefits of algebraic data types and pattern matching from functional languages, but in a way that smoothly integrates with the feel of the underlying language. Pattern matching is able to switch on the type of data and offers greater flexibility when working with non-primitive data types.

       1: // pattern matching in C#

       2: var people = {

       3:               new Student("Dustin", "Campbell", 195434) { Grades = { 4.0m, 4.0m, 3.9m, 4.0m, 3.8m, 4.0m }},

       4:               new Student("Mads", "Torgersen", 193845) { Grades = { 2.0m, 2.4m, 3.4m, 1.8m, 3.9m, 0.2m }},

       5:               new Student("David", "Stephens", 230954) { Grades = { }},

       6:               new Professor("Anders", "Hejlsberg", "Programming languages"),

       7:               new Professor("Scott", "Guthrie", "Clouds"),

       8:               new Professor("Scott", "Hunter", ".NET")

       9:             };

      10:  

      11: foreach (var p in people) 

      12: {

      13:   if (p is Professor { Subject is var s, FirstName is "Scott"})

      14:   {

      15:     WriteLine($"One of the Scotts is teaching {s}");

      16:   }

      17:   if (p is Student { FirstName is var n, Gpa is decimal g})

      18:   {

      19:     WriteLine($"{n} has a GPA of {g}:N2");

      20:   }

      21: }

  • Immutable objects are a feature being discussed for beyond C# 7. Immutable objects are an explicit shorthand way of writing immutable classes with the added benefit of the compiler being able to identify them as immutable.

       1: // new up an immutable object 

       2: var p1 = new Point { X = 3, Y = 7 };

       3:  

       4: // copy p1 to p2 with an X value of negative p1's X value.

       5: var p2 = p1 with { X = -p1.X }; //=> { X = -3, Y = 7 }

ROSLYN

The write anywhere run everywhere strategy of .NET is really apparent with C#. Because of Roslyn, the cross platform compiler as a service, C# can be written and run on any platform. Roslyn enables C# to run in IDEs and editors and opens the door to support from any linter, refactoring tool, and code generation tooling. In the future, expect to see more uses for C# in more places.

Conclusion

.NET is always changing and improving as a platform. Because of the sheer amount of changes happening and the speed at which they are delivered, expect some difficulties along the way. However, gone are the days of Microsoft secrecy, so enjoy the new open development process and transparent roadmaps that have been outlined. There’s an exciting future ahead for .NET, it’s cross platform, open source, and full of features one would expect from a modern set of tools and languages.

随机推荐

  1. ThreadLocal简单理解

    在java开源项目的代码中看到一个类里ThreadLocal的属性: private static ThreadLocal<Boolean> clientMode = new Thread ...

  2. SQL Server镜像自动生成脚本

    SQL Server镜像自动生成脚本 镜像的搭建非常繁琐,花了一点时间写了这个脚本,方便大家搭建镜像 执行完这个镜像脚本之后,最好在每台机器都绑定一下hosts文件,不然的话,镜像可能会不work 1 ...

  3. 运行执行sql文件脚本的例子

    sqlcmd -s -d db_test -r -i G:\test.sql 黑色字体为关键命令,其他颜色(从左至右):服务器名称,用户名,密码,数据库,文件路径 通过select @@servern ...

  4. NET Core-学习笔记(三)

    这里将要和大家分享的是学习总结第三篇:首先感慨一下这周跟随netcore官网学习是遇到的一些问题: a.官网的英文版教程使用的部分nuget包和我当时安装的最新包版本不一致,所以没法按照教材上给出的列 ...

  5. spring源码分析之@ImportSelector、@Import、ImportResource工作原理分析

    1. @importSelector定义: /** * Interface to be implemented by types that determine which @{@link Config ...

  6. 在Visual Studio Code中配置GO开发环境

    一.GO语言安装 详情查看:GO语言下载.安装.配置 二.GoLang插件介绍 对于Visual Studio Code开发工具,有一款优秀的GoLang插件,它的主页为:https://github ...

  7. Win10 UWP开发系列——开源控件库:UWPCommunityToolkit

    在开发应用的过程中,不可避免的会使用第三方类库.之前用过一个WinRTXamlToolkit.UWP,现在微软官方发布了一个新的开源控件库—— UWPCommunityToolkit 项目代码托管在G ...

  8. 安装angular-cli

    最近在学习angular2,并尝试用这个框架来做公司的一个新项目. 终于要开始开发了,等了1个多月. 因为第一次用这个新框架做项目,不太熟悉,就找了angular-cli这个脚手架来搭建项目. 安装了 ...

  9. MVC还是MVVM?或许VMVC更适合WinForm客户端

    最近开始重构一个稍嫌古老的C/S项目,原先采用的技术栈是『WinForm』+『WCF』+『EF』.相对于现在铺天盖地的B/S架构来说,看上去似乎和Win95一样古老,很多新入行的,可能就没有见过经典的 ...

  10. required

    required,这是HTML5中的一个新属性:这是HTML5中input元素中的一个属性. required译为必须的,在input元素中应用这一属性,就表示这一input元素节点是必填的或者必选的 ...