News for hackers. Stuff that matters.
Re:Is C# Underhyped? by zamalek on Thursday December 07, 2023 @10:38PM (#38565161)
Good C# is certainly possible, XNA was a thing of beauty. There are still fundamental issues with the language. Another example (beyond nulls etc.): why do C# switch statements require break? Fall-through isn't supported, so it's just dangling there as an artifact of a previous language and not, oh I don't know, doing something useful like breaking out of the loop that contains the switch. When was the last time you took advantage of the variable scoping in switch, vs. when was the last time you had to figure out what to call a variable because of the scoping rules.

Ignoring the big issues, it's paper cut after paper cut.

It's infuriating after you've used a language with thoughtful ergonomics.

Re:Is C# Underhyped? by briHass on Thursday December 07, 2023 @11:14PM (#38565370)
Blame C/C++ for the switch complaint. C#'s design was to avoid a lot of those nasty pitfalls by making you be explicit about your intent. You don't have to use a break, but you do have to explicitly exit out of the switch, so a return, or throw, or (gasp) goto works also. This means forgetting a break is a compiler error, not the silent execution of subsequent cases, which is probably a trick employed purposefully in C++ like 5% of the time and a nasty bug for every other instance.
Re:Is C# Underhyped? by cableshaft on Thursday December 07, 2023 @11:27PM (#38565447)
> why do C# switch statements require break? Fall-through isn't supported

Yes it is. I've got it in my game right now. It totally supports fall-through.

Re:Is C# Underhyped? by zamalek on Thursday December 07, 2023 @11:29PM (#38565465)
... by using a goto case, which you can put anywhere in a case. The break remains non-functional.
Re:Is C# Underhyped? by neonsunset on Friday December 08, 2023 @07:55AM (#38568444)
Switch in C# is pretty much Rust's 'match' (aside from Rust having unit type and being expression oriented which gives it an advantage). It support list pattern matching, object type and member pattern matching, inline slice patterns, etc. You don't need to use switch statements for that either, switch expressions is the recommended syntax today and IDE is likely to even suggest to auto-fix some of the idioms it can recognize.