5 ms·
Exactly this! I’d love a modern C++ like syntax with the expressiveness of python and a mostly functional approach. C# is not that far I suppose from what I wa
by rao-v 1y ago
Exactly this! I’d love a modern C++ like syntax with the expressiveness of python and a mostly functional approach.
C# is not that far I suppose from what I want
- tjk 1y agoEverybody's mileage will vary, but I find contemporary C# to be an impressively well rounded language and ecosystem. It's wonderfully boring, in the most positive sense of the word.
- LogicHound 1y agoI can't stand modern C#. They've bung in a bunch of new keywords and features that are of dubious benefit every release.
- mrsmrtss 1y agoI'm interested what are those new keywords and features that are of dubious benefit?
- LogicHound 1y agoThere is a huge amount of syntactic sugar that has been added over the years that doesn't do whole lot IMO. It is often imported from other languages (usually JavaScript and/or Python). e.g. Just a very simple example to illustrate the point if (customer != null) { customer.Order = GetCurrentOrder(); } vs if (customer is not null) { customer.Order = GetCurrentOrder(); } Is there really any benefit in adding "is/is not"? I would argue no. So I categorise that as being of "dubious benefit" and there are many similar small features, keywords etc. that get added each release where they might save a few lines of code somewhere but I've never seem them used that often.
- mrsmrtss 1y agoIn your sample there really is no benefit to using the "is" operator over just checking for null (assuming you haven't overloaded the "!=" operator). However, the "is" operator is a lot more powerful, you can match an expression against a pattern with it. Would you say that these samples show no benefit to using the "is" operator? if (obj is string s) { ... } if (date is { Month: 10, Day: <=7, DayOfWeek: DayOfWeek.Friday }) { ... } https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/operators/is https://learn.microsoft.com/en-us/dotnet/csharp/language-ref... https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/operators/patterns https://learn.microsoft.com/en-us/dotnet/csharp/language-ref...
- LogicHound 1y agoThe issue is that I dislike the overall mentality of just adding a bunch of language features. Things just seem to be dumped in each release and I think to myself "When I am going to use that?". > Would you say that these samples show no benefit to using the "is" operator? I didn't say no benefit. I said dubious benefit. I didn't really want to get into discussing specific operators, but lets just use your date example: if (date is { Month: 10, Day: <=7, DayOfWeek: DayOfWeek.Friday }) { ... } This following would do the same thing before the is operator: static bool IsFirstFridayOfOctober(DateTime date) { return date.Month == 10 && date.Day <= 7 && date.DayOfWeek == DayOfWeek.Friday; } And then: if IsFirstFridayOfOctober(date) { ... } I understand it is more verbose. But do we really need a new operator for this? I was getting on fine without it. Each release there seems to be more of these language features and half the time I have a hard time remembering that they even exist. Each time I meet with other .NET developers either virtually or in Person they all seem to be salivating over this stuff and I feel like I've walked in on some sort of cult meeting.
- mrsmrtss 1y agoI agree that they should not add new stuff lightly, but the "is" operator actually should be looked together with switch expression in the context of pattern matching. How else could you enable powerful and succint pattern matching in c#?
- dionian 1y agoScala