What .NET 10 GC changes mean for developers
181–190 of 253 posts
Re: What .NET 10 GC changes mean for developers
#182Earlier 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.
Re: What .NET 10 GC changes mean for developers
#183Earlier 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.
#!/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
#184I 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?
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
#185A 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…
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
#186Earlier 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.
Re: What .NET 10 GC changes mean for developers
#187I 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…
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
#188Earlier 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.
Re: What .NET 10 GC changes mean for developers
#189Earlier 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...
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
#190Earlier 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.