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. Python编码记录

    字节流和字符串 当使用Python定义一个字符串时,实际会存储一个字节串: "abc"--[97][98][99] python2.x默认会把所有的字符串当做ASCII码来对待,但 ...

  2. 冒泡,setinterval,背景图的div绑定事件,匿名函数问题

    1.会冒泡到兄弟元素么? $(function(){ $("#a").click(function(){alert("a")}) $("#b" ...

  3. WPF 微信 MVVM 【续】修复部分用户无法获取列表

    看过我WPF 微信 MVVM这篇文章的朋友,应该知道我里面提到了我有一个小号是无法获取列表的,始终也没找到原因. 前两天经过GitHub上h4dex大神的指导,知道了原因,是因为微信在登录以后,web ...

  4. MySQL数据库和InnoDB存储引擎文件

    参数文件 当MySQL示例启动时,数据库会先去读一个配置参数文件,用来寻找数据库的各种文件所在位置以及指定某些初始化参数,这些参数通常定义了某种内存结构有多大等.在默认情况下,MySQL实例会按照一定 ...

  5. JavaScript正则表达式,你真的知道?

    一.前言 粗浅的编写正则表达式,是造成性能瓶颈的主要原因.如下: var reg1 = /(A+A+)+B/; var reg2 = /AA+B/; 上述两个正则表达式,匹配效果是一样的,但是,效率就 ...

  6. C#多线程之线程同步篇1

    在多线程(线程同步)中,我们将学习多线程中操作共享资源的技术,学习到的知识点如下所示: 执行基本的原子操作 使用Mutex构造 使用SemaphoreSlim构造 使用AutoResetEvent构造 ...

  7. css元素水平居中和垂直居中的方式

    关于居中的问题,一直处于疑惑不解的状态,知道的几种方法好像也不是每一次都会起到作用,所以更加迷惑.主要是不清楚该 在什么情况下采用哪种解决方法,所以,整理了一些方法,梳理一下思路,做一个总结. 1. ...

  8. Python爬虫小白入门(四)PhatomJS+Selenium第一篇

    一.前言 在上一篇博文中,我们的爬虫面临着一个问题,在爬取Unsplash网站的时候,由于网站是下拉刷新,并没有分页.所以不能够通过页码获取页面的url来分别发送网络请求.我也尝试了其他方式,比如下拉 ...

  9. 推荐一个ASP.NET网站内容管理系统源码

    许多人都有各自的兴趣,如打球.踢毽子.看书.看电视.玩游戏等等....我近来迷上了猜灯谜,于是业余做了一个在线猜灯谜的网站:何问起谜语. 先出个谜语让你猜猜:不可缺一点(打一字).可以在线猜:http ...

  10. SharePoint2016安装的过程的”Microsoft.SharePoint.Upgrade.SPUpgradeException”错误解决方法

    前提 在windows server 2012的服务器上运行安装sharepoint2016出现如下错误: Could not load file or assembly ‘Microsoft.Dat ...