|
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?"
|
|
|
|
|
I'm ok with some of the simple quality-of-life things like null coalescing, and switch expressions. But a lot of it (compiler and runtime lib) has all gone a bit too far in the direction of high-level / functional programming.
The beauty of C# was that it had much of the speed and efficiency of a low-level lang, with high-level niceties like GC, immutable strings and bounds-checked arrays (all of which happen to be important for security).
But now code is riddled with anonymous function callbacks and linq expressions which can be 30x slower and consume more heap, than equivalent old school C#.
And harder to read, sometimes, yes.
I think it's a generational rotation, from devs whose first language was C/C++, to devs whose first programming language was javascript.
|
|
|
|
|
I like some of it. It's useful to be able to say something like
string x = Person?.Name ?? "";
and for me, that's quite easy to read.
There are other bits which are sort of ghastly, though. Basically, I don't like anything which, to me, isn't totally context-insensitive, or where I can't tell what the compiler's quite going to do with it (which is why I hate Linq).
It's all quite interesting, though. As a language, C# is becoming so laden with syntactic sugar that at this point, it's actually idiomatic, which is fascinating for a programming language: until now, I'd always considered idiom as something restricted to spoken, human languages.
|
|
|
|
|
I think C# has always sacrificed clarity of syntax for high-level functionality. Many people seem to like it, as it increasingly enables more to be done with fewer lines of code (though I am not sure why that's important) but personally I find it too high-level now for my liking so I rarely use it. No one language will ever appeal to everyone in my opinion.
|
|
|
|
|
Honestly nuts, secretly (2 3 3)
"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
|
|
|
|
|
On the sly ?
Life should not be a journey to the grave with the intention of arriving safely in a pretty and well-preserved body, but rather to skid in broadside in a cloud of smoke, thoroughly used up, totally worn out, and loudly proclaiming “Wow! What a Ride!" - Hunter S Thompson - RIP
|
|
|
|
|
I was hoping for more than one minute of fame
You are up tomorrow!
"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
|
|
|
|
|
so nuts is an anagram indicator?
I’ve given up trying to be calm. However, I am open to feeling slightly less agitated.
|
|
|
|
|
It can be - think "mixed up" or "crazy". The words that can be anagram indicators are legion. It would probably be quite possible to create an entire clue using only anagram indicators. Heck, it's probably already been done!
|
|
|
|
|
@KornfeldEliyahuPeter
Where's the CCC?
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
On its way... I just felt I have to earn the Oi
"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
|
|
|
|
|
@KornfeldEliyahuPeter
As requested: I won't post CCC until I get Oied[^]
So ... where's the CCC? (apart from not being due for 90 minutes odd, now you have no excuse ... )
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
|
|
Wordle 444 5/6
⬛⬛⬛🟩⬛
⬛⬛⬛🟩⬛
⬛🟨⬛🟩🟩
⬛🟨🟨🟩🟩
🟩🟩🟩🟩🟩
|
|
|
|
|
Wordle 444 X/6
⬛⬛🟨🟨⬛
🟨⬛⬛🟨🟩
⬛🟨⬛🟨🟩
⬛🟩🟩🟩🟩
⬛🟩🟩🟩🟩
⬛🟩🟩🟩🟩
Once again I ran out of rows before I got the right letter!
|
|
|
|