Live data from Hacker News

Union types in C# 15

devblogs.microsoft.com

211–215 of 215 posts

Re: Union types in C# 15

#211

Earlier quoted context omitted.

> terrible ecosystem .NET is a fantastic ecosystem. Has a decent build and dependency system (NuGet, dotnet run/build, declarative builds in XML). Massive standard library, with a consistent and wide focus on correctness, ergonomics, and performance across the board. You can write everything in many languages, all on the same runtime: business logic in C#; hot paths interfacing with native libraries in C++/CLI; shell…

I work with C#/NuGet on windows every day and my experience is entirely the opposite. The build and dependency systems are an abysmal esoteric, poorly documented mix between csproj files, sln files, random scattered json files, etc. The standard library in my experience sucks and has all sorts of issues, especially around Uris, DateTimes, etc. And the ecosystem itself has such a low quality bar, ironically _especiall…

If you work with old .NET Framework, then maybe I would agree. What kind of issues do you have in standard library or how they are only biting you? Nothing is perfect, but compared to other (popular) alternatives, C#/.NET is the best you can get today.

Re: Union types in C# 15

#212
post #169

Earlier quoted context omitted.

This is the general pattern of how the C# team operates, IME. "Never let perfect be the enemy of good" Very much what I've seen from them over the years as they iterate and improve features and propagate it through the platform. AOT as an example; they ship the feature first and then incrementally move first party packages over to support it. Runtime `async` is another example.

In the meantime I still haven't done any project with nullable references, because the ecosystem has yet to move along. Same applies to ValueTask for async code.

Which part of the ecosystem is blocking your projects from using nullable references? I find them very helpful, but the projects were all newer or migrated to new SDK.

Re: Union types in C# 15

#213
post #169

Earlier quoted context omitted.

In the meantime I still haven't done any project with nullable references, because the ecosystem has yet to move along. Same applies to ValueTask for async code.

Which part of the ecosystem is blocking your projects from using nullable references? I find them very helpful, but the projects were all newer or migrated to new SDK.

What all projects?

It is relatively easy to find corporate libraries, or commercial products that still aren't using it, including Microsoft products still stuck in .NET Framework, or .NET standard 2.0.

If you want name shaming of commercial products with modern .NET, here is one, can provide more.

https://github.com/episerver/content-templates

Re: Union types in C# 15

#214

Earlier quoted context omitted.

FYI small string optimizations are generally implemented using unions.

In Rust? The two I'm big fans of, CompactString and ColdString do not use unions although historically CompactString did so and it still has a dependency on smallvec's union feature ColdString is easier to explain, the whole trick here is the "Maybe this isn't a pointer?" trick, ColdString might be a single raw pointer onto your heap with the rest of the data structure at the far end of the pointer, this case is expe…

My bad I thought it still used `union`s. I guess I'm not very up to date

Re: Union types in C# 15

#215
post #213

Earlier quoted context omitted.

Which part of the ecosystem is blocking your projects from using nullable references? I find them very helpful, but the projects were all newer or migrated to new SDK.

What all projects? It is relatively easy to find corporate libraries, or commercial products that still aren't using it, including Microsoft products still stuck in .NET Framework, or .NET standard 2.0. If you want name shaming of commercial products with modern .NET, here is one, can provide more. https://github.com/episerver/content-templates

You can use dependencies that aren't using nullable reference types in projects that use it. You can enable/disable nullable reference types per file, as it only influences static analysis. There's no runtime difference between a non-nullable reference type and a nullable reference type.
Post reply on HN