C# 7 - What Would You Put In?
C# 7 - What Would You Put In?
Written by Mike James   
Thursday, 29 January 2015

Microsoft's conversion to open source is very patchy, and sometimes seems to make little difference to how things work, but when it comes to C# things really do seem to have changed. 

 

Csharp7

 

The proceedings of a  recent meeting on the design of C#7 have been placed on GitHub for all to read and you can make suggestions. It begins:

This time we want to increase the openness further: 

  • we involve the community from the beginning of the design cycle (as per these notes!)

  • in addition to design notes (now issues on GitHub) we will maintain feature proposals (as checked-in Markdown documents) to reflect the current design of the feature

  • we will consider publishing recordings of the design meetings themselves, or even live streaming

  • we will consider adding non-Microsoft members to the design team.

it also says that Anders Hejlsberg will always have the last word - which as the chief architect of .NET seems entirely reasonable. 

So what are the possibilities for the new C#? 

The team identify a number of possible themes:

  • Improving working with data
  • Performance and reliability
  • Componentization
  • Distributed programming
  • Metaprogramming
  • Null tolerant operator 

The biggest of the themes is better data handling and some of the suggestions so far are: 

  • pattern matching
  • tuples
  • "denotable" anonymous types
  • "records" - compact ways of describing shapes
  • working with common data structures (List/Dictionary)
  • extension members
  • slicing
  • immutability
  • structural typing/shapes?

 

The big single feature here is the idea of pattern matching to allow, among other things, conditional execution based on type:

switch (o) {
case string s:
    Console.WriteLine(s);
    break;
case int i:
    Console.WriteLine($"Number {i}");
    break;
case Point(int x, int y):
    Console.WriteLine("({x},{y})");
    break;
case null:
    Console.WriteLine("<null>);
    break
}

Array slicing - i.e. having dynamic windows onto arrays is also considered,  What about the idea of allowing reference locals and returns? This would allow you to say return a reference to a location in an array. Do we want what would be effectively safe pointers in methods and the complications of pointer assignment? 

Less controversial are readonly parameters and locals - something that other mainstream languages have. Another sensible suggestion, though difficult to implement well, is the idea of allowing a lambda expression to specify the variables it wants captured in the closure similar to the way C++ lambda's work.

The final suggestion in the write up is to allow method contracts to become part of the language syntax. The idea goes further however in that the conditions could be compiled into runtime checks as well as just providing metadata for tools. 

It is good to see C# look so energized after its long sidelining while WinRT and C++ got all the attention. Perhaps Anders Hejlsberg can forget TypeScript and get back to more important matters in the future. 

If you want C# to keep going down the open source route then contribute!

Csharp7

Banner


NetBeans 9 RC1 Ready to Go
23/05/2018

NetBeans seems to have survived its transition from Oracle to Apache, but it is still difficult to say how well. The long-awaited version 9 is ready for serious work and you can download the release c [ ... ]



Atom v Visual Studio Code - The Unexpected Consequence Of Consolidation
14/06/2018

OK, so you got upset about Microsoft taking over GitHub, but after a lot of reassurance you can see that commercial interests mean that Microsoft isn't going to trash GitHub - well not at first. But w [ ... ]


More News

 

justjsquare

 



 

Comments




or email your comment to: comments@i-programmer.info

 

Last Updated ( Thursday, 29 January 2015 )
 
 

   
Banner
RSS feed of news items only
I Programmer News
Copyright © 2018 i-programmer.info. All Rights Reserved.
Joomla! is Free Software released under the GNU/GPL License.