←back to thread

Why F#?

(batsov.com)
447 points bozhidar | 6 comments | | HN request time: 0.874s | source | bottom
Show context
raphinou ◴[] No.43547463[source]
F# was for me the best functional language when I looked at rewriting a Ruby on Rails app. I wanted to go with a functional language, as it seems to better fit my thinking and reasoning, and I looked at Haskell, Ocaml, Scala, F#.

Being a stranger to Microsoft technologies, F# was the least likely to be chosen, but easily became the first choice. Haskell's purity made it hard to adopt (for me), Ocaml's ecosystem is subpar (there wasn't even a clear choice for a library to interact with postgresql, I couldn't install the latest version due to its reliance on an obscure tool whose name I forgot and didn't get help on the forum), and Scala is seems complex....

F# was surprisingly easy to get started with. The community is mis-managed by a corporate-minded approach (requiring people to become member of the F# software foundation to get access to the official slack!), but its members are friendly, smart and ready to help. The ecosystem is great with access to all the dotnet libraries (some complain there's a mismatch as most of those are developed for use with C#, but I rarely got in trouble for using them).

There are also great libs and frameworks available. Like https://github.com/SchlenkR/FsHttp to easily interact with http servers, to the point that I find it easier to use than a dedicated library. Or https://github.com/CaptnCodr/Fli , to run commands. And last but not least, https://www.websharper.com/ is the best web framework I have encountered across all ecosystems. Their reactive approach to web ui really allows me to develop complex interfaces in a maintainable way.

This became a longer message than I thought, probably due to my enthousiasm for the language. For complete transparency, the situation is not perfect, and in my experience the tooling is not the best.

If you want more info, I blogged about it a couple of months ago: https://www.asfaload.com/blog/consider-fsharp/

replies(5): >>43547792 #>>43547982 #>>43548045 #>>43548126 #>>43549735 #
breadwinner ◴[] No.43548126[source]
Apache Spark, Delta Lake are written Scala. Being JVM based, it has a large ecosystem. Scala seems like a better choice than F#.
replies(2): >>43548326 #>>43548391 #
innocentoldguy ◴[] No.43548391[source]
I think Clojure is the better option if you want to do FP using the JVM ecosystem. The problem (for me, anyway) I've run into with Scala is that it supports both functional programming and object-oriented programming. Every code base I've worked on in Scala has ended up being a hodgepodge of both, which I find annoying.

However, the best functional programming language is, of course, Elixir. :D

replies(4): >>43548470 #>>43549065 #>>43550751 #>>43552557 #
1. raphinou ◴[] No.43548470[source]
Elixir getting a strong type system is interesting, but watch out for gleam though

But they still miss the computation expressions, which open interesting possibilities like https://github.com/CaptnCodr/Fli and https://github.com/fsprojects/FsHttp

replies(2): >>43548678 #>>43555883 #
2. innocentoldguy ◴[] No.43548678[source]
Gleam lacks lisp-style macros, and its implementations of BEAM and OTP are not exhaustive. For example, Gleam does not support:

- Hot updates.

- Full distributed system support.

– Low-level process manipulation.

- Named processes.

- Advanced supervision strategies.

- Behaviours other than GenServer.

- Type-safe distributed messaging.

- And several other things that I value in BEAM and OTP.

I can't justify trading the full power of BEAM and OTP for static typing. To be fair, though, I've written a lot of code in both statically and dynamically typed languages, and static typing isn't something I value much (to the point that you might say I don't care about it at all :D).

replies(2): >>43549237 #>>43555317 #
3. raphinou ◴[] No.43549237[source]
I knew otp was still suboptimal in gleam, but thanks for mentioning all these additional points!

Funny how preferences and priorities vary among devs, I need my static type system! :-) But note even in static type systems there are variations. I'm talking about an hindley milner type system with its type inference like the one in fsharp

4. felixyz ◴[] No.43555317[source]
My current preference is to use Elixir and its great ecosystem as the shell for my project, and implement the core business logic in Gleam.
replies(1): >>43564959 #
5. ◴[] No.43555883[source]
6. innocentoldguy ◴[] No.43564959{3}[source]
Why? The business logic part is where Elixir outshines Gleam the most, isn’t it? What do you gain by doing this?

(I am genuinely curious and not trying to be snarky.)