5 ms·
I played around a lot with F#, and I really like it, but I got to this question of why use F#, and it is actually really hard to come up with a good answer to i
by keithnz 8y ago
I played around a lot with F#, and I really like it, but I got to this question of why use F#, and it is actually really hard to come up with a good answer to it, mainly because C# is really good and the real question in .NET is why use F# over C#. If you program with the same mindset of F# in C# then the differences are not super quantifiable.
In general terms F# as a language is nicer than C#, but my real question is it good enough that you'd want to covert to it if you are mainly a group of C# programmers, and I reached the conclusion that it's probablly not simply becaus C#, in general, is not really that horrible to start with and a lot more people do things in C# and everything in the .NET world is looked at through the lens of C#. I asked a similar question on the F# communities slack, and beyond a few language features ( that are nice! comprehensions and discriminated unions, and more concise syntax with implicit typing ) it's really hard to find a reason. Part of the problem is there is very little in terms of libraries that are unique for F# that massively jump start you in any particular direction. What's more, quite a lot of F# code that fits in with frameworks that were built in C# often just look like C# written in F#. F# code written with F# oriented libraries are really nice and super concise, but it's a bit of a lonely world.
- knocte 8y ago> If you program with the same mindset of F# in C# then the differences are not super quantifiable. I think they are. F# defaults to immutable stuff. Everytime you write anything in C# and forget the word "readonly", you're opening the door for a race condition. Also F# is much more succinct, things that take dozens of lines in C# are just one line in F#, take a look at this quick guide I wrote: https://github.com/knocte/csharp2fsharp https://github.com/knocte/csharp2fsharp
- keithnz 8y agoWhile those are nice things, they don't really bite me in the C# world. There's a lot of fuss about it in the F# world, but it really isn't that big of a problem in my experience. I do like the robustness of it, but in practical terms... it's only a minor point in F#s favor
- knocte 8y agoI guess you say this because you don't really do multi-threading that much or haven't had the urge about parallelising your work yet ;)
- keithnz 8y agoI have, and I do.
- knocte 8y agoCool, now go and read this C# horror story: http://tomasp.net/blog/csharp-async-gotchas.aspx/ http://tomasp.net/blog/csharp-async-gotchas.aspx/
- sk5t 8y agoC# with the good old .NET BCL has excellent support for multithreading, even if some language features could make it even better, there's no need for smugness.
- knocte 8y agoI didn't say that C# doesn't have support for multithreading, I said that C#+multithreading is more prone to race-conditions than F#+multithreading.
- sparkie 8y agoI wish MS had continued support for their "Axum" project, or at least open-sourced it so that it could be continued outside of MS. It was essentially a C# subset with "static" removed and replaced with "isolated", with some other new stuff added. Code was separated into domains and actors, which could be safely used without the concerns on race conditions. Essentially erlang-like programming on .NET
- knocte 8y ago
- S_A_P 8y agoI have never gotten deep into F# but have watched it from a distance for a while. I remember f# 1.0 and thinking this is cool but not fully baked. As f# has grown, I feel like because of or in spite of F#, C# has learned new tricks with each version. While I wish I had time to really ramp up and learn every intellectual curiosity I’ve had, I don’t feel like I have ever had enough friction with c# to “switch”. I’m working with very specific problem sets though so my case isn’t everyones. That said I’m still interested in F# and hope to get into it sometime...
- tokyodude 8y agoThis article convinced me that I wish I was using a language like F# with a similar type system https://fsharpforfunandprofit.com/posts/designing-for-correctness/ https://fsharpforfunandprofit.com/posts/designing-for-correc... That article made me feel like I'm kind of wasting some percentage of my life dealing with bugs that would just disappear if I was using a better language. I don't know what the tradeoffs are though but it did convince me I'm probably missing out on being more productive.
- deleted 8y ago[deleted]