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


AI Breakthrough For Robot Surgery
17/11/2024

Using imitation learning, a robot has learned to perform surgical procedures as skillfully as human surgeons, bringing the field of robotic surgery closer to true autonomy.



Apache Fury Adds Optimized Serializers For Scala
31/10/2024

Apache Fury has been updated to add GraalVM native images and with optimized serializers for Scala collection. The update also reduces Scala collection serialization cost via the use of  encoding [ ... ]


More News

 

espbook

 

Comments




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

 

Last Updated ( Thursday, 29 January 2015 )