Hacker News new | ask | show | jobs
by osd 3377 days ago
Enjoyed the article. My personal battle with f# has always been searching for what is idiomatic. Everything feels a little bit foreign when you write something in f#. One of the responses the author leaves in reply to a comment is something that I found important the more I used f#, and is something that never really gets said out loud.

"Bottom line: people need to embrace the fact that F# is a hybrid language, and that the primary motivation for using F# is the .NET platform. People interested in FP but not in .NET should just try SML or Haskell. Claiming that F# is “up there” with Haskell or SML is false advertising and ultimately deals unpleasant surprises to people coming either from .NET or Haskell backgrounds."

f# needs to find its place not only in the FP world, but also in the .NET world. That's a very hard thing to do. The language is fun, and I hope it finds its way.

7 comments

IMO that is also true for Scala. And is something that gets criticized every single time I see a reference to Scala on the internet. Yet very few people acknowledge that the problem these languages are trying to solve is complex and that the solution is not always pretty because of the interaction with the platform they're supposed to run on.
I tried to learn FP by doing a project with F# but I felt like I was writing C# code with a different syntax. I would like to give FP another go with a purely functional language but then you also need libraries that enforce that approach. The .Net framework will always lead you to an OO approach.
What I found is that it took me about three tries to actually grasp functional programming. My first F# project started out the same way yours did. It was really OO in an F#. Once I looked at it, I started to realize that it was not the language, but my approach and changed it to fit the FP approach.
In the moment you get a NULL exception with a string (in a call to a .NET function) you understand that F# is part of .NET, for good and bad.
You might like the talk Thirteen ways of looking at a Turtle (https://youtu.be/AG3KuqDbmhM). Scott Wlaschin (https://fsharpforfunandprofit.com) solves the same problem 13 different ways and demonstrates a number of techniques.
F# is a training language. Only know OOP? Great, we can show you how you do the same OOP stuff you like, only using F#.

Want to learn some pure FP? Great, we can show you how to code idiomatically using pure FP.

Want to learn some pure FP but it's tough? Great, code as much in pure FP as you like, then use a big list of "Stuff you shouldn't have to do" as a way to figure out where you need to pick up some more skills.

The reason I'm using F# at the moment is indeed the platform, but not because of .Net; it's because when I tried Haskell on Windows, it didn't work, from which I conclude Haskell is primarily about Unix; I want an FP language where Windows is a first-class, no-question supported platform, and F# fits that bill.
Windows is first-class-no-questions-asked-supported by Haskell.

The same cannot be said about .NET's support for platforms other than Windows.

> Windows is first-class-no-questions-asked-supported by Haskell.

I would have hoped so, but when I tried it recently, the package managers didn't work.

http://stackoverflow.com/questions/42562702/haskell-on-windo...

http://stackoverflow.com/questions/42564296/haskell-on-windo...

> The same cannot be said about .NET's support for platforms other than Windows.

Now that is an interesting question. A few years ago when I tried compiling and running a C# program on Linux/Mono it worked fine - and I'm no Linux expert to be able to debug hairy problems, so it had to work pretty much out of the box - and I'm told things have improved since then, but for all I know, there could be problems I'm not aware of. Have you run into any?

Taking each of those in turn:

The first question is an issue because of Stack assuming something about how git works that might not be true on your system. That's probably because you have an old version of git installed. I had a similarish issue on Gentoo, where it assumes something about gcc that isn't true in the version of gcc I have installed. That's a bug in stack, it's not really Windows-specific. Try uninstalling git, installing the latest version of git, or something like that.

Your second question has nothing to do with Windows. The issue is that when one installs packages globally (as you are doing with cabal in your question), you get into issues if you have two incompatible packages. For example, you want stylish-haskell<0.6 for hfmt, and stylish-haskell requires directory<1.3, but you have 1.3 installed (because of another package).

That's called 'cabal hell'. It's basically just dependency hell for Haskell. It was common in Python before virtualenv became popular, and common in Haskell before stack became popular. In fact, a big reason for using stack is to make it easier for people new to Haskell, and people on Windows, and in particular people new to Haskell on Windows, to use Haskell. The way it gets rid of this issue is that you install dependencies locally, separately, for each project.

At the end of the day, this really sucks for you. I hope you can get it working, Haskell is a lot of fun. You should post the first issue to https://github.com/commercialhaskell/stack/issues/new.

Ah! Thanks, those are actually clearer answers than the ones on stackoverflow. It's true that I'm using a several years old version of git. I might try reinstalling it.
I have the same issues. Writing idiomatic F# is a battle. Things feel always a bit off. Its a nice language that needs more love from ots creators.