Live data from Hacker News

What .NET 10 GC changes mean for developers

roxeem.com

181–190 of 253 posts

Re: What .NET 10 GC changes mean for developers

#182

Earlier quoted context omitted.

Python and F# are not very similar. A better comparison is OCaml. F# and OCaml are similar. They're both ML-style functional languages.

I'd much rather code F# than Python, it's more principled, at least at the small scale. But F# is in many ways closer to modern mainstream languages than a modern pure functional language. There's nothing scary about it. You can write F# mostly like Python if you want, i.e. pervasive mutation and side effects, if that's your thing.

If Python is the only language you have to compare other languages to, all other programming languages are going to look like "Python with X and Y differences". It makes no sense to compare Python to F# when OCaml exists and is a far closer relative. F# isn't quite "OCaml on .NET" but it's pretty close.

Re: What .NET 10 GC changes mean for developers

#183

Earlier quoted context omitted.

> Usually you combine this with pattern matching and other functional features and the whole thing makes it convenient in the end. That part is missing in C# You mean like this? string foo = result.MatchFirst( value => value, firstError => firstError.Description); Or this? ErrorOr foo = result .Then(val => val * 2) .Then(val => $"The result is {val}"); Or this? ErrorOr foo = await result .ThenDoAsync(val => Task.Dela…

None of your examples use native C# pattern matching. And without language support like e.g. discriminated unions you can't have exhaustive pattern matching in C#. So you'll have to silence the warnings about the missing default case or always add one, which is annoying.

I mean, it's not a stretch to see how you can use native pattern matching with ErrorOr result types.

    #!/usr/local/share/dotnet/dotnet run
    #:package ErrorOr@2.0.1
    using ErrorOr;

    var computeRiskFactor = ErrorOr ()
        => 0.5m; // Just an example

    var applyAdjustments = ErrorOr (decimal baseRiskFactor)
        => baseRiskFactor + 0.1m; // Just an example

    var approvalDecision = computeRiskFactor()
        .Then(applyAdjustments)
        .Match(
            riskFactor => riskFactor switch {
                 "Approved",
                = 0.5m => "Approved with Conditions",
                >= 0.75m and  "Manual Review",
                _ => "Declined"
            },
            errors => "Error computing risk factor"
        );

    Console.WriteLine($"Loan application: {approvalDecision}");
(Fully contained program, BTW)

Here's the OCaml version:

    let compute_risk_factor () = 0.5

    let apply_adjustments base_risk_factor = base_risk_factor +. 0.1

    let approval_decision =
      let risk_factor = compute_risk_factor () |> apply_adjustments in
      match risk_factor with
      | r when r  "Approved"
      | r when r  "Approved with Conditions"
      | r when r  "Manual Review"
      | _ -> "Declined"

    let () =
      print_endline approval_decision

Still not functional enough?...Or you just don't like C#? No point moving goal posts.

Re: What .NET 10 GC changes mean for developers

#184
post #55

I am considering dotnet Maui for a project. On the one hand, I am worried about committing to the Microsoft ecosystem where projects like Maui have been killed in the past and Microsoft has a lot of control. Also XML… On the other hand, I’ve been seeing so many impressive technical things about dotnet itself. Has anyone here used Maui and wants to comment on their experience?

Certainly wouldn't recommend MAUI. Even using it as a simple shell with for Blazor Hybrid was noticeably harder than WPF.

If Microsoft aren't using it themselves in any real capacity, then it's not good bet IMO.

Re: What .NET 10 GC changes mean for developers

#185
post #45
post #27

A hobby audio and text analysis application I've written, with no specific concern for low level performance other than algorithmically, runs 4x as fast in .net10 vs .net8. Pretty much every optimization discussed here applies to that app. Great work, kudos to the dotnet team. C# is, imo, the best cross platform GC language. I really can't think of anything that comes close in terms of performance, features, ecosyste…

Having worked with C# professionally for a decade, going through the changes with LINQ, async/await, Roslyn, and the rise of .NET Core, to .NET Core becoming .NET, I disagree. I certainly think that C# is a great tool and that it’s the best it has ever been. It’s also relies on very implicit behaviour, it is build upon OOP design principles and a bunch of “needless” abstraction. Things I personally have come to view…

What sort of issues do you get debugging?

My experience of .NET even from version 1 is that it has the best debugging experience of any modern language, from the visual studio debugger to sos.dll debugging crash dumps.

Re: What .NET 10 GC changes mean for developers

#186

Earlier quoted context omitted.

This is raw OpenFGA code: await client.Write( new ClientWriteRequest( [ // Alice is an admin of form 123 new() { Object = "form:124", Relation = "editor", User = "user:avery", }, ] ) ); var checkResponse = await client.Check( new ClientCheckRequest { Object = "form:124", Relation = "editor", User = "user:avery", } ); var checkResponse2 = await client.Check( new ClientCheckRequest { Object = "form:125", Relation = "ed…

In the first example, I have to learn and understand OpenFGA, in the second example I have to learn and understand OpenFGA and your abstractions.

Well the point of using abstractions is that you don't need to know the things that it is abstracting. I think the abstraction here is self explaining what it does and you can certainly understand and use it without needing to understand all the specifics behind it.

Re: What .NET 10 GC changes mean for developers

#187

I always found that Jit and GC are a marriage destined to come together, but never found one another entirely. Jit marks the hotloop in code- and thus can tell the GC in detail what a generation really is and how long a generation lifetime really lasts. It can reveal secret cull conditions for long generational objects. If that side-branch is hit in the hot-loop, all longterm objects of that generation, are going to…

Any interpreter could theoretically do those "marking" things, also JIT's do far more than just "bytecompile" hot loops, _all_ cooperative modern GC's are enabled by JIT semantics for things like read and/or write barriers (this helps a GC keep track of objects that keep getting "touched" whilst the GC can work in parallel).

Outside of the mentioned, things like detecting finegrained lifetimes is very very hard and the mentioned escape analysis is an optimization that needs to be capped to avoid the halting problem. (1)

A fairly deep covererage of GC behaviours can found in Bacon's "Unified Theory of Garbage Collection" where the author theoretically connect previous works on tracing collectors and reference-counting systems and show that the optimized variations often existing in a design-space between them. (2)

1: https://en.wikipedia.org/wiki/Halting_problem

2: https://web.eecs.umich.edu/~weimerw/2008-415/reading/bacon-g...

Re: What .NET 10 GC changes mean for developers

#188
post #79

Earlier quoted context omitted.

Arrays have a static fixed size though, making them far less useful in practice. Anything one builds with generics is boxed. Dotnet doesn't have this problem.

Currently you can get around this with Panama, even if the API is kind of verbose for the purpose. Eventually value classes might close the gap, finally available as EA.

Valhalla is over 10 years in the works already and there is still no clear date when or if at all it would be released. It's very difficult to change (or fix) such fundamental things so late in the game.

Re: What .NET 10 GC changes mean for developers

#189

Earlier quoted context omitted.

> C# is, imo, the best cross platform GC language. I really can't think of anything that comes close How about F#? Isn't F# mostly C# with better ergonomics?

Personally I love F#, but I feel the community is probably even smaller than OCaml...

I once got a temporary F# role without any F# experience simply by having 7 YoE with C# and the knowledge that F# exists.

As much as I'd like to do more with it, the "just use F#" idea flaunted in this thread is a distant pipe dream for the vast majority of teams.

Re: What .NET 10 GC changes mean for developers

#190

Earlier quoted context omitted.

In the first example, I have to learn and understand OpenFGA, in the second example I have to learn and understand OpenFGA and your abstractions.

Well the point of using abstractions is that you don't need to know the things that it is abstracting. I think the abstraction here is self explaining what it does and you can certainly understand and use it without needing to understand all the specifics behind it.

More importantly: it prevents "usr:alice_123" instead of "user:alice_123" by using the type constraint to generate the prefix for the identifier.
Post reply on HN