-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Plan and break big in C# 10 #16103
Comments
Break what? And why? |
Once Eric Lippert some, what could have been done better in C#- |
If every version of C# is required to be compatible with the prior version, 8 will be compatible with 7, 9 will be compatible with 8, and 10 will be compatible with 9, therefore, 10 will be compatible with 7. that's a transitivity relation right there. So there wouldn't be breaking changes as in breaking things even in C# 10. Although, it's possible to relax/restrict some of the rules with warning waves (#1580) in an opt-in manner. In fact, if a breaking change is reasonable enough to take, it's almost always preferable to do it sooner than later, because with every release. more code will depend on the possibly unwanted behavior. Also, analyzers could address most of those today so you don't need to wait until C# 10 to not shoot yourself in the foot. |
Most of those specific "mistakes" are minor and can be easily avoided. You could even render them illegal via analyzers. Removing those from C# wouldn't make it any more modern of a language. Some are just stylistic preferences. I personally prefer |
#MakeCSharpGreatAgain |
I think that instead of setting up some arbitrary deadline/version through which portions of the language will be broken that it would be more useful to have a documented timeline through which specific proposals are introduced and enforced. For example, say anonymous delegates are to go the way of the dodo, the designers could say that in C# 8.0 using an anonymous delegate would result in a warning wave in strict mode, then in C# 9.0 it could result in a warning in all modes and finally in C# 10.0 it would be an error unless you explicitly selected a previous language version. The IDE could assist in guiding developers through these migrations by offering quick fixes to replacement syntax as well as defaulting the language version when opening with a newer IDE if such features are detected. That's assuming that such changes would be considered at all. It doesn't really cost the C# team anything to leave anonymous delegates in the language, but it would cost time and effort to plan for and implement their demise, and in the end the developer isn't really any better off. But with a framework each specific proposal could be considered independently and implemented in due time. |
But 10 is the new 1.0. 😉 |
I don't think that's an option. Once something makes its way to the language it becomes a style and people are pretty strict in that regard. I think it just should be a code style option to prefer lambda if applicable*. *Note that anonymous delegates are capable of ommiting all parameters (even without wildcards).
Swift, for example, did remove C-style I re-read the article and noticed that some of them are not directly related to C# itself, rather, they are actually more related to the fundamental design of BCL. For example, equality; of course analyzers could help to generate the boilerplate but it certainly does not remove the bloat from the code. Another example of this is Other points like empty statement, as mentioned in the article, has actual use cases even in modern code (for example, Roslyn codebase, if you will). So the best thing to do is to leave it as-is and warn in obvious cases that are known to be likely unintended, like in PS: I'm not completely in disagreement with the points mentioned though, for example No. 1 and 6. |
I fully agree, just using it as an example. Probably not a particularly good one given that the anonymous delegate syntax, while considered a mistake in hindsight, is pretty innocuous. A better example might be retiring Either way, my only argument is that any and all arguments to "break" existing language should be considered individually and implemented under a standard timeline, not crammed into some single arbitrary release. |
You mean hypothetically when it's not followed by another valid identifier, right? or completely ditch it? because some people would hate if their fields would no longer be prefixed with an underscore. Edit: Okay.. they actually ditched it, that's wow... okay I can't even put it into words but let's just say that if this change will make it into C# I don't even know how would I react to that simply because I like to prefix all my fields with an underscore. |
I mean as a standalone identifier name. You can still use it as a prefix in an identifier: int _foo = 123; // fine
int _ = 123; // warning
Consumer<Integer> consumer = _ => { }; // error |
@HaloFour Yeah, that's sensible. |
yes we can !!! |
|
Yes. The changes to Java only affect fields/variables specifically named |
Actually I can think of some more fundamental features, which are mostly impossible without hard breaking changes. Most of them are functional language constructs-
The C# can make much wiser decision regarding what to do, given they can break. My proposal to start planning now means the constituting the "legal -> styling error -> warning -> error" route or other measures for easy transition. |
For the most part it's called F# and it already exists. C# is not going to become F#. C# may implement some small subset of those requests eventually, but only those that fit within the expectations of C#. |
@HaloFour Almost all of these are suggested in one way or other. I have updated my list with references. And you know those very well, as you have participated in all of those discussions. Many are barred just because it is a breaking change. So, if we plan beforehand to break at some time in future, there is a lot which can be done. |
@gulshan I made a joke above about 10 being the new 1.0 but really I think that if the C# team had a migration path from one version to another and a tool that would fix the code reliably then maybe they could use this to fix some of the decisions that were made in the past. (such a tool was discussed somewhere...) Another issue is some people are using 3rd-part libraries so they might have to replace these libraries and maybe some of them are no longer maintained. I have a friend that in his company they are still using ASP.NET WebForms on .NET 4.0 and I wrote a component for them using C# 2.0 that I'm not going to rewrite or touch ever and they probably wouldn't replace it unless they will rewrite everything so there's these sort of issues, now, I'm not sure if they are using the latest C# there so maybe it wouldn't be a problem for them at all but for some companies it might. Personally, I want to see arrays covariance, null reference types fixed and immutable types introduced as proposed here #159 and finally type inference for generics and lambdas. |
I agree that, there should be no breakage in IL level. Meaning all libraries/assemblies compiled with any previous version of C# should keep working. And if a 3rd party/not maintained code is being compiled, they should be able to opt out of new warnings and error by mentioning the level of warning/error it is happy with. This will be enabled by the Warning Wave. |
I like this idea of breaking big. Lets change the syntax to the VB syntax. |
Closing as this is not the road the C# team is considering. Back compat is one of our most important features and one we take great pains to maintain between releases. |
Version 10 for anything looks significant. As C# 7 has not been released yet, there is still 6+ years left before C# 10. I propose to make C# a greatest modern language ever in version 10, and to serve the purpose, break big. And start planning for this from now onward, so that everybody can be ready for this, when it happens.
The text was updated successfully, but these errors were encountered: