[HN Gopher] Welcome to C# 11
       ___________________________________________________________________
        
       Welcome to C# 11
        
       Author : dustedcodes
       Score  : 56 points
       Date   : 2022-11-08 16:18 UTC (6 hours ago)
        
 (HTM) web link (devblogs.microsoft.com)
 (TXT) w3m dump (devblogs.microsoft.com)
        
       | keewee7 wrote:
       | Looking back at how HN and r/programming reacted to recent
       | versions of C# the common complaints are that the language is
       | becoming too complex and that it is hard to keep up with new
       | features.
       | 
       | The language has gotten a lot of new features but it is
       | surprisingly viable to keep coding like it's 2012 when C# 5.0
       | came out with async/await support.
       | 
       | It is also surprisingly viable for most C# programmers to _not_
       | keep up with new language feature. Most are using ReSharper or
       | Rider that will introduce useful new language features as a
       | refactoring suggestion that is one shortcut away.
        
       | delta_p_delta_x wrote:
       | > Monoid                 T AddAll<T>(params T[] elements) where T
       | : IMonoid<T> =>          elements switch       {           [] =>
       | T.Zero,           [var first, ..var rest] => first +
       | AddAll<T>(rest),       };
       | 
       | It is remarkable how functional C# has become. Not that it wasn't
       | very functional already, what with LINQ and its (much more
       | powerful than Java) generics but the above example really hammers
       | home how much FP has inspired C#, on top of Ocaml's influence on
       | C# generics[0].
       | 
       | [0]: https://github.com/ocaml/cwn-
       | data/blob/9ee93e99d984b3f922e25...
        
         | ziml77 wrote:
         | It's been going that way since LINQ and I'm happy every time
         | they move a bit more functional. I don't want my C# to be
         | purely functional, but I love being able to choose to use
         | functional constructs when I feel they work better.
        
         | WorldMaker wrote:
         | > its (much more powerful than Java) generics
         | 
         | Yeah, it's also interesting to point out how useful to FP C#
         | 11's further improvements to generics are. Generic Math, which
         | the IMonoid<T> in this example is a part of explaining a small
         | related piece of (static abstract interfaces), is another place
         | where C# is improving generics (further beyond Java).
         | 
         | The list of interfaces in the much expanded System.Numerics
         | namespace where most of the raw implementation of Generic Math
         | lives should look quite interesting, if not familiar, to many
         | FP developers: https://learn.microsoft.com/en-
         | us/dotnet/api/system.numerics...
         | 
         | It will be interesting to see where libraries take Generic
         | Math.
        
         | vyrotek wrote:
         | I saw that and immediately thought, "Someone put F# in my C#!".
         | Looks great.
        
         | david_allison wrote:
         | Although seldom used, C# has allowed for Haskell-style monadic
         | comprehension syntax for decades via extension methods. It's
         | very strong functionally                   var paymentId =
         | from joshIban in processor.GetIban("josh") // fails
         | from olenaIban in processor.GetIban("olena") // not executed
         | from paymentId in processor.SendPayment(joshIban, olenaIban,
         | 100)             select paymentId;
         | 
         | https://github.com/louthy/language-ext/wiki/Thinking-Functio...
        
       | Arnavion wrote:
       | >If you need three or more "s to be part of your content, you
       | just use more "s on the outside. The beginning and end just have
       | to match:
       | 
       | This particular form of raw strings would seem to have the
       | problem that you can't start the raw string with a double-quote
       | character. ie if you want:
       | Console.WriteLine(???);
       | 
       | ... to print:                   "Hello world"
       | 
       | ... you can't write:
       | Console.WriteLine(""""Hello world"""");
       | 
       | ... because that'll print:                   Hello world
       | 
       | I suppose the workaround is:
       | Console.WriteLine("""             "Hello world"             """);
        
       | jp0d wrote:
       | What does the future of F# look like with C# becoming more and
       | more functional?
        
       ___________________________________________________________________
       (page generated 2022-11-08 23:02 UTC)