I hate recent C# versions!
-
Am I the only one who hates recent addings to the language? Some examples: ?? Named/optional arguments () ?[] discards :confused:
(_, _, area) = city.GetCityInformation(cityName);
Switch expressions The list can go on and on. They are trying to make programming much easier and at the same time are making the syntax more and more unreadable:mad::mad:
Behzad
Some of the new features I really like. Some I don't. The issue for me is not about what I may or may not like, but the ever-increasing complexity. People say 'just don't use the features if you don't like them'. This is fine if you mainly work on your own, but what if you work in a team? Or worse, lead one? You're likely to have a mix of people, some of whom want to explore all the new features, and some who are just learning. The latter group will really struggle because of the former - their learning curve will be much steeper, they will require more support, and they may even lose confidence and decide this isn't for them. There's a good article here[^] that explores this. TL;DR: langauge design is a balance between keeping up, and overloading with complexity. If you don't add new features, the language dies; but new features eventually make the langauge die from complexity. Personally, I understand the need to keep evolving the langauage, and really appreciate some of the additions, but I would prefer a slower, more measured evolution.
-
Am I the only one who hates recent addings to the language? Some examples: ?? Named/optional arguments () ?[] discards :confused:
(_, _, area) = city.GetCityInformation(cityName);
Switch expressions The list can go on and on. They are trying to make programming much easier and at the same time are making the syntax more and more unreadable:mad::mad:
Behzad
I missed the latest stuff, as we are still using Visual Studio 2017. But in my opinion, null propagation, named arguments and lambdas are useful and increase readability. I haven't tried switch expression, but they look like the same goes for them. I'm not familiar with ?[] and (_, _, area)=...! Does it mean you can return multiple values? Looks a little untidy compared to returning an object.
-
Behzad Sedighzadeh wrote:
... recent addings to the language ...
I'm not convinced by your definition of "recent"! :laugh:
Behzad Sedighzadeh wrote:
Named/optional arguments
Added in C# 4, which was released in April 2010.
Behzad Sedighzadeh wrote:
?? ?[]
The null conditional / coalescing operators were added in C# 6 (July 2015).
Behzad Sedighzadeh wrote:
discards
C# 7 (March 2017)
Behzad Sedighzadeh wrote:
()
Not entirely sure what you're referring to here. I'm going to guess that you mean value tuples, which were also added in C# 7 (March 2017).
Behzad Sedighzadeh wrote:
Switch expressions
C# 8 (September 2019). As with any addition to the language, nobody is forcing you to use them. If you want to stick to writing C# 1.0 code, then you're free to do so. It's only when you come to read someone else's code that you might need to understand the newer constructs - but even then, there are ways to convert the code to an older syntax.
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
I tend to agree with you on this one. C# has always been innovating, for the sake of trying new things or simply taking a swing to solve minor issues. I have no problem with Microsoft doing this. Most additions end up never being used in production anyway. As far as I can tell, they typically serve a very niche purpose and audience, and only rarely catch on.
-
Am I the only one who hates recent addings to the language? Some examples: ?? Named/optional arguments () ?[] discards :confused:
(_, _, area) = city.GetCityInformation(cityName);
Switch expressions The list can go on and on. They are trying to make programming much easier and at the same time are making the syntax more and more unreadable:mad::mad:
Behzad
null conditional in variables im still nah about var x = object?.value?.pointer1; tuples and tuple deconstructions are enjoy mainly from article from I think team creator about why he does not see many use tuples, and always just pairs which then is key/value pair, but tuples a bit more then that, and the syntax need to set and the deconstruct, so made it much easier. Can't find article but something like this [C# - Tuple Trouble: Why C# Tuples Get to Break the Guidelines | Microsoft Docs](https://docs.microsoft.com/en-us/archive/msdn-magazine/2018/june/csharp-tuple-trouble-why-csharp-tuples-get-to-break-the-guidelines) switch expression, similar, once know it clicks why would use instead of some other form makes sense. For me I dislike the syntax of most switch/break, is it : or brace :doh: , so I prefer if/else setups. then switch expression, for assigning a value, ohhh, yes. in comparison to if/else for value assign.
-
Behzad Sedighzadeh wrote:
... recent addings to the language ...
I'm not convinced by your definition of "recent"! :laugh:
Behzad Sedighzadeh wrote:
Named/optional arguments
Added in C# 4, which was released in April 2010.
Behzad Sedighzadeh wrote:
?? ?[]
The null conditional / coalescing operators were added in C# 6 (July 2015).
Behzad Sedighzadeh wrote:
discards
C# 7 (March 2017)
Behzad Sedighzadeh wrote:
()
Not entirely sure what you're referring to here. I'm going to guess that you mean value tuples, which were also added in C# 7 (March 2017).
Behzad Sedighzadeh wrote:
Switch expressions
C# 8 (September 2019). As with any addition to the language, nobody is forcing you to use them. If you want to stick to writing C# 1.0 code, then you're free to do so. It's only when you come to read someone else's code that you might need to understand the newer constructs - but even then, there are ways to convert the code to an older syntax.
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
I think OP is only starting to see these in code bases. Not everyone is on latest/greatest day 1 :) adoption takes time. I have to also say something about "nobody forcing" is - try to write C# 1.0 code and get it past code review :) In the end everyone will have to just put up with it - if they like these features or not.
-
Am I the only one who hates recent addings to the language? Some examples: ?? Named/optional arguments () ?[] discards :confused:
(_, _, area) = city.GetCityInformation(cityName);
Switch expressions The list can go on and on. They are trying to make programming much easier and at the same time are making the syntax more and more unreadable:mad::mad:
Behzad
Yes! I don't program for PCs any more any just stick to embedded in C largely because all the higher level languages have been similarly afflicted.
-
Am I the only one who hates recent addings to the language? Some examples: ?? Named/optional arguments () ?[] discards :confused:
(_, _, area) = city.GetCityInformation(cityName);
Switch expressions The list can go on and on. They are trying to make programming much easier and at the same time are making the syntax more and more unreadable:mad::mad:
Behzad
It used to be that C# could tell a story, but not now and that has greatly reduced the maintainability. A lot of this has to do with it going to Open Source with its rapid cycle of updates. There is some perceived benefit to constant change. No one seems to be factoring in cost. Is there any wonder that there is a talent shortage? There is no benefit to terseness if it reduces readability or maintainability. And don't think this stuff is never used. You always have some contractors on the bleeding edge and they just create problems for people that want to engineer reliable, maintainable solutions. Companies may think it's new and hot, but it is just difficult to maintain.
-
Be more positive - learn these additions, but use only if fits... After all - they do not force you!!!
"Everybody is a genius. But if you judge a fish by its ability to climb a tree, it will live its whole life believing that it is stupid." ― Albert Einstein
Kornfeld Eliyahu Peter wrote:
Be more positive - learn these additions, but use only if fits... After all - they do not force you!!!
Nope, you're wrong. It's very easy to get in the position of supporting someone else's unreadable code. Of the last 8 to 10 C# releases, I've found about 90% of the new syntax to either be useless or counter-productive, as it makes the code unreadable. The C# team keeps making "additions", as it's their job, and for the most part they ran out of useful things to add years ago, but they don't let that stop them. :doh:
-
Am I the only one who hates recent addings to the language? Some examples: ?? Named/optional arguments () ?[] discards :confused:
(_, _, area) = city.GetCityInformation(cityName);
Switch expressions The list can go on and on. They are trying to make programming much easier and at the same time are making the syntax more and more unreadable:mad::mad:
Behzad
-
Am I the only one who hates recent addings to the language? Some examples: ?? Named/optional arguments () ?[] discards :confused:
(_, _, area) = city.GetCityInformation(cityName);
Switch expressions The list can go on and on. They are trying to make programming much easier and at the same time are making the syntax more and more unreadable:mad::mad:
Behzad
-
Am I the only one who hates recent addings to the language? Some examples: ?? Named/optional arguments () ?[] discards :confused:
(_, _, area) = city.GetCityInformation(cityName);
Switch expressions The list can go on and on. They are trying to make programming much easier and at the same time are making the syntax more and more unreadable:mad::mad:
Behzad
MS is trying to make C# look like nasty Python, JS, Go, and the rest of the bunch. So bad is "dotnet new console" that I had to write my own "Hello World" template. I do not program with top-level statements, and I never will. So bad is it that I will need to write a processor to parse new, terrible C# syntax, and refactor to old style.
-
There is “with” in C#: with expression - C# reference | Microsoft Docs[^]
Which is not a
with
statement. -
Then you wont like this valid c# syntax:
if (jsonReader.TokenType is JsonTokenType.EndObject or JsonTokenType.EndArray)
{
//...
}Old syntax:
if (jsonReader.TokenType == JsonTokenType.EndObject || jsonReader.TokenType == JsonTokenType.EndArray)
{
//...
}Graeme
"I fear not the man who has practiced ten thousand kicks one time, but I fear the man that has practiced one kick ten thousand times!" - Bruce Lee
Yeah, still just trying to attract VB developers.
-
Yeah, still just trying to attract VB developers.
PIEBALDconsult wrote:
Yeah, still just trying to attract VB developers.
I am seeing a lot of very old VB features creeping in. Probably for the Python crowd.
Graeme
"I fear not the man who has practiced ten thousand kicks one time, but I fear the man that has practiced one kick ten thousand times!" - Bruce Lee
-
Behzad Sedighzadeh wrote:
... recent addings to the language ...
I'm not convinced by your definition of "recent"! :laugh:
Behzad Sedighzadeh wrote:
Named/optional arguments
Added in C# 4, which was released in April 2010.
Behzad Sedighzadeh wrote:
?? ?[]
The null conditional / coalescing operators were added in C# 6 (July 2015).
Behzad Sedighzadeh wrote:
discards
C# 7 (March 2017)
Behzad Sedighzadeh wrote:
()
Not entirely sure what you're referring to here. I'm going to guess that you mean value tuples, which were also added in C# 7 (March 2017).
Behzad Sedighzadeh wrote:
Switch expressions
C# 8 (September 2019). As with any addition to the language, nobody is forcing you to use them. If you want to stick to writing C# 1.0 code, then you're free to do so. It's only when you come to read someone else's code that you might need to understand the newer constructs - but even then, there are ways to convert the code to an older syntax.
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
No one is forcing you to use those new features unless you're working on a codebase that uses those new features. Things like
public readonly double Distance => Math.Sqrt(X * X + Y * Y);
are, for me, a matter of taste. Things like
public static bool IsLetterOrSeparator(this char c) =>
c is (>= 'a' and <= 'z') or (>= 'A' and <= 'Z') or '.' or ',';give me stomach acid. A dev has saved a few keystrokes at the expense of structure. This
static Quadrant GetQuadrant(Point point) => point switch
{
(0, 0) => Quadrant.Origin,
var (x, y) when x > 0 && y > 0 => Quadrant.One,
var (x, y) when x < 0 && y > 0 => Quadrant.Two,
var (x, y) when x < 0 && y < 0 => Quadrant.Three,
var (x, y) when x > 0 && y < 0 => Quadrant.Four,
var (_, _) => Quadrant.OnBorder,
_ => Quadrant.Unknown
};is meant to provide neat, compact code but I worry that for someone new to C# it becomes a stumbling block. My feeling is that it should be easy to switch between languages. Truly I wish there were only one language, but us humans are tribal and so that will never happen (and of course situations where a language needs to have specifics for the platform, hardware, compiler or programming methodology). Even so, making a language simpler is better, and adding syntactic sugar for the sake of it simply diverges the language. In many instances adding new features can converge languages. Javascript gaining the coalesce operator, C# getting the null-check. This is All Good. But like good art, they should add what they need and no more.
cheers Chris Maunder
-
No one is forcing you to use those new features unless you're working on a codebase that uses those new features. Things like
public readonly double Distance => Math.Sqrt(X * X + Y * Y);
are, for me, a matter of taste. Things like
public static bool IsLetterOrSeparator(this char c) =>
c is (>= 'a' and <= 'z') or (>= 'A' and <= 'Z') or '.' or ',';give me stomach acid. A dev has saved a few keystrokes at the expense of structure. This
static Quadrant GetQuadrant(Point point) => point switch
{
(0, 0) => Quadrant.Origin,
var (x, y) when x > 0 && y > 0 => Quadrant.One,
var (x, y) when x < 0 && y > 0 => Quadrant.Two,
var (x, y) when x < 0 && y < 0 => Quadrant.Three,
var (x, y) when x > 0 && y < 0 => Quadrant.Four,
var (_, _) => Quadrant.OnBorder,
_ => Quadrant.Unknown
};is meant to provide neat, compact code but I worry that for someone new to C# it becomes a stumbling block. My feeling is that it should be easy to switch between languages. Truly I wish there were only one language, but us humans are tribal and so that will never happen (and of course situations where a language needs to have specifics for the platform, hardware, compiler or programming methodology). Even so, making a language simpler is better, and adding syntactic sugar for the sake of it simply diverges the language. In many instances adding new features can converge languages. Javascript gaining the coalesce operator, C# getting the null-check. This is All Good. But like good art, they should add what they need and no more.
cheers Chris Maunder
Chris Maunder wrote:
public readonly double Distance => Math.Sqrt(X * X + Y * Y);
That would give you a
CS0106
compiler error. :) You would need either:public readonly double Distance = Math.Sqrt(X * X + Y * Y);
or:
public double Distance => Math.Sqrt(X * X + Y * Y);
Wrong: See William's post below.Chris Maunder wrote:
c is (>= 'a' and <= 'z') or (>= 'A' and <= 'Z')
Well, of course, anyone serious about performance would write that as:
(uint)((c | 0x20) - 'a') <= 'z' - 'a'
:laugh: Source: Performance Improvements in .NET 7 - .NET Blog[^])
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
-
Chris Maunder wrote:
public readonly double Distance => Math.Sqrt(X * X + Y * Y);
That would give you a
CS0106
compiler error. :) You would need either:public readonly double Distance = Math.Sqrt(X * X + Y * Y);
or:
public double Distance => Math.Sqrt(X * X + Y * Y);
Wrong: See William's post below.Chris Maunder wrote:
c is (>= 'a' and <= 'z') or (>= 'A' and <= 'Z')
Well, of course, anyone serious about performance would write that as:
(uint)((c | 0x20) - 'a') <= 'z' - 'a'
:laugh: Source: Performance Improvements in .NET 7 - .NET Blog[^])
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
Richard Deeming wrote:
That would give you a CS0106 compiler error
That was copy and pasted from [What's new in C# 8.0 - C# Guide | Microsoft Docs](https://docs.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-8) :-D
cheers Chris Maunder
-
Am I the only one who hates recent addings to the language? Some examples: ?? Named/optional arguments () ?[] discards :confused:
(_, _, area) = city.GetCityInformation(cityName);
Switch expressions The list can go on and on. They are trying to make programming much easier and at the same time are making the syntax more and more unreadable:mad::mad:
Behzad
-
Which is not a
with
statement. -
Am I the only one who hates recent addings to the language? Some examples: ?? Named/optional arguments () ?[] discards :confused:
(_, _, area) = city.GetCityInformation(cityName);
Switch expressions The list can go on and on. They are trying to make programming much easier and at the same time are making the syntax more and more unreadable:mad::mad:
Behzad
Though I know C# very well, I stick with VB.NET simply because Microsoft is no longer updating the language with all the screwy constructs they keep adding to C#. Both languages are highly mature and no longer really need any new additions and have been that way for quite some time. However, Microsoft can't seem to let anything be even if it doesn't require MS engineers mucking about with it...
Steve Naidamast Sr. Software Engineer Black Falcon Software, Inc. blackfalconsoftware@outlook.com