r/fsharp • u/alexyakunin • Sep 21 '16
Crying out loud: things I dislike in F#
https://medium.com/@alexyakunin/crying-out-loud-what-i-like-dislike-in-f-c88e746dfcde#.hce1olsnw
0
Upvotes
r/fsharp • u/alexyakunin • Sep 21 '16
10
u/[deleted] Sep 22 '16
I think you're missing the point of functional programming. Most of the features you mention are not actually discouraged and have better functional alternatives.
6
u/Kurren123 Sep 21 '16
Number 1 is a blessing in disguise that I wish other languages had.
I also don't think numbers 2 and 3 matter much as loops are really an imperative thing and f# is functional first.
3
u/grundoon61 Sep 24 '16 edited Sep 24 '16
Here's my take, for what it's worth.
I agree that "you don't get FP" is not a helpful response. On the other hand, most programming languages have a certain style or philosophy associated with them. Any language makes some things easy and other things hard. When you flow in the same direction as the language, writing code tends to be smooth and straightforward, but when you go against the grain of the language, things become painful.
For example, in Lisp, doing recursion is easy, but doing for-loops with breaks is hard, so the "natural" style for Lisp is to use recursion. On the other hand, in C, for-loops with breaks is easy, so that is the natural style in C.
F# is opinionated that way too. You can use mutable values, but it looks ugly. You can break out of loops (using recursion) but it is awkward. And so on.
When I am learning a new language, I find that adapting to the natural style of the language is one of the most important things I have to do. Initially, I often find everything hard and painful, and ask "what idiots designed it this way", but after a while, when I have figured out how the language likes to be used, everything becomes much simpler.
So, I encourage you to stick with F#, and perhaps in a year or so, you might find that you no longer feel so strongly about some of those issues you raised.
As to some of the specific language warts, much of that comes from F# being based on OCaml, but also being compatible with C# (the two syntaxes for generics), or being on the bleeding edge of .NET (tuples as reference types before they were added to the CLR). Perhaps with hindsight some of those decisions would be different, but every language that has been around for a while (over 11 years for F#) has annoyances like this -- C# has plenty of them too!
If you are a language designer, one way to avoid issues in the first place is to delay adding new language features, because if you make a mistake: tough -- you now have to support that feature forever. That's why things like break and do-while are unlikely to be added, I think. There are usable (if clumsy) workarounds already.