-
C# now has an increasing amount of syntactic sugar, which often makes the code harder to understand. The same functionality can be written in multiple ways, making the code difficult to maintain. |
Beta Was this translation helpful? Give feedback.
Replies: 10 comments 15 replies
-
I don't know how people can call the features with wide semantic opportunities as syntax sugar. All the syntaxes are making code easy to understand, without the need to find the focus in a lot of boilerplates.
This is a very basic trait for general-purpose language. If any construct has high utilization of same boilerplate, it can have a shortcut syntax. |
Beta Was this translation helpful? Give feedback.
-
What "syntax sugar" are you talking about? Just about every language feature since C# 2.0 is syntax sugar. Taken to the extreme, C# is sugar for IL. |
Beta Was this translation helpful? Give feedback.
-
Languages evolve to solve problems and simplify common patterns. That's true of every programming language still being actively maintained, including languages as old as COBOL, C++, FORTRAN, etc. The fact that there are multiple ways to solve a problem is a strength. |
Beta Was this translation helpful? Give feedback.
-
There are some obvious duplicates syntax-wise, like |
Beta Was this translation helpful? Give feedback.
-
First, the point of syntactic sugar is to make the code [easier] to express and [understand], not to make it harder, and I honestly can't seem to think of one single example of a syntactic sugar in C# making it harder to read the equivalent before (feel free to point them). |
Beta Was this translation helpful? Give feedback.
-
In my opinion, almost all syntactic sugar makes code harder to read. For those who seek code brevity, C++ macros are a classic example, yet their detrimental effects are widely recognized. |
Beta Was this translation helpful? Give feedback.
-
For exmple: Default Interface Methods; And |
Beta Was this translation helpful? Give feedback.
-
This assertion needs evidence. We have not seen this to be the case. Indeed, a lot of the niceties C# added later have demonstrated the opposite. Allowing beginners to learn more quickly; getting them to be able to solve the problems they care about in an easier fashion. There's no special 'underlying' logic that they are generally missing out on. And now there is a nicer, more gradual learning curve to move to the full breadth of the language. Note that this is like complaining that by using C# beginners can't grasp the underlying logic of IL, or assembly, or any lower level concept this all desugars to. That's not relevant as the purpose of these languages is exactly to make it so that you shouldn't have to know that. And it's especially so a beginner can start with the simple concepts and only take on the deeper ones later if they have a need. So the thing you're complaining about here is actually a virtue. |
Beta Was this translation helpful? Give feedback.
-
One must look beyond the initial coding experience to the long-term maintenance costs. People are not compilers, and projects are collaborative. Every concealed detail raises the cost of reading and understanding, making it essential to weigh the trade-offs carefully. That's my opinion translated by AI. I hope more people will join the discussion. |
Beta Was this translation helpful? Give feedback.
I'm pretty sure if you want you can write CIL if you create a project that uses
Microsoft.NET.Sdk.IL
That is about as close as you can get to no syntax sugar while still writing text based code in .NET.