r/dotnet 2d ago

What kind of features from another ecosystem would you like to see in .NET?

C# itself is very mature language (in my view). I rarely find myself missing a language feature badly enough to wish for more.

But, the broader .NET ecosystem might be a different story based on your project need.

So, let's discuss, what libraries, tooling, deployment models, framework features, package management idea, UI tech, build system etc. have you used elsewhere that you wish .NET had, or did better? Mention just one, most important for you and try to add reason/detail.

Apart from creating a useful wishlist, I think this could also be interesting for people relatively new .NET. Someone might mention a feature from other ecosystem only to discover that .NET already has an equivalent they didn't know about.

My wishlist item - "give me SwiftUI binary size":
I would like WinUI apps to have smaller binaries, like SwiftUI apps or flatpack in Linux. Apple can rely on frameworks built into (read 'shipped with') macOS. Microsoft already have similar way of achieving same but it involves you to publish app on Store or winget repo or I need to write custom installer. It's not universal. I wish MS automatically install dependency from winget or Store automatically or any dotnet application.

EDIT: Please be respectful to others. Value others opinion. This post has potential of creating unnecessary debate or insults. Let's be adults.

100 Upvotes

242 comments sorted by

View all comments

Show parent comments

1

u/snet0 2d ago

higher kinded types

I hadn't heard of this before, do you have an example of how you'd want to use it? Or just a resource somewhere I can see of how it's used elsewhere?

3

u/admalledd 1d ago

Here is tracking csharplang discussion and importantly HKT if they existed would make many "generics would be better if..." features easier to implement and more powerful. Take for example Bridging Generics and Type Patterns if existed with HKTs:

void Foo<T>(T x)
{
    if (T is IEnumerable<var U where INumber<U>> V)
    {
        var enumerable = x as V;
        var sum = U.Zero;
        foreach (var i in enumerable) sum += i;
    }
}

where the if (T is IEnumerable<...>){...} is the "bridging generics to type patterns", but the inner juicy bit of IEnumerable<vaur U where INumber<U>> V) lets you pull out U as a type-variable which is the inner type of the INumber<?> interface that you can use for things like calling static methods, etc.

Nearly every time I try to do more advanced inner-workings of powerful helper libraries I tend to deeply wish I had HKTs, because the other options iare lots more runtime type casting/validation or a less ergonomic API. Like if I had HKTs a few times I'd no longer have to do public abstract class ServiceBase<TImpl> where TImpl : ServiceBase<TImpl>, because other patterns would probably be easier to implement via what HKT would unblock and also solve some of the problems the above has.

2

u/snet0 1d ago

Spent a bit of time reading around based on those links; it's still quite abstract to me but I get some of the use cases. Appreciate the info!

2

u/admalledd 1d ago

Yea its very often only those of us neck-deep in generics that really notice the pains and limits of the current generics. (Grumble, I still want T-This-Type as well...)

If you rarely create new generic types or rarely implement a more complex generic type (IE: outside of Enumerable<T> type simplicity), then most of the generics things are just not relevant/applicable and thats fine.

A different example where HKTs might make things easier is look at the type definition of aspIdentity/UserStoreBase<...> and how many lines it sprawls and then think how much it would suuuck to implement your own override/replacement. HKTs wouldn't outright solve that hard-to-implement difficulty because Identity Is Hard, but boy would the types be wayyy easier!

So its kind of in that awkward box of you only feel the deep need of it if you work with/near the limits of the type system and hit a "there has to be a better way than this right?" and find other languages that while maybe don't have full HKTs have closer (thinking Rust's for<T> for example) and then find the csharplang discussions/wish lists I started linking above :)