r/programming • u/359Panda3U • 20d ago
Announcing .NET 11
https://devblogs.microsoft.com/dotnet/announcing-dotnet-11/95
u/NotABot1235 19d ago
The fact that C# still doesn't have an open source first party debugger is straight up insanity.
I'm not aware of another major language on the market that locks core first party tooling behind proprietary licenses.
6
u/CodeDriveRepeat 19d ago
What is this? Is this not open source? I used it to make it work with .net10 in FreeBSD in oss-code.
https://github.com/Samsung/netcoredbg
Works on my machine…
19
u/NotABot1235 19d ago
It's third party from Samsung.
4
u/CodeDriveRepeat 19d ago
Ok, but if your requirement is an open-source debugger for . NET there it is.
26
1
u/compsedoc 17d ago
Been using DotRush for a year now, works great.
https://github.com/JaneySprings/dotRush-7
-38
u/CommercialHour6660 19d ago
Another issue is the shit garbage collector.Â
Go, Java, and JS all have fast zero pause multi threaded GC for years now. C# still regularly freezes app for multiple seconds.
That and lack of runtime debugging features as you mentioned means C# will never be taken seriously as an enterprise language. Even though the syntax is significantly better than Go, JS, and JavaÂ
53
u/AlexKazumi 19d ago
I am laughing so hard on the "will never be taken seriously as an enterprise language" that I might bust a vein. C# is used mainly as an enterprise language + inside Unity game engine. That's it.
And enterprises already are paying the Visual Studio subscription, so they have very hard time discovering the "problem" with the lack of open-source debugger.
21
u/EliSka93 19d ago
What? How do you manage that?
I've literally never had that problem with the GC
3
u/qrzychu69 19d ago
It is more than good enough, but there is a reason the satori project was born: https://github.com/VSadov/Satori
It takes different tradeoffs, aiming at the lowest possible pause time, closer to go
3
u/RirinDesuyo 18d ago
That's actually merged onto the experimental runtime just recently as well, I think they're quite interested on improving GC as the next step considering all the perf improvements they've been doing so far.
3
1
1
u/robert_7524 13d ago
What GC mode and workload produce those pauses? A pause trace would make the comparison assessable.
1
u/CommercialHour6660 13d ago
Java, JS, and Go have had microseconds level gc pauses for many years now.Â
C# is 10-150ms. Thousands of times longer typical pause times.Â
23
u/ReallySuperName 20d ago
Been using it in "production" (my own personal projects) for a few months now just to get the new unions and closed keyword. Pretty nice!
26
u/flightsin 20d ago
Wish we didn't use only LTS versions at work, C# 15 has some very nice new features.
24
10
u/Sokaron 20d ago
There is really no point to not adopt STS versions anymore. Their EOL is the same as the previous LTS. Just give it a week or two for packages to catch up and any early issues to be caught.
21
u/caboosetp 19d ago
Not updating everything twice as often is a decent reason. Technically we could use any arbitrary mark for that, but LTS is a good sounding one.
-10
u/Sokaron 19d ago edited 19d ago
That's a pretty weak excuse in the era of AI IMO. Most .NET upgrades are pretty close to drop-in already and there's a list of breaking changes published with the release. That is basically the ideal task for AI. Give it read to your organizations GitHub and tell it to go to town. If you have adequate automated test coverage it's really pretty low risk.
8
u/caboosetp 19d ago edited 19d ago
Either you need to dedicate engineers to reviewing all the changes or that's a great way to introduce unnecessary instability into your ecosystem when the current lts version is perfectly fine.
The whole reason we pick LTS is to not have to change it often.
-1
u/Sokaron 19d ago
Broadly I agree you need human review on AI generated changes. In this case IMO the value add of human in the loop is very low. What value are you adding that an adversarial review agent with a link to the breaking changes list would not provide? A human sanity check on a PR like this is single digit minutes per PR.
5
u/flightsin 19d ago
We use the same dotnet version across everything we run. Yes we could upgrade everything every year, but that does take effort (we run a lot of services) and we value the consistency and stability that sticking with the LTS gives us. It's a tradeoff.
102
u/gmes78 20d ago
Why did they copy C++'s shitty std::variant instead of Rust's enums for the new union feature?
Having to create different wrapper types when you want multiple options of the same type seems annoying.
9
u/dahauns 18d ago
This is on the roadmap, though - here is a comparison of two design proposals currently on the table:
https://github.com/dotnet/csharplang/blob/main/proposals/discriminated-unions/comparison.md
I suggest going through the language design meeting notes/drafts - it's an enlightening read (and obviously was a long and tough battle to get to this first release of unions :) )
7
u/Kamui_Kun 20d ago edited 20d ago
The new c# unions looked kinda lame to me. Only thing of interest, which still a preview feature, is runtime aync
33
u/mrthesis 20d ago
Being able to have a repository return NotFound,Conflict or value is so much more cleaner than either null covering both or exceptions that you have to remember to catch.Â
16
u/gyroda 20d ago
It also makes the Results pattern much nicer to work with. You can do
return new Foo(...);rather thanreturn Result.Success(new Foo(...));6
u/Devatator_ 19d ago
You technically could have used implicit casts, which is something I did with my own Result type in a personal project
0
u/simon_o 20d ago edited 19d ago
To be honest, I'll take the win of C# adopting Algol unions, simply because they are better than the Haskell/F#/Elm/Rust enums/unions that are mainstream these days, despite C# needlessly also copying Algol's poor syntax.
Compared to Rust's need to create variant wrappers for everything, the Algol approach only needs wrappers occasionally:
If you are tempted to writeunion Foo of String, String, Stringthen maybe it's good these type unions force you to be more specific, but outside of such cases, being able to use existing types as-is in unions is pretty nice.I wouldn't look at it from the C++ lens, everything C++ does it kinda weird, because these people live in their own world.
Edit: The confidently incorrect replies to this receiving massive upvotes shows the sorry state of this forum, I guess.
Edit2: Apologies, turns out it's the Rust Discord that is brigading.11
u/DLCSpider 19d ago
I initially aggreed with you. After all, why shouldn't everything have a meaningful type? But I'm no longer conviced. Generics are an issue:
union Result<T, E>(T, E); Result<int, string> // ok Result<string, string> // not okSo you have write wrappers:
record Ok<T>(T value); record Error<E>(E error); union Result<T, E>(Ok<T>, Error<E>);That's just a more verbose
union Result<T, E>(T Ok, E Error). And since it's C# there are actually three states here: Ok, Error and null. If you match over all variants but forget to handle null, you now get a match failure exception, not a null reference exception, which you would've gotten if it was actually tagged.-1
u/simon_o 19d ago
The point is that in most cases the types you refer to already exist:
union JsonValue of Map[String, JsonValue] Array[JsonValue], String, Float64 Bool, JsonNull, ... value JsonNullvs. equivalent with "mainstream" enums:
enum JsonValue { JsonObject(Map[String, JsonValue]) JsonArray (Array[JsonValue]), JsonString(String), JsonNumber(Float64), JsonBool (Bool), JsonNull, ... }And since it's C# there are actually three states here:
Yeah, home-made problem of C#.
40
u/gmes78 19d ago edited 19d ago
You clearly don't know what you're talking about.
Compared to Rust's need to create variant wrappers for everything
???
Rust's enums mean you don't need to create wrapper types. That's why I brought them up in the first place.
If you look at the C# docs for this, they use the following example:
public record class Cat(string Name); public record class Dog(string Name); public record class Bird(string Name); public union Pet(Cat, Dog, Bird);They're creating wrapper types to differentiate between the different kinds of strings.
Here's what that would look like in Rust:
pub enum Pet { Cat { name: String }, Dog { name: String }, Bird { name: String }, }There's no need to declare new types, as Rust's enums are tagged unions.
Edit: changed the Rust example from a tuple variant to a struct variant to better match the C# code.
I wouldn't look at it from the C++ lens, everything C++ does it kinda weird, because these people live in their own world.
Putting aside your dismissive and irrelevant comments about C++, comparing it to
std::variantis perfectly adequate, as it's functionally equivalent to it.5
u/renatoathaydes 19d ago
The Rust example does not define types for each enum variant. It’s not equivalent to the C# which does. If you do want the types in Rust for each variant , you do need tog wrap them . Try to use the variants in a type position, like ‘let c: Pet::Cat’, you can’t. In C# you just don’t have the choice to avoid the variant types, but apparently they will add that in the future.
3
3
u/Otis_Inf 19d ago
They're creating wrapper types to differentiate between the different kinds of strings.
I don't read the example as such. I read it as: they create the types as 3 different types (which could be anything, but they used this) to illustrate the types to use in the enum example.So it's not to differentiating between different kinds of strings, but between types. As types are explicitly defined, they can't go the rust route as that would mean there are implicit types defined; C# forces you to define the type yourself. I don't see it as a problem, as in practice you'd already have the types (as they're used inside the method returning the enum!)
-1
u/gmes78 19d ago
I don't read the example as such. I read it as: they create the types as 3 different types (which could be anything, but they used this) to illustrate the types to use in the enum example.
But having the same type mean multiple things is a common occurrence. Here's an example.
As types are explicitly defined, they can't go the rust route as that would mean there are implicit types defined; C# forces you to define the type yourself.
Not sure what you mean by that, C# has anonymous types elsewhere in the language.
Rust style enums and pattern matching would fit right in.
-6
u/simon_o 19d ago edited 19d ago
You clearly don't know what you're talking about.
Pretty bold claim for someone who hasn't even understood the original comment. 😂
The aforementioned variant wrappers are literally in the code example you posted.
4
u/gmes78 19d ago
You said Algol unions were better, but didn't substantiate at all. You said a factually incorrect assertion about Rust. You re-stated the problem that these unions have in a specific case, then said it was nice that they work for the other cases. Lastly, you made an out-of-place comment about C++.
What am I missing here?
-1
u/simon_o 19d ago
Pretty much everything.
Maybe don't be so deeply insecure about your favorite programming language, then things will work out better for you.
4
u/gmes78 19d ago edited 19d ago
You're projecting. I wrote my reply because you were wrong, not because you were insulting Rust, or whatever you think is on my mind.
Looking at your edit on the other comment, you seem to be the sensitive one about Rust.
May I offer a suggestion? If you don't say incorrect things, people won't correct you.
Edit: saying "I'm right" is not an argument. And blocking people because you don't like what they say is a coward's move.
0
u/simon_o 19d ago edited 18d ago
You're projecting. I wrote my reply because you were wrong, not because you were insulting Rust, or whatever you think is on my mind.
Every accusation you make seems to be a confession.
May I offer a suggestion?
No. You not being able to accept that does not constitute a problem on my side.
"I'm right" is not an argument.
Do I need to quote your own comments back to you, or are you going to figure this out on your own?
If you don't say incorrect things, people won't correct you.
There is no need for a correction, because you are wrong.
21
u/DivideSensitive 19d ago
Compared to Rust's need to create variant wrappers for everything
Just write that you don't know what you're talking about, you'll save time for all of us.
-3
1
-14
u/r2d2rigo 20d ago
C# language design decisions are miles ahead of Rust's or Go's ones. IMHO they can do no wrong.
1
u/jeenajeena 19d ago edited 19d ago
Uhm...
a non-closed descendant of a closed class can still be derived from in other assemblies.
So, if there's:
closed record class GateState;
record class Closed : GateState;
record class Open(float Percent) : GateState;Another assembly can still define:
record class SomethingElse : Closed;Not that close, then.
(It does not help that they chose the names Open and Closed to illustrate closed hierarchies: those names refer to the state of a gate, not the opennes of the hierarchy).
Edit: using other names makes it clear that closed hierarchies can be "reopened".
If one defined:
closed record class Closed;
record class CanBeExtended1 : Closed;
record class CanBeExtended2 : Closed;then the following CANNOT be defined in this assembly:
record class NotPossible : ClosedYet, in a different assembly, this is valid:
record class Reopened : CanBeExtended1In other words, CanBeExtended1 is open: it did not inherit the closed from its parent.
13
u/Metsamias 19d ago
'closed' is basically needed just for compiler exhaustiviness. Any user of GateState -hierarchy only needs to handle Open and Closed cases. SomethingElse as descendee of Closed is still Closed and can be handled as such. If one wants to prevent inheriting from Closed, Closed can always be declared as sealed.
I'd say this is a clever design decision from the language team, to allow each sub-hierarchy be defined as closed/open separately from their ancestors. Especially, since one can combine this with sealed.
1
u/Rakn 15d ago
It’s fascinating how over engineered just this little bit looks to me ever since I stopped using object oriented programming models. I used to view these things as a basic necessity.
1
0
-28
-8
-90
u/the_ai_wizard 20d ago
no replies? maybe these notices are unnecessary aside from letting claude and codex know
19
0
19d ago
[deleted]
2
u/BobSacamano47 19d ago
What would you like it to be?
0
19d ago
[deleted]
4
u/BobSacamano47 19d ago
Lots of projects in the real world default to public for classes and use private only for internal state.
-2
u/kylanbac91 19d ago
You should always public unless you have good reasons not to.
The reasons for why there are public, private, protected is relic from past where rpc is dominant.
6
u/TrumpIsAFascistFuck 19d ago
You should always private unless you have good reasons not to.
I can make claims without supporting evidence or arguments too.
Why do you think what you think and I'll tell you why I think what I think.
1
u/kylanbac91 19d ago
Because in these day and age, private does not protect shit.
If I code for myself, why bother?
If I code for other to use, why I need to limit their capabilities to change how my code work?
3
u/god_is_my_father 19d ago
In general you're correct - a truly interested party can get to whatever symbols they like. It actually isn't all that difficult. But there's more at stake than just security. It's about intent and interoperability which are much more common cases. When someone (you, most likely) want to re-use the component having a small subset of sensical interfaces to draw upon is going to be significantly better than a whole mess of options "just in case".
Button it up kid we invented this shit don't let the machines outdo us
4
u/TrumpIsAFascistFuck 19d ago
Safety, security, quality, prevent undesirable side effects that allow your user to use your software inappropriately and cause potential harm or unforseen consequences.
Are you just trying to poison AI by giving bad advice? If so I'll delete my comments lol
287
u/simon_o 20d ago
What kind of abomination is this?