|
Agree. However they do not just save keystrokes, hence I like the features listed here.
Reducing the risk of errors (like the switch expressions) and reducing the amount of code that is not clearly expressing the intend of your algorithm (like ?. and ??) Is a clear benefit for me.
I can even get behind the minimalistic stuff, once they expand it to cover all classes. I have no need for one single class to look completely different. But I guess they will eventually realize the main use case for C# is not only doing cool demos at conferences and expand it to us who have "complicated" programs needing two or more classes.
|
|
|
|
|
Speak for yourself. I, for example, love ?? and switch expressions for making the syntax more readable, actually. They are concise, that is, there's less syntax to achieve the same thing, meaning less overhead to parse when reading.
|
|
|
|
|
I believe they are competing with JS and python, because programming Meme always noted that python is fast in a single hello world sample, And others are not. The things I'm not sure about is why companies such as JetBrains also support those bad manners, and force users to change code to some of these style, while they just could ignore the user style (that may depend on the surranding and could change readability regarding to that)
|
|
|
|
|
i hope it does not sound patronizing for me to i say that i "love" the discussion of "I hate recent C# versions" what a pleasure for an old man about to get new eyes, to savor the illuminations of many of CP's brightest-bulbs.
Kornfeld's signature quote from Einstein: "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."
Did make me chuckle ... as I thought of the tree-climbing mudskipper fish whose evolutionary history is detailed in Richard Dawkins' magisterial survey, "The Ancestor's Tale." (see "The Lungfishes' Tale").Quote: Another common name, ‘climbing fish’, comes from their habit of climbing mangrove trees looking for prey. They cling to the trees with the pectoral fins, aided by a kind of sucker which is made by bringing the pelvic fins together under the body. That boomeranging thought leads me to ponder if the evolution of C# ... leads us to believe we ... are ... smart.
Is the "destiny" of C# (my favorite grab-bag of syntax and functionality masquerading as a "computer language") to have as much junk in its DNA as we, Homo Saps, do ?
cheers, Bill
«The mind is not a vessel to be filled but a fire to be kindled» Plutarch
|
|
|
|
|
If you don’t like more succinct code I would just stick with COBOL
|
|
|
|
|
Yes! One language to rule them all
|
|
|
|
|
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.
|
|
|
|
|
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.
|
|
|
|
|
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
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 , so I prefer if/else setups.
then switch expression, for assigning a value, ohhh, yes. in comparison to if/else for value assign.
|
|
|
|
|
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.
|
|
|
|
|
I do embedded C mostly also.
However I had a fairly hairy embedded project that I ended up writing a C# wrapper around to permit faster testing (I was processing recorded data files).
The only thing I really missed from C is the preprocessor.
Why is this not a thing in C#?
#define FOOT_PER_MILE 5280.0
#define INCH_PER_FOOT 12.0
#define INCH_PER_MILE (FOOT_PER_MILE * INCH_PER_FOOT)
double miles = 12.54;
double inches;
...
inches = miles * INCH_PER_MILE;
In a lot of embedded applications you don't have GB of ram to use. Sometimes you are stuck with KB of RAM. It is hard to beat inline constants when squeezing a program into a resource limited processor.
|
|
|
|
|
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.
|
|
|
|
|
I am delighted with some recent extensions, with others I'm indifferent and I don't hate any.
Sorry for my bad English
|
|
|
|
|
This is in preparation for the launch of C# Classic, the new clean and back-to-basics version that everyone will be talking about in a couple of years.
* Smaller footprint
* Faster
* Write clean, consistent code with your team
The new C# Classic!
|
|
|
|
|
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.
|
|
|
|
|
What about the ternary operator? You could argue that it doesn't make code more readable and not use it, but I guess you got somehow accustomed to it. (By the way: what is not to like about optional arguments or naming arguments?)
|
|
|
|
|
The ternary operator is in C. I use it. It is not any more efficient than a simpler if else construct, but visual scope matters as well. Being able to see more of the code on the screen at the same time can make coding/debugging faster and easier.
|
|
|
|
|
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
|
|
|
|
|
|
Agreed. C# is such an elegant language and well written C# code is understandable at a glance. Much of this new stuff is just WTF??
|
|
|
|
|
There is often a trade-off between succinctness and clarity. It's not always about "saving a few keystrokes"; sometimes it's about removing nonessential details, or better expressing intent, or allowing a developer to (literally) see the whole picture, or increase speed of understanding. Other times we see features added that have proved valuable in other languages or platforms.
|
|
|
|
|
First, they came for the types (var) and noone said anything...
Haha.
I disagree on the named/optional and the discards, mostly on the point of "unreadable". These both make code more legible as opposed to maybe more succinct like your other examples.
|
|
|
|
|
Actually, I like and use many of the new enhancements. Some of them are real time savers, for example:
int x = foo?.bar?.index?[y] ?? 0;
versus:
int x = 0;
if (foo != null && foo.bar != null && foo.bar.index != null && foo.bar.index[y] != null
{
x = foo.bar.index[y];
}
Not only was the new style code shorter and easier to write, but I would assume that it compiles down to a more efficient form because it doesn't have to keep re-evaluating the entire list of object references / pointers and only assigns a value to x once. Of course, I could write the second version to use a bunch of temporary variables and theoretically get close to the same performance, but then it would grow to be many more lines long... and still contain a bunch of redundant assignments to x that would be hard to eliminate unless I turned it into a local function (that's a lot of extra code authoring versus the nice simple, efficient, single line).
I also think the first version is easier to read. I like the simplicity of a single ? for a null check and the double ?? for a default value.
I've also used the is/as construct as a time saver and really like some of the new switch statement options and scoping, and some of the new code shortcuts (like using get => x; instead of get { return x; }
I particularly like putting them together for properties, for example writing public int count { get => mylist?.Count ?? 0; } is a lot easier (and clearer) than having to write out the null check. And while it might take a little bit to get used to, it's fairly intuitive (if I'd never seen it before, I'm pretty sure I'd still be able to figure out what it means just by the context).
I can't say I'm a fan of every change, and I tend to lag (if only because I don't like to depend on the latest compiler when I'm working on a team, I try to give everyone time to get on the new compiler). However, the compiler hints do often push me toward the new options when it suggests them as ways to 'improve' my code... (sometimes I like that, and sometimes I don't...)
|
|
|
|
|
As you learn more languages, you start to see where the C# developers copy all of their "innovations" from. They do it if it fits or not and if it makes sense or not. Sometimes they adopt the concept, but need to tweak the implementation in such a way, it loses a significant bit of the value it had in the original language.
Global usings predefined by project type are my current favorite example.
It seems like a matter of pride that C# has practically every feature they have seen in another language that they could make "work".
The "magic" they add to the language allows someone to write far more logic in fewer strokes and a reader of the code has to understand exponentially more about the project type, all referenced libraries, and the code in every file if it looks relevant or not.
With "global using" statements and extension methods, reading C# code snippets on line or even complete files can be somewhat meaningless without significant additional documentation describing the code.
|
|
|
|
|
Yeah, I think the global usings as well as ditching some of the boilerplate for a shorter "Hello World!" probably falls under the Geneva Convention or some kind of human rights UN charter but I haven't figured out how to bring a case yet.
Some noob trying to learn:
"args[]? what args[]? wth is args[]? is that a keyword? a variable?! but where...? huh? who thought this was ok?"
|
|
|
|