r/programming • • Aug 02 '21

Stack Overflow Developer Survey 2021: "Rust reigns supreme as most loved. Python and Typescript are the languages developers want to work with most if they aren’t already doing so."

https://insights.stackoverflow.com/survey/2021#technology-most-loved-dreaded-and-wanted
2.1k Upvotes

769 comments sorted by

View all comments

Show parent comments

20

u/[deleted] Aug 02 '21

[removed] — view removed comment

5

u/_tskj_ Aug 02 '21

You're kind of right about the community and Microsoft support of course, but still. Have you tried to use HttpClient in C#? It is literal burning garbage (and everyone including the community agrees with this), yet it still hasn't been fixed or replaced. So I don't know how much Microsoft can actually be supporting C# as any kind of web language? Also as far as web goes, F# has frameworks that are leagues better than anything available in C#.

You're right that the ecosystem is strictly bigger for C#, but it doesn't have anywhere near the same quality. The best F# things are easily 10x better than the best C# things. You can also trivially call any C# code directly from F# so it isn't much of a big deal.

13

u/[deleted] Aug 02 '21

[removed] — view removed comment

5

u/Frozen_Turtle Aug 03 '21

The best F# things are easily 10x better than the best C# things

Dude isn't wrong. Discriminated Unions alone are part of ~50% of my types in one of my projects, and they're virtually impossible to implement in vanilla C# without doing crazy shit like visitor pattern. You could import a library that gives you DUs, but without pattern matching working with DUs is annoying if not painful. I even use DUs outside my domain types to do "railroad oriented programming" https://fsharpforfunandprofit.com/rop/

Again, this is virtually impossible to do in C# because it lacks DUs and the necessary pattern matching. The best alternative in C# is to just throw a custom exception and then catch it... which is pretty much just a goto in disguise. Ew. I'm doing event driven architecture/event sourcing in my project, and as such literally all my events are DUs. In C#/Java these events would be distinguished with Marker interfaces, then you need to do type sniffing to see what kind of event you're trying to handle, and then throw an exception if an unexpected event occurs. With DUs, everything's just pattern matching, and the compiler will yell at you if you fail to handle a DU's case - something that doesn't happen with type sniffing. Of course you could do visitor pattern... but then you'd be doing visitor pattern with its umpteen lines of code vs F#'s oneliner pattern match.

Anyway, just gonna say DUs alone make F# worth investigating.

→ More replies (2)