Live data from Hacker News

Union types in C# 15

devblogs.microsoft.com

61–70 of 215 posts

Re: Union types in C# 15

#61

Is this the last of the F# features to be migrated into C#? What a missed opportunity. I think really F# if you combine all of its features, and what it left out, was the way. Pulling them all into C# just makes C# seem like a big bag of stuff, with no direction. F#'s features, and also what it did not included, gave it a style and 'terseness', that still can't really be done in C#. I don't really get it. Was a funct…

> big bag of stuff, with no direction. also called general purpose, general style langue > that still can't really be done in C# I would think about it more as them including features other more general purpose languages with a "general" style have adopted then "migrating F# features into C#, as you have mentioned there are major differences between how C# and F# do discriminated sum types. I.e. it look more like it…

"reputation about being unnecessary complicated and obscure to use with a lot of CS-terminology/pseudo-elitism gate keeping doesn't exactly help"

Probably more this than any technical reason. More about culture and installed view points.

I don't want to get into the objects/function wars, but do think pretty much every technical problem can be solved better with functions. BUT, it would take an entire industries to re-tool. So think it was more about inertia.

Inertia won.

Re: Union types in C# 15

#62

Earlier quoted context omitted.

You aren’t giving enough credit to the careful evaluation of how this adaption is happening. So far everything that was added to C# very much reduces the amount of dead boilerplate code other languages struggle with. Really give it an honest try before you judge it based on the summation of headlines.

In isolation, yes, I agree with you. But in the context of the cornucopia of other "carefully evaluated" features mixed into the melting pot, C# is a nightmare of language identities - a jack of all trades, master of none, choose your dialect language. No thanks.

>a jack of all trades

Yes, C# is a jack of all trades and can be used at many things. Web, desktop mobile, microservices, CLI, embedded software, games. Probably is not fitted for writing operating systems kernels due to the GC but most areas can be tackled with C#.

Re: Union types in C# 15

#63
post #31

Earlier quoted context omitted.

Depends on what you mean by ecosystem, it hasn't been trapped on Windows for about a decade now. The variety of third party libraries available is quite good, while the standard library is robust enough that you don't need NPM nonsense like LeftPad and IsEven and IsNumber. Are there particular things about the ecosystem that you worry about (or have heard about)? Biggest complaint I would have is that it seems like m…

Yup, the commercial libraries. That's pretty big. It's nice the standard library has lots of goodies, but I doubt many projects in reality are zero-dependency (The amount of times I hear "the standard lib is great!" seems more to attempt to defend the plethora of commercial libraries, more than anything) The community feels rather insular too? The 9-5 dayjob types with employers who don't understand or embrace open s…

I work with .NET for my day job and my team doesn't use any commercial libraries. I haven't felt limited in any sense by the .NET ecosystem. Nearly everything is open-source, too.

Re: Union types in C# 15

#64

Is this the last of the F# features to be migrated into C#? What a missed opportunity. I think really F# if you combine all of its features, and what it left out, was the way. Pulling them all into C# just makes C# seem like a big bag of stuff, with no direction. F#'s features, and also what it did not included, gave it a style and 'terseness', that still can't really be done in C#. I don't really get it. Was a funct…

>Is this the last of the F# features to be migrated into C#? >What a missed opportunity. Not adding functional features to F# doesn't mean F# would have gained more usage. And if someone wants to use F#, no one is stopping him or her.

I meant, 'missed', in that the entire industry would have been better off if F# or functional programming had won out over object oriented/C# styles.

But, that would takes, schools changing, companies changing, everything. So it was really the installed base that won, not what was better.

We'd have to go back in time, and have some ML Language win over C++ .

Re: Union types in C# 15

#65
I love it, but I see a downside, though: unions are currently implemented as structs that box value types into a Value property of type object. So there can be performance implications for hot paths.

Re: Union types in C# 15

#66

Earlier quoted context omitted.

You aren’t giving enough credit to the careful evaluation of how this adaption is happening. So far everything that was added to C# very much reduces the amount of dead boilerplate code other languages struggle with. Really give it an honest try before you judge it based on the summation of headlines.

In isolation, yes, I agree with you. But in the context of the cornucopia of other "carefully evaluated" features mixed into the melting pot, C# is a nightmare of language identities - a jack of all trades, master of none, choose your dialect language. No thanks.

If it’s not for you I guess that is ok. But from your comment I would also deduct that you never professionally used it. After so many different languages it’s the only one I always comeback to.

The only things that I wish for are: rusts borrow-checker and memory management. And the AOT story would be more natural.

Besides that, for me, it is the general purpose language.

Re: Union types in C# 15

#67
post #21

Is C# a great language trapped in a terrible ecosystem? ie would masses use C# if it existed in another ecosystem? Or is it becoming a ball-of-mud/bad language compared to its contemporaries? (Honest questions. I have never used .NET much. I'm curious)

C# can be used inside Unity game engine. Does this makes it trapped?

Re: Union types in C# 15

#68
post #21

Is C# a great language trapped in a terrible ecosystem? ie would masses use C# if it existed in another ecosystem? Or is it becoming a ball-of-mud/bad language compared to its contemporaries? (Honest questions. I have never used .NET much. I'm curious)

C# is a language that serves many masters and if you trace the origin of its featureset, you can see why each was created. Take the `dynamic` keyword: created to support interfacing with COM interop easier[0]. It serves many audiences so it can feel like the language is a jack of all trades and master of none (because it is) and because it is largely backwards compatible over its 20+ years of existence. That said, I…

>It serves many audiences so it can feel like the language is a jack of all trades and master of none (because it is)

That's why I like it so much. And now, I can write mostly functional code.

>I think it excels in a few areas: web APIs and EF Core being possibly the best ORM out there

It's awesome for web stuff and microservices.

Re: Union types in C# 15

#69

Earlier quoted context omitted.

C# is a language that serves many masters and if you trace the origin of its featureset, you can see why each was created. Take the `dynamic` keyword: created to support interfacing with COM interop easier[0]. It serves many audiences so it can feel like the language is a jack of all trades and master of none (because it is) and because it is largely backwards compatible over its 20+ years of existence. That said, I…

>It serves many audiences so it can feel like the language is a jack of all trades and master of none (because it is) That's why I like it so much. And now, I can write mostly functional code. >I think it excels in a few areas: web APIs and EF Core being possibly the best ORM out there It's awesome for web stuff and microservices.

    > It's awesome for web stuff and microservices.
The gRPC platform support is top notch and seamless and Aspire is just :chefs_kiss:

Re: Union types in C# 15

#70

Earlier quoted context omitted.

You are looking at it from what you know about C#, the goal is how can you reduce (delete) all this to make the language more accessible. For you it may be fine to write: List strs = new List (); And sure if you have been using C# for years you know all the things going on here. But it shouldn’t be an argument that: List strs = []; Is substentionally easier to grasp. And that has been the theme of all changes. The ex…

> The example you point out is the advanced case, someone only needs in a very specific case This is exactly how C++ landed where it is now. Every time it's "you only need to know that syntax if..." well it ends up everyone has to know that syntax because someone will use it and if you're a responsible programmer you'll end up reading a lot code written from other people.

An unbeatable argument, really.

But still there is a difference between learning and mastering.

I recently helped my partner learn for her CS class, and I feel very comfortable arguing that my previous statement holds up.

Mastering? No, in that case I agree with you.

Post reply on HN