r/functionalprogramming • • Jan 11 '25
Question Based on your experience, what functional languages have good standard library and tooling? My issue with OCaml
I like OCaml, a great language and its tooling has made leaps when it comes to developer experience, but something that I could never put up with is having to resort to alternative standard libraries like Base and Core for basic things to the degree where it's ubiquitous. When it comes to building small utilities, one shouldn't even need to think about the package manager, yet OCaml's own community tells you certain parts of stdlib are arcane and suggest you depend on these 3rd party libraries as the back bone of everything you build.
If you experimented with multiple FP languages, how would rate them based on this?
- stdlib
- tooling
- ecosystem
20
u/v4racing Jan 11 '25
I would recommend giving elixir a try
11
u/kalalele Jan 11 '25
What about using F# instead?
10
u/Rschmukler Jan 11 '25
I’ve played with quite a few and I would recommend you either Clojure or Elixir; my personal language of choice is Clojure.
Clojure:
Elixir:
7
u/smthamazing Jan 11 '25
I've recently got into Scala, and I'm enjoying it a lot. The standard library is good, I especially like the collections: you have both mutable and immutable versions, and operations like
mapalso come in two variants: one is eager, defined on the specific data structure itself, like Vector or List, and it returns a value of the same type. The other is lazy and defined on Iterable. Apart from that, the whole JVM ecosystem is there for you to use.There is some historical baggage in the language due to the need to interoperate with Java, but overall it seems much more expressive than both Java and Kotlin.
Scala 3 is quite stable these days, with build tools (SBT and Scala CLI) constantly improving. Some of my colleagues in fintech (banks, not crypto) are making a move from Java, and we have also started using it for internal gamedev-related tooling.
4
u/jacobissimus Jan 11 '25
The ecosystem/tooling is my biggest pain point with ocaml and Haskell, but I think Haskell tooling is the better if the too.
Typescript tooling is great and the effect/fp-ts community is pretty solid. Clojure is super high up there too.
4
u/Makefile_dot_in Jan 16 '25
i would just not listen to them. the stdlib is like, adequate for small scripts, in my opinion, even if it can be a bit lacking in some areas.
here are some other languages i've tried anyway:
haskell: the stdlib is quite full-featured in terms of computing, though it doesn't really have that much for IO iirc. the tooling is a bit bad, since there's no debugger due to the laziness and so your best bet is
Debug.Trace. the ecosystem is slightly bigger than ocaml's. iirc HLS was a bit more prone to dying than ocamllsp. in any case, it's a pretty good language if your script involves things that benefit from monads.f#: i tried using this language recently with asp.net core. in my opinion, it's quite bad: the language is meant to be ocaml combined with c#, and yet it is worse than both ocaml and c#:
strings can be nullable,Seqs can't, but there's also aNullabletype that can make non-nullable types nullable but it won't work iirc if the type is already nullable which makes for a very frustrating experienceobj, f# doesn't let you match against the actual fields, while c# does. also this means you can't pattern match on exceptions in f#. also f# has no field punningIn_channel.with_open_filein the middle of one.result<'t, 'e> TaskOption.to_result).among functional languages, i normally use ocaml for most small utilities, especially ones with more IO or string processing, and haskell for things where i think its elegance would benefit the program (like nondeterministic algorithms).
3
u/jeenajeena Jan 12 '25
I would say F#. Not simply because it’s a very nice language, but because it benefits from the very generous .NET ecosystem.
2
u/ykafia Jan 13 '25
D has good tooling as we can bind to a lot of C/C++ code.
3
u/[deleted] Jan 12 '25 edited Jan 12 '25
If you're open to an open definition of functional languages, and are looking for languages that support fp constructs and have amazing tooling, I've really been enjoying Rust. My standard for tooling is Go, and Rust is the only fp-like language that has Go level tooling and cohesion. I've written Scala for 6 months and OCaml for about a year outside of work. In the end, I chose Rust despite its higher complexity and verbosity because its tooling and ecosystem is most cohesive AND their lsp is really nice. To top it off, LLMs (like Claude Sonnet 3.5) have produced more working boilerplate Rust code when predicting code for 3rd party libs than for F# and Scala
TLDR; Rust > F# > Scala in terms of most cohesive tooling.
I used Scala to write web api projects. Scala's sbt and mill are both good but having to define dependencies and even think about how to define them in their respective config files is a chore when I'm frequently starting up new libs or projects. It's really nice having all the JVM libs to use.
I also used OCaml to write web api projects and a cli. OCaml's dune is actually getting quite nice. Dune is integrating opam, the most popular ocaml dep manager, directly into itself and wants to feel more like cargo, but it's still in preview. Because I really wanted to use eio, a new 3rd async runtime, I kept hitting dependency issues where some libs aren't ready to use to eio so I have to switch back to lwt. OCaml's winning feature is how fast it compiles though.
F#'s tooling feels nice if you use jetbrain's rider or vscode's ionide. But I like using Zed so having the Rust LSP built into Zed is really nice. ince I'm most used to npm style dep management, cargo maps over it nicely. Access to dotnet libs are great. However it's still a mental cost having to read C# and figuring out how to call it from F# (like Scala calling Java code).
In the end, Rust has the most cohesive tooling but has enough fp features that I feel I can write fp-enough code.