4 ms·
There’s having syntactic sugar and there’s whatever the F C# is trying to do. There is so much different syntactic sugar to do the same thing that it’s becomin
by addicted 3y ago
There’s having syntactic sugar and there’s whatever the F C# is trying to do.
There is so much different syntactic sugar to do the same thing that it’s becoming very difficult to onboard new devs to any slightly complex application worked on by multiple devs because invariably the codebase will consist of 3-4 syntaxes doing the same thing which can get really hard to grok.
In an ideal world C# would have gotten rid of a lot of the ceremonial code it had but unfortunately backwards compatibility means that’s not likely to happen.
I wish C# declared a preferred singular syntax for every scenario and provided IDE support to warn when that preferred syntax wasn’t being used.
- cjk2 3y agoI said this elsewhere in the thread, but C# reminds me of The Homer now. https://simpsonswiki.com/wiki/The_Homer https://simpsonswiki.com/wiki/The_Homer No one is sure what problem it is trying to solve anymore. Also the amount of people I see blowing their toes off by not understanding stuff like LINQ and when stuff is executed and materialised into memory is insane. That and entirely not understanding async and any weird side effects like things happening on other threads and losing context and all sorts. Urgh. Im sure C# version 22 or whatever it's on now will allow you to write in plain English at compile time and it'll use CoPilot to compile this to C# which doesn't work.
- christophilus 3y agoLINQ is maybe the only thing I miss from my .NET days. But this was the biggest problem with it. It was easy for newcomers to accidentally introduce horrendous performance by failing to understand how LINQ would translate to the underlying store.
- cjk2 3y agoYeah we broke everything one day with a bad merge conflict resolution. The ToList() ended up before the Where() and after Where()!. Tests passed, integration tests worked. Until we had 2000 front end cluster threads all trying to pull a 2 billion row table.
- bradleyjg 3y agoThere is so much different syntactic sugar to do the same thing that it’s becoming very difficult to onboard new devs to any slightly complex application worked on by multiple devs because invariably the codebase will consist of 3-4 syntaxes doing the same thing which can get really hard to grok.* This is exactly the same story as c++. You’d think we’d learn from history.
- PedroBatista 3y agoIf that gives you any comfort “new” Java is starting to go the same way. Too many smart language people trying to justify their salary.
- thefz 3y ago> There is so much different syntactic sugar to do the same thing Have an example of overlapping syntax?
- ludston 2y agoAll the same: int Foo => 4; private int Foo { get => 4; } private int Foo { get { return 4; } }
- thefz 2y agoDo these all compile to the exact same thing? https://sharplab.io/#v2:CYLg1APgAgTAjAWAFBQMwAJboMLoN7LpHoCWAdgC7oBiA9regLwB86ALANzKHEAOATiQBuAQwoBTUpRr0Y+dAHNxVFuw7oAvtyTF0A4WMnkqdWhjyLl8qAHY1mhzyJPMGKG3QBZABQBKfC5aSBpAA=== https://sharplab.io/#v2:CYLg1APgAgTAjAWAFBQMwAJboMLoN7LpHoCW... Yes, so you are right. I don't get why in IL, the expression bodied member is different, though. Still, makes sense if you have learned C# starting from the most verbose form (3) then (2) was introduced, then (1).
- ludston 2y agoI could probably give 20 different examples of this too. Not all of them would have identical compiler output, but the behaviour would be. E.g. you could add private int Foo { get; } = 4; To the above example given that the behaviour is identical, although the compiled output should be different so I didn't to avoid any nit pickers.
- dagaci 3y agoVisual Studio has build in snippets for boilerplate stuff, so you can type class[tab], ctor[tab], prop[tab] to inject a class contrutor or property into you code. Other IDEs will have similar. Built in ones are here https://learn.microsoft.com/en-us/visualstudio/ide/visual-csharp-code-snippets?view=vs-2022 https://learn.microsoft.com/en-us/visualstudio/ide/visual-cs... If you want to apply a coding style, there are lots of free tools for that even, or you could investigate something like ReSharper from jetbrains. https://learn.microsoft.com/en-us/visualstudio/ide/code-styles-and-code-cleanup?view=vs-2022 https://learn.microsoft.com/en-us/visualstudio/ide/code-styl...