3 ms·
C# is more popular but actually harder to learn IMO (although this does depend on your prior experience). C# is huge, but F# achieves more with fewer language c
by de_keyboard 5y ago
C# is more popular but actually harder to learn IMO (although this does depend on your prior experience). C# is huge, but F# achieves more with fewer language constructs. F# can also be transpiled to JavaScript, which is a huge advantage.
- rspeele 5y agoI love F#, it's my #1 favorite language by far. But I code in C# at my day job and I gotta say, while I haven't exactly kept count, it's hard for me to agree that F# has fewer constructs. To be fair, much of that comes from the fact that F# has to do nearly everything C# does for compatibility, and have its own stuff too. It leads to a lot of "wait, which tool do I use for this problem?" questions for newbies. * [<Extension>] methods vs `type X with member ...` extensions * let-bound functions vs static methods vs instance methods * operator overloads vs let-bound operators * curried functions vs multi-parameter functions * modules vs static classes * `exception MyError of string` vs `type MyErrorException(msg) inherit Exception(msg)...` * polymorphic data: interface vs abstract class vs discriminated union * Async vs Task * seq { ... } computation expression vs chain of Seq module operations vs. LINQ methods * Option vs Nullable vs Result * Statically resolved generic vs runtime generic (`^a` vs `'a`) * `for i = 0 to 10` vs `for i in 0..10` * `upcast` vs `:>` and `downcast` vs `:?>` * `function` vs `fun x -> match x with` * .fsi files and the syntax for declarations in them * `let mutable` and `<-` vs `ref` and `:=` * sprintf vs interpolated strings with "%d"-style format specifiers vs interpolated strings with FormattableString format specifiers vs String.Format * Code quotations vs linq-style Expression<Func<...,...>> I am very comfortable with F# today and feel I have a solid grasp on how I like to do things. But when I was introduced to it, I was a little overwhelmed, even though I already had familiarity with C# and with Haskell.
- de_keyboard 5y agoThis is a fair point! Although I was more talking about the language constructs that are used for 90%+ of code, which from my own experience is: * let * discriminated unions * records * lists * seq * async * fun Like all languages people actually use, F# has a long tail of advanced features!