-- Leo's gemini proxy

-- Connecting to bbs.geminispace.org:1965...

-- Connected

-- Sending request

-- Meta line: 20 text/gemini; charset=utf-8

Any C# fans in the crowd? I have a large legacy C# codebase at work, and I don't like this language. I feel like this language makes it easy to shoot yourself in the foot, or write code that performs badly and doesn't scale (especially EF+LINQ). And, I find it hard to refactor C# code because of hidden control flow, colored functions (async/not/static/dynamic), 'hidden code' like getters and frequent disruptive changes (across runtime/EF versions). However, some people love it to death and I'd love to hear why.


Posted in: s/programming

๐Ÿ˜ˆ dimkr

2023-08-23 ยท 9 months ago ยท ๐Ÿ‘ Addison, dragfyre


8 Comments โ†“


โ˜•๏ธ johan ยท 2023-08-23 at 19:43:

I've worked with it for seven years now and have learned to like it a little more at least. It is a vast language with lots of backwards compatibility so you will find many anti-patterns like those you mention. But if you stick to the good parts and embrace the rapid development it is not too bad. Lots of good pattern matching have made it in along with other more functional things, like records, and you can mix with F#. Also method-based LINQ, without EF, is very powerful and can scale nicely with good parallel support. Overall the language is extremely flexible and almost everything can be overridden, with side effects, so one must avoid those tempting shortcuts :)


โ˜•๏ธ johan ยท 2023-08-23 at 19:46:

Also everything became much nicer when I discovered Rider and stayed clear of all the Visual Studios. Refactoring with Rider is a charm. VSCode may be free but for a paid developer, that is not a wise cost saving.


๐Ÿฆ€ jeang3nie ยท 2023-08-23 at 22:57:

If it had gained enough traction on Unix (like finishing the gtk3 bindings) I might have tried it. As it stands, doesn't seem very useful for the programming I want to do.


๐ŸŒ™ dmoonfire ยท 2023-08-24 at 05:13:

I got into C# when the Mono project got going and I've been coding it ever since. it is also one of my three primary languages (with Rust and Typescript).


The biggest thing that drew me was the elegance. Coming through the lineage of C, C++, and Java, C# was deliberate where it mattered: you had to call out overrides, not have them happen; single inheritance to avoid those footguns; a BCL that shows it's roots from Delphi and learned from Java's limitations and C++ standards; avoiding JARs and CLASSPATH.


Having a solid type system and being cross platform was a major bonus. it continues to be write once run anywhere for me since the beginning.


I was already using code in properties with a lot of languages already, it has its place. I prefer one class per file because it was easier with Emacs. So it was a good language for me.


I also loved that the type system was so well developed. When it comes to refactoring, I haven't encountered many languages that were so extensive (and as early in in its history). That was before Rosyln and ReSharper but the language's reflection is great.


I also do a lot of meta-coding (source generators, code writing code, reflection) and the language has a lot of tools to assist in that (again, only improving with age).


The last bit is the BCL. There is a lot of deliberate thought that went into it. Lessons learned from Java, Delphi, Visual Basic, Microsoft's Win32 libraries. If you read the design book, you can see a lot of it. Things like deallocating at the same "level" as memory allocations, consistent patterns for event handle, etc.


Yeah, they made mistakes but that is one reason I stick with it. Most of the new features adding over the years have that thought put into it. Yeah, MS drives the process instead of RFCs and MS sucks like every other capitalistic company, but the language itself is the right level if elegance for me and continues to remain that way for decades.


๐Ÿฉ wholesomedonut ยท 2023-08-24 at 18:59:

I enjoy C# because I already spend a lot of time in Powershell when I'm coding nowadays.


And ultimately, all roads point to .NET when it comes to that ecosystem, whether PS or C#. So I can write stuff on the fly with Powershell and then if it goes beyond the scope of even writing modules, I can pivot over to using the C# equivalents of the logic pretty seamlessly.


Though I can second using an IDE that is NOT Visual Studio whenever possible.. it's clunky as hell for the kind of coding I do and I'm not really a fan. Rider is good if you need a whole IDE, and otherwise just spend some time configuring your CLI and text editor like VSCode, Vim, the usual suspects.


๐Ÿ Addison ยท 2023-08-24 at 19:49:

I use it all the time, for work and personal stuff. I wrote a Gemini client called Opal in C#, and Rosy Crow is made with .NET MAUI.


I may or may not have also built a Gemini mirror of The Anarchist Library using C#, which currently runs on a Linux VPS.


In my opinion, it's perfectly performant for a general-purpose GC'd language; moreso than others, depending on the use-case. .NET 6 and 7 have brought a ton of excellent performance optimizations.


If I absolutely need something to be written in C I'll use C; but for 99% of what I do, C# is the ideal tool because it's what I'm most familiar with.


Regarding IDEs, I use Visual Studio 2022 with Vim keybindings and the ReSharper extension.


As with any set of tools, there are some gotchas to be mindful of, but I don't feel that .NET has more than other languages. ReSharper offers static analysis that will highlight most of the typical coding mistakes as you type them, and will often offer to fix those mistakes for you. I think Rider even comes with ReSharper baked-in, since they're from the same vendor.


๐Ÿ˜ˆ dimkr [OP] ยท 2023-08-25 at 06:15:

I use Code (with the C# extension of course) and the dotnet CLI to do the things one normally uses VS for (things like scaffolding of new projects), and the LSP crashes very often and struggles with big projects. Regarding elegance - maybe I can see the elegance you see, but I also find it hard to finish a big refactoring project without leaving any traces of the old code. For example, I don't have a linter for things like x.AddRange(IQueryable) from async code. In general find the type system a bit meh, because I miss Go interfaces and it's static typing but with null and potential gotchas at runtime: more "static" than Python+annotations or TypeScript but less "static" than Go.


๐ŸŒ™ dmoonfire ยท 2023-08-25 at 12:07:

I'll agree there. The second C# supported nullables, I turned that on but its going to take years for all supporting libraries before it is universal (I hope). With old projects, you can only do that one file at a time.


I like to think newer languages learn from previous ones and NULL will continue to be pushed down.


Refactoring legacy code bases is a pain, more so when the previous team didn't have discipline or a good architecture. That is one reason I'm strict with code reviews.


I inherited a 600 kLOC project (C#, 1.1 MLOC total including SQL Server) twelve years ago and I'm still refactoring out "just make it work" code. It's a painful journey, no matter what language.


If you can, I would strong suggest you try out Rider though. Once you get over the learning curve, it has superior refactoring, analysis, and navigation tools.

-- Response ended

-- Page fetched on Sun May 19 13:52:55 2024