Live data from Hacker News

Why F#?

batsov.com

161–170 of 424 posts

Re: Why F#?

#161

Earlier quoted context omitted.

F# is up to version 9 now, and has only improved over time, IMHO. Type providers are a very small part of the story and can be avoided entirely if you want.

I tried F# when it was first released and was not a fan, but it sounds like that impression is a little outdated. C# has come so far in that time it’s almost a new language. I’ll have to take another look.

I don't know what C# has for an interactive prompt nowadays, but F#'s commandline environment, via its fsi.exe, was a revelation back then. It prevented having to have entire solutions to contain test projects to explore different areas of the vast .NET framework, especially when just learning how to use specific methods or objects.

Re: Why F#?

#162
I worked a lot in F# and loved it. I love that it has a lot of great functional ideas without being too pedantic about being 100% functional all the time. (You can have mutating state or just call arbitrary C#.) I took a lot of its insights into my daily python code too. I especially love match.

Re: Why F#?

#163

Earlier quoted context omitted.

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

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

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).

Re: Why F#?

#164
post #57

Earlier quoted context omitted.

Interesting - I'm curious where your thoughts are now on using FP/Scala in 2025? I've always looked at F# with envy as it is a hosted ML that will have extremely battle tested bindings to the important day to day stuff via C# (Darklang's stories of struggling with postgres and AWS when using OCaml was a good cautionary tale on the risks of using less common langs as a startup) Never had a chance to try out Scala but…

It's never been a better time to try Scala if you're interested in the FP side. It's still very much "not opinionated" but the community and ecosystem have benefited from a certain convergence and given up on the "better Java" front which is served by Kotlin more adequately. Of course you can still consume any Java library when needed but it's best to avoid it if possible. Today you can pick between several ecosystem…

Very good summary, thank you! I've mostly stopped writing Scala, but it's still close to my heart.

Re: Why F#?

#165

Earlier quoted context omitted.

Apache Spark, Delta Lake are written Scala. Being JVM based, it has a large ecosystem. Scala seems like a better choice than F#.

I'm sure it can be the better choice, but for me it was not. It seems there was some incompatibility between me and Scala. I find it such a complex language and I never managed to wrap my head around it. As I said F# was my last choice at the start of my evaluation, and Scala was high on the list due to the Java ecosystem. But in the end it didn't work out for me. F# on the JVM would be great though!

Is F# easier to learn than Scala? (I know a bit of Scala (in the old 2.x days) but have no knowledge of F#.)

Re: Why F#?

#166
Two nice things about F# are that you can introduce it into an organisation using the dotnet ecosystem and that you can use all libraries in dotnet, which is a huge advantage over OCaml.

Otherwise, I am happy with OCaml, but F# has also a place in this world.

Re: Why F#?

#167
post #119

Earlier quoted context omitted.

In C#, you can't use the await keyword in a non async method, so I find the argument short sighted.

If your code base is already using async await it's really not an issue.

The point is that it's not actually different from C#, especially once you consider that F# also has task{} blocks that give you a .NET Task directly.

Re: Why F#?

#168
post #51

> Why F#? I'm kinda wondering if anyone here with decent C#/.net experience can give their version of the answer? --- The article really didn't answer its own question. It basically says "How" instead of "Why"... ...Which as someone who's spent over 20 years in C#, and tends to advocate for "functional" style, leaves me with more questions than answers!

Everything is an expression (i.e. its an actual functional programming language), and along with it comes a different way of thinking about problems. Coupled with a really good type system which has discriminated unions, you'll have much fewer bugs.

Pro tip: don't write F# like you would write C# - then you might as well write C#. Take the time to learn the functional primitives.

Re: Why F#?

#169
post #29

I did try F#, but I was new to .NET ecosystem. For 1 "hello world" I was quite surprised by how many project files and boilerplate was generated by .NET, which put me off. I am all for FP, immutable, and modern languages. But then where are the jobs and which companies care if you write good code? Now everyone wants languages which are easy to use with AI, while reducing workforce and "increased productivity". I have…

I like F#'s syntax when all you're doing is pure logic. But when you have to interface with any IO like a database or REST call or something, you have to abandon the elegance of ML syntax and use these ugly computation blocks. In C# you can do something like this: var post = await _postService.getById(id); in F# the equivalent is basically let getPostById id = async { let! post = blogPostService.getPostById id return…

F# is a big language, it is a ML multi paradigm language that interoperates with C# so there is a lot of necessary complexity and many ways to do the same thing. A strong benefit of this is the ability to create a working functional paradigm prototype that can iteratively be refined to a faster version of itself by hot spot optimizing the slower parts with equivalent highly mutable functions while staying within the same language. Similar how one would use python and C++ and over time replace the python code with C++ code where performance is important.

For the specific case of C# use of await it is unfortunate that C# didn't design this feature with F# interop in mind so it does require extra steps. F# did add the task builder to help with this so the 'await' is replaced with a 'let!' within a task builder block.

  let getById(id:int) : Task = failwith "never"
  let doWork(post:string) : unit = failwith "never"
  let doThing() = task { 
    let! post = getById(42); 
    doWork(post); }


Alternatively the task can be converted to a normal F# async with the Async.AwaitTask function.

  let getPostById1(id:int) : Async = async { return! getById(id) |> Async.AwaitTask }
  let getPostById2(id:int) : Async = getById(id) |> Async.AwaitTask 
  let getPostById3 : int -> Async = getById >> Async.AwaitTask

Re: Why F#?

#170

Earlier quoted context omitted.

F# is up to version 9 now, and has only improved over time, IMHO. Type providers are a very small part of the story and can be avoided entirely if you want.

I don't doubt it, but I don't run Microsoft software any more. I've seen enough embrace, extend, and extinguish in my lifetime to not depend on them for my code's execution environment. My current work needs nothing the .NET environment provides that I can't use python's standard libraries to get done, or bash and C if I need to. But I'm lucky to no longer be in a corporate environment, so I don't need to consume com…

FWIW, F# is an open source project controlled by the F# Software Foundation, the .NET Foundation, and Microsoft.
Post reply on HN