by ken · 7y ago · 0 comments
F# is neat, and I see why it's useful if you have a big .NET program already, but for anyone else I don't see why I'd pick it over a more mature (and less Microsoft-centric) functional language like OCaml, SML, or Erlang.
Does F# have any unique features that other functional languages lack, or is .NET integration its killer feature?
But from a language standpoint, here are three unique features
* Type Providers, which let you generate types based on a data source, and tie compilation to the use of that data being correct
* Active Patterns, which are similar to Haskell's View Patterns, and let you tie some arbitrary functionality that ultimately returns an Option into a pattern for neat pattern matching
* Computation Expressions, which let you express, compose, sequence, etc. monadic and monoidal computations in a convenient syntax that's super easy for newcomers to grok. There is also an RFC and WIP implementation that expands these to support applicative constructs
There's more (Units of Measure, universal quantification via Interfaces, etc.) but these three tend to be something people like a lot.
Something that no one has mentioned yet is that F# is now among the fastest functional first programming languages. At least according to (take with a grain of salt) benchmarks like [1] and https://www.techempower.com/benchmarks/
[1] https://benchmarksgame-team.pages.debian.net/benchmarksgame/...
And then of course, parallel computation is an issue with OCaml.
SML: Kind of lacks libraries. I did learn some SML in the past and loved it, but I want a language that will let me be about as productive as Python is. SML lacks a strong ecosystem.
* multi-threading (vs Ocaml) * type providers (perhaps totally unique) * units of measure * active patterns * computation expressions