That proposal doesn't mention how the union struct handles tearing under concurrent modification. Tearing can cause memory safety issue. Variant A can have an integer field and variant B can have a reference field in the same offset. Tearing can cause it to treat an integer as reference.
Official proposal for Type Unions in C#
261–270 of 315 posts
Re: Official proposal for Type Unions in C#
#262What would the rough timeframe be for seeing adoption of this into the language? I was considering introducing the OneOf library into our codebase, but if this is < a year or so away it might not be worth the effort.
Re: Official proposal for Type Unions in C#
#263Earlier quoted context omitted.
> Java is generally fine enough, but it's a little annoying when I have to do whacky workarounds with wrapper classes to get something that would be done in three lines This is a weird take, given that Java has had ADTs for years Records https://en.wikipedia.org/wiki/Java_version_history#Java_16 Sealed classes https://en.wikipedia.org/wiki/Java_version_history#Java_17 And pattern matching for almost a year https://en…
Most of my jobs until recently have been using Java 11, so I didn’t get to use these things.
Re: Official proposal for Type Unions in C#
#264Earlier quoted context omitted.
This is definitely all just a learning curve on how to do this. None of this is accurate at all. - IntelliJ knows exactly what version of Java you want to run and develop against. - Async is also trivial. Just fire off a virtual thread. - it sounds like your company just picked a bad orm. Any good one is going to escape sql injection when binding variables. You are using binding right? If you to “write it in Java” th…
I'm not worried about SQL invitation so much as I'd rather just query my C# objects instead of writing raw SQL. Yuck.
Re: Official proposal for Type Unions in C#
#265Earlier quoted context omitted.
As of 2020 (when I stopped using F# and .Net in general), the CLR only had inheritance and F#'s enums were actually implemented using inheritance. Eg Some and None were derived classes of Option class. You would see it if you inspected an F# assembly in a decompiler. I don't know if it's still the same today. This C# proposal has anonymous enums using `A or B` syntax which would be hard to make work as sugar over inh…
This is only partially true. Both Some and None were always instances of single FSharpOption class (None is actually not an instance, but null), however custom DUs are indeed compiled into classes with inheritance
Re: Official proposal for Type Unions in C#
#266As a long time C# dev, I feel like I’m missing something about this proposal. The use case for this doesn’t seem well defined to me. Could someone give me a real world example? I’m pretty sure you can implement the example in this proposal by declaring an empty interface and having some record classes that “implement” it. Does that lose something that I’m not seeing?
I think,.net team haven't added discriminited unions yet because it can be effectively simulated with interfaces.
Re: Official proposal for Type Unions in C#
#267Earlier quoted context omitted.
This comment is kind of out of the blue because no one in this thread is advocating for using C# for infrastructure projects. Java is frankly a bad choice for that too these days for a new project, and for the same reason: why would you develop infrastructure in a language that requires shipping a runtime when Rust and Go exist? That made a lot more sense back when C/C++ was your only other real choice. Meanwhile, pl…
Java has been fine for infrastructure projects. There is so much out there that relies on things like elasticsearch, Kafka, or any aws service. Heck even the columnar dbs like pinot and Druid are most likely more used than clickhouse. C# is also fine for this, just way less popular. Recently ms put out https://github.com/microsoft/Garnet when the redis debacle happened. The Apache project has helped put out quite a f…
If you try to install any of the latter, it will be apparent why. (They are poor in usability).
Re: Official proposal for Type Unions in C#
#268Re: Official proposal for Type Unions in C#
#269Re: Official proposal for Type Unions in C#
#270Earlier quoted context omitted.
If it wasn't so linux distribution unfriendly…
What distributions specifically have you had a problem developing on? I've developed on Ubuntu and Pop_OS! in C# for years and never hit a problem.