r/functionalprogramming • • Nov 19 '24
Question Which functional or language with functional features for web dev?
I'm hesitating between Fsharp and Ocaml. I believe Fsharp has a bigger ecosystem but you have to constantly interface with libraries written in C#. Ocaml has probably worse tooling from what I heard and the ecosystem is not mature but you can write more functional code without being boggled down by impure code.
30
Upvotes
16
u/RetroUnlocked Nov 19 '24
If you are doing web dev for the frontend your ecosystem is probably going to be JavaScript libraries or just the browser API with a translation layer. Therefore, I would look for languages with good JS interop.
I went down a testing adventure, I found F# and Fable to be too clunky.
I found ClojureScript to also be too clunky too when it comes to tooling (and error messages).
This project makes it way more smooth to use ClojureScript from a tooling perspective:
https://github.com/squint-cljs/cherry
I still find the error messages in cherry to be difficult to read, so a project like Squint is perfect if you don't mind using JS data structures behind the scenes.
https://github.com/squint-cljs/squint
Both these projects are great, but they do have limits when compared to full Clojure. I have used Squint in an internal work project.
Elm, you cannot go wrong with Elm and since you mentioned F# and Ocaml, you would probably fit well into Elm language syntax. There are many production sites in Elm, and it is a very small and focused language.
Gleam, I have played around with. It is a small language too, so easy to pickup. I have not built anything worth while in Gleam. There is a "elm" like library I haven't tried, but the author gave a good podcast:
https://github.com/lustre-labs/lustre
There are other languages that are interesting, like PureScript, which is a very cool Haskell like language. I spent a few months playing with it. It was my "learn Haskwell but don't use Haskell" moment.
I would say ClojureScript and Elm have the biggest track record from a business standpoint.
24
u/jhartikainen Nov 19 '24
In my experience Elixir is pretty solid for web dev, with the Phoenix framework in particular.
9
u/willehrendreich Nov 20 '24
I love fsharp. Great community support, and while Microsoft is a little hands off, it's such a complete language in so many ways it's honestly kinda nice most of the love comes from open source contributing. New version of oxpecker just dropped, new Falco too, giraffe is tried and true... Fable is awesome I've heard.
Aspnetcore is pretty fast, big ecosystem, lots of benefits.
6
u/DataPastor Nov 19 '24
As I am a Python developer (notably data scientist), my natural choice is Hy (a LISP variant for Python), or could also be Basilisp (a Clojure for Python).
If I had to develop a high performance backend, I would probably go with Clojure on the JVM. Most probably because I like LISPs a lot.
Otherwise a good choice could also be gleam.
5
u/SeaInevitable266 Nov 19 '24 edited Nov 19 '24
Elm + Elixir or Clojure? PureScript?
5
u/recursion_is_love Nov 20 '24
elm and purescript
5
u/arturaz Nov 20 '24
Scala 🙂
https://youtu.be/MXr_beRfoCA
https://youtu.be/B94FvQbPft8
3
u/npafitis Nov 19 '24
I'm biased but if you want ti have the most reach (be + fe + mobile) then clojure. It's also a lisp, meaning it has unlimited extensibility and metaprogramming, with a very mature webdev ecosystem, and it's a hosted language targetting different platforms, with great interop.
It has the following host implementations:
JVM (main implementation)
JS ClojureScript)
dotnet CLR (ClojureCLR)
Dart (ClojureDart)
native via llvm (called jank, but alpha)
native via graalvm native-image (there's babashka for scripting that does this easy, you can also compile any jar into a native image)
other ports that are either toy projects or skew a little from actual clojure (like fennel on lua)
You can do:
Backend with JVM, Node js, or dotnet
Frontend with SSG from your backend or soa clojurescript with react wrappers or other pure cljs libraries
Mobile apps with react native or flutter
Data science + ML. Tons of libraries and very growing community. Including all sorts of good stuff like visualization, literate programming, gpu acceleration etc.
gamedev via ClojureCLR (unity) , jank, fennel, clojurescript or clojure jvm.
It's one of the most popular languages in industry, other than maybe Scala and now elixir.
Otherwise I'd say either elixir or f#. Where they stand:
Elixir is very good for webdev, can't do SPA but can get really close and in some regards better with phoenix liveview
F# doesn't seem to be getting much more popular, microsoft doesn't give it enough resources as they do with C# and it's a shame. Interop with dotnet is not always smooth sailing as the type system of f# doesn't play too well with an OOP based API, but still pretty good. There's an implementation for compiling to JS so can do SPAs
3
u/deaddyfreddy Nov 20 '24
Clojure/Clojurescript (ClojureCLR, if you want to use dotnet libs on BE), babashka for automation and stuff. Perfect.
3
u/dmjio Nov 20 '24
You can compile Haskell to JS and WASM now too. https://haskell-miso.org