Hacker News new | ask | show | jobs
by mcdermott 2461 days ago
C# (the default .Net lang) has so much ceremony, boilerplate/scaffolding and IDE dependence (IDE programmers) and OOP overhead that it requires 5x more lines of code than the same app in Python or Go. Every time my interest peaks, I take a look leave with the same feeling that it's a dated/bloated OOP relic and would take all the joy out of programming. I've also noticed that most C# programmers don't usually know another language (other than a little JS) and seem totally dependent on Visual Studio; if all they had was a text editor they'd be lost. That's not a good place to be.
9 comments

C# has very minimal boilerplate for a lot of uses. I can throw together a simple CRUD UI app in WinForms in well under a day. Visual Studio handles writing all the data binding code for me, code that I'd have to write myself in any other language.

Using one of the enterprise frameworks, sure, those all have boilerplate, in any language, especially the older frameworks.

And for some tasks, the amount of boilerplate is tiny. I can write out a struct/class with property names matching my JSON, and watch as C# automatically data binds the JSON to a UI. The amount of boilerplate I need to do that in the browser is pretty much identical, or I can learn / figure out some fancy auto-binding toolkit that has its own boiler plate and learning curve.

You can be seriously functional in C#. Passing around lambdas and using functional techniques to manipulate data has been idiomatic C# for over a decade.

> I've also noticed that most C# programmers don't usually know another language

Stereotyping is not good. I <3 C#, but I've written embedded C, C++, JavaScript, Typescript, and Python.

If you go to most corporate dev places, you will find a significant population of single language devs. Same things happen with any popular corporate language. While I agree that learning multiple programming languages makes for better developers, blaming a language for being popular is hardly fair.

Heck the number of developers who have historically only worked in C/C++ was really high for multiple decades.

Under a day ?? Make an app with pyqt5 or kivy and it's under an hour...
> Under a day ?? Make an app with pyqt5 or kivy and it's under an hour...

Last CRUD app I did in WinForms:

1. Auth

2. Real time push updates from my database

3. Platform native looking UI

4. Automatic 2 way data binding between my backing JSON and my UI controls.

I hadn't used C# for ~2 years, I had never used that particular DB library or done any work with JSON in C#.

I got it done in under 4 hours.

If I did it now, yeah, even faster.

The amount of code I wrote is insanely tiny. I wanted some custom date/time formatting stuff so I had to implement that myself.

I just checked the source out, I wrote under 120 LOC total, and that is including the repetitive ~70 LOC I did for handling days of the week and auto-formatting user entered times. (Time sucks, working with time sucks.)

Without that my code would've been limited to:

1. Wiring login button up to sending username/password to the DB 2. Attaching a listener to the DB (C# has had native event handling as a primitive type since forever!) 3. The save button to push stuff to the DB.

Did I have to drag and drop some UI elements onto a page? I sure did. It was rather nice.

WinForms was the go to solution for CRUD apps for a reason. Sure VB6 was probably better at popping CRUD apps out in no time, but after that died out, WinForms was a really good replacement.

It would be cool if you had a demo to show this off. That way you can add a lot more heft to all of your arguments about this subjects, and we can all learn something from it.
Kivy is a broken pile of patches. You must be trolling.
I think you might want to take a slightly different look at it as I have found the opposite.

You also might need to find better C# programmers as I honestly don't know any C# programmers who only know one language or one editor. An awesome IDE is big perk to development. I don't think that should be considered a con.

.NET also has tons of "magic features" like Data Annotations & Attribute Tags for those who want some magic that reduces code & helps get stuff done faster.

JS & other languages reference it when looking to introduce new features.

C# is anything but dated. One could call it bloated as it is one of the most flexible languages with about 10 ways to do anything. That is a strength & a weakness of any language that positions itself as a Swiss army knife type tool that wants to be able to be used everywhere. With C# you can write a lot of nice fairly functional programming style code & OOP code which is a nice perk.

If you're interested in .net and the clr, you could replace c# with f#.

It's the most practical functional language that I've tried. Great for domain modeling and it can used in C# projects.

I also think that c# is too verbose so what I normally do: asp.net core mvc for routing, templating, authentication / authorization, data access etc and then reference an f# project that contains the domain logic. The best of both worlds.

As a complete newbie to .net, I’ve tinkered around with f# for a web app and quickly got frustrated. I like the sound of your approach. Do you have any links / resources for the best way to get started with your approach?
Don't try to start with a web app. I'd recommend looking into Fable (the F# to js compiler). Write f# and run it in the browser, I found it to be a better and faster feedback loop when compared to a .net project.

Play around with the f# language (don't touch the js inter-op) until you can figure out if you actually like f#. Take it slow, it's not just a new language, it's a different paradigm. If you get frustrated, take a break for a few days, watch some f# videos and let the knowledge settle. You'll eventually start having evrika moments.

Look into other functional languages. Maybe you'll like others more. Accumulate knowledge and experience until you start thinking "I could do this a lot simpler in f# (or other lang)".

Then, if you want to use f# in a c# project you just need to learn how to reference a project in another project.

If you want some resources: https://fsharpforfunandprofit.com/video/ some of these videos can get you "hyped up" for functional languages

https://www.youtube.com/watch?v=4YO4XmtPFQw

https://www.youtube.com/watch?v=EPfpO_6uFAA

the entire https://fsharpforfunandprofit.com/ site is a good resource to learn everything from the basics to the wizard level stuff.

As an editor you can use Visual Studio but I'd recommend Visual Studio Code with the Ionide extension.

If your writing a web app I've heard good things about Giraffe (https://github.com/giraffe-fsharp/Giraffe). It seems to even have a project template via the "dotnet" command to get a quick web app running. With F# I personally find Rider or VsCode better IDE's than VS as well. The workflow in F# is more like my experience with scripting languages than something heavy like Java/C#; you don't lose much by going to a more lightweight IDE and a lot can be done via CLI commands and text editing in .NET Core.
If you're writing boilerplate code in C#, it's either because you prefer to be explicit, or because you don't know how to use reflection and dynamic compilation yet. Using C# without reflection is like using Scheme without macros. That said, just like macros lead to DSLs, reflection leads to custom frameworks which then have to be explained to newcomers. It's definitely a cost/benefit thing, and there's an argument against ever using reflection. I can't live without it at this point though. You could say I've 'gone through the looking glass'.

If you're a C# dev who hasn't dug in to reflection yet, the gist is that all the things that the MVC, ORM, DI frameworks do, you can also do. This allows you to build custom frameworks which eliminate boilerplate.

I'm not sure about the comparison to Go as that can get very verbose. Same with Python. And JS is an absolute mess compared to C#/.NET which has a fantastic standard library and many conventions to get going fast.

.Net (and Java) run the Fortune 1000 so there will of course be lots of devs specialized in that. There's nothing wrong with being very good with 1 language and stack when you're paid to be productive for the company. Also you can definitely write C# with a simple text editor if you have to, and VSCode is pretty slim already, but why would you want to when there's such a powerful IDE available?

This sounds like a purity argument about how to be a "real programmer", but I would much rather work with people who are good at what they do and get things done instead.

That was a lot of predispositions. I can say for sure I've never scaffolded anything in C#, I can write a fully functional web app using Notepad++, the different parts of the startup are not hard to memorize, and I can't imagine scaffolding being useful in a console application.

Yeah, it requires more lines to achieve the same thing in other languages, that isn't a pro or con.

And myself personally, I started with Basic, and have used C++, C, Python, Java, JS and C# throughout my career, but I'm also sure you can find many more Python/Go developers who only know Python/Go

It'a unfortunate you don't like the language and I hope Microsoft and the open-source developers continue to add more features so that one day you'll find the joy may developers have found in using C#

> console application

I wrote a console application to splat some addresses in a hex file with version info and keys. Difficulty you want to be able to diff the files afterwards. Was pretty trivial.

I don't get why people don't like IDEs. If you're digging a ditch you're dependent on your shovel (or even better, an excavator). You can do it with your hands, but why would you want to? Just as the shovel magnifies your digging capacity, the IDE magnifies your capacities as a coder.
C# developer here. I picked up Java very quickly... most other OOP languages comes pretty easily as well, after learning the syntax that is.

But I definitely lean on the intellisense of the IDE fairly regularly, I don't think I would completely lost, but it would take me longer.

Break the bubble, talk to more C# devs from different kinds of businesses.
Often, you have to make a serious effort, and that goes for all sides.

"talk to more C# devs from different kinds of businesses"

As a PHP dev who's done C#, Java, Perl, CF, VB and more... I'd rarely find any other PHP devs at our local MS and Java user groups. In a few cases, I was the first "PHP developer" some of these people had ever met.

Java/C# tend to be used in larger enterprises, and they tend to be used by people who are... somewhat more 'corporate' in their life. Go to work, do the job, go home - going to local groups/conferences and socializing with non-work tech folks is often not high on their priority list (family, etc may rank higher).

Maybe it's generalizing some, but it's also a lot of my experience over the past 20+ years. I've met some phenom tech/dev folks at pretty much every event I go to, and I meet more "professional" polyglots today than I did 15 years ago, but I found I had to make an effort to find them (beyond just going to my own favorite events).

Friend of mine mentioned their boyfriend is a corporate dev who programs in C#. Guy doesn't seem to mind that the work is boring and repetitive. Just he gets paid well, doesn't work too hard. Gets 6 weeks of vacation. Which is helpful because his mom and cousins all live in China. And his coworkers aren't a bunch of assholes. (If you're too much of an asshole where he works the boss pushes a button and you get managed out)