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. 




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:
case int i:
    Console.WriteLine($"Number {i}");
case Point(int x, int y):
case null:

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!



Falco On Track To Version 1.0.0

Falco is a cloud native runtime security tool for the Linux operating system, designed to detect abnormal behavior and warn of potential security threats in real-time. Now it's about to release its fi [ ... ]

Is PHP in Trouble?

The April 2024 headline for the TIOBE Index, which ranks programming languages in terms of their popularity, reads, "Is PHP losing its mojo" asking this question because this month PHP has dropped out [ ... ]

More News


raspberry pi books



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


Last Updated ( Thursday, 29 January 2015 )