Live data from Hacker News

.NET (OK, C#) finally gets union types

andrewlock.net

121–130 of 300 posts

Re: .NET (OK, C#) finally gets union types

#121
post #69

Earlier quoted context omitted.

Winforms, wpf, blazor, maui, avalonia, what are you talking about

Alright. I'm actually fine with WinForms and WPF since my factory floor codes depend on them. But the reality is they aren't expressive enough for modern UIs. XAML is an issue, and WPF is boilerplate hell. But then Blazor is too heavy, MAUI is broken and buggy, Avalonia is underwhelming, and WinUI 3 is an absolute nightmare.

> But the reality is they aren't expressive enough for modern UIs

Other than web tech, what actually is expressive enough?

Re: .NET (OK, C#) finally gets union types

#122
post #97

As a big user and fan of c# but this is a miss, as it always boxes value types.

It always boxes them TODAY. Lately the team has been releasing an MVP and improving stuff (like perf) later on. I wouldn't be surprised if they do the same thing here, as noted in the article you can already work around that yourself.

Re: .NET (OK, C#) finally gets union types

#123
post #66

C# is my strongest and favorite language. That said, it's frustrating that the C# framework ecosystem lacks solid options. MAUI is especially half-baked, and I'm really starting to doubt whether I should continue using XAML

C# used to be my favorite language, but having spent a lot of time in Rust using its algebraic data types + match statements + Option & Result types, then returning to C# to build a few moderately involved libraries, I'm horrified by the enums and null & error handling that I used to deal with all the time. I knew that enums were really just named integer values and nothing more, but I had forgotten than you can buil…

Learning Rust really ruined C# for me. The explicitness saves you from so much defensive programming.

Re: .NET (OK, C#) finally gets union types

#124

Earlier quoted context omitted.

Ok. I'm just trying to understand what code I'm replacing with them. Like I wanna see the before and after in order to gain the same level of excitment as other people seem to have for them. Often the explanations just seem rather abstract which makes it harder to appreciate the win, versus the hideous sort of code that might appear when they're misused.

They are so fundamental to the way I write code I can't imagine ever using a language that does not support them. "Make invalid states unrepresentable."

I might suggest that anyone who wants to make it concrete to go through the article

https://fsharpforfunandprofit.com/posts/designing-with-types...

while visiting https://dotnetfiddle.net and typing the code samples in, experimenting with what manner of changes and additions to the code cause the compilation to fail, and considering how you would leverage those abilities in your everyday development work.

I think this would be even more powerful if you then come back and re-read some of the pro-Union comments in this very thread.

Re: .NET (OK, C#) finally gets union types

#125

Earlier quoted context omitted.

Not OP here - but for me it’s the open source ecosystem. Java just wins in terms of scope, scale, and stability. I love C# the language, but the ecosystem is a ghetto.

I see this reason a lot but what are some actual examples of what is lacking in the .NET ecosystem vs. Java?

Large Apache ecosystem (Spark, Flink, Pinot) is completely missing and third-party SDKS (looking at you AWS) almost ALWAYS have worse SDKs. The java Kinesis consumer and producer libraries are amazing, the ones for C# are simple wrappers around the AWS APIs which means there's a few foot guns waiting for developers to run into, even if they should know better.

Re: .NET (OK, C#) finally gets union types

#126
post #97

As a big user and fan of c# but this is a miss, as it always boxes value types.

It always boxes them TODAY. Lately the team has been releasing an MVP and improving stuff (like perf) later on. I wouldn't be surprised if they do the same thing here, as noted in the article you can already work around that yourself.

But why not do it right the first time. This is an obvious performance pitfall for people that want to adopt this feature. It is bizarre to me after the last decade has been dedicated to performance improvments.

Re: .NET (OK, C#) finally gets union types

#127

Earlier quoted context omitted.

Not OP here - but for me it’s the open source ecosystem. Java just wins in terms of scope, scale, and stability. I love C# the language, but the ecosystem is a ghetto.

I see this reason a lot but what are some actual examples of what is lacking in the .NET ecosystem vs. Java?

Dev tools. The debugger is something for example that Microsoft ostensibly keeps to their own products, and how they totally slaughtered omnisharp.

It killed my daily csharp vscode driver couple of years ago, only now catching back up somewhat, but still unusable for bigger solutions.

That move made me gravitate towards vscodium, and avoiding csharp where possible.

Microsoft's move only recently got more understandable to me, because Cursor and others basically stole vscode to establish their "empire".

Re: .NET (OK, C#) finally gets union types

#128
post #108
post #31

I love C# and in every iteration we're getting more and more features to get C-like performance in a lot of scenarios. C# does it really well because if your problem isn't performance/memory-constrained, you can ignore these features and fallback on the language's natural ease of use.

Do you think by now C# has left Java behind in features and performance?

more than 10 years ago, yes

Re: .NET (OK, C#) finally gets union types

#129

Earlier quoted context omitted.

Not OP here - but for me it’s the open source ecosystem. Java just wins in terms of scope, scale, and stability. I love C# the language, but the ecosystem is a ghetto.

I see this reason a lot but what are some actual examples of what is lacking in the .NET ecosystem vs. Java?

I mean I haven't done much in c# recently, but few examples that c# ecosystem is the subpar in quality

Kafka client library sucks, I mean it was a nightmare to make it stable and there were a few of them.

Pdfbox library

And many other libraries. If you use c# Microsoft libraries only - then you are golden. outside of that its really bad.

At this point I switched to Rust.

Re: .NET (OK, C#) finally gets union types

#130

Earlier quoted context omitted.

It always boxes them TODAY. Lately the team has been releasing an MVP and improving stuff (like perf) later on. I wouldn't be surprised if they do the same thing here, as noted in the article you can already work around that yourself.

But why not do it right the first time. This is an obvious performance pitfall for people that want to adopt this feature. It is bizarre to me after the last decade has been dedicated to performance improvments.

They do this often actually. They will likely watch how people use it and tailor the design to fix that.

As for performance, in lots of use cases it's not going to be a big deal. If you are super sensitive to performance issues then you can just wait, meanwhile everyone else gets to use the new feature. You have to start somewhere and waiting to satisfy everything usually ends up with doing nothing

Post reply on HN