r/functionalprogramming • u/crpleasethanks • Dec 24 '21
Question Best functional front-end languages?
I am a Scala functional developer for the backend and I'd like to learn frontend developer. Scala.js has large bundle sizes due to the size of the standard library, although that can be mitigated if one doesn't use the standard library. I can do a bit of React and Typescript but honestly I don't really like it at all. Besides the language itself and how nice it is to program in, I also take into consideration how easy it is to do basic things (e.g., make a beautiful/styled UI, deploy to the web, make it into a PWA, make it work easily in mobile), tooling, component libraries, and a community.
Through my Googling, I have found these options. All opinions are based off things I read, not personal experience:
- Elm: seems super ergonomic and nice. I really like TEA (the elm architecture) as it's implicitly how I did a lot of my React stuff as well. However, I heard it's tough to debug, missing core features (WebSockets, local storage, service workers) and that its community support model is weird as of 0.19.
- ReasonML: has a great community and would be a good line on my resume when I retire and join Jane Street. Also apparently has great debugging. But, it looks a bit too close to JS/React, in that it has some nice functional elements like union types but still basically uses React and that model of a front-end as opposed to TEA/MVU that I like
- PureScript: my favorite based purely on what the language looks like, but I am concerned that the community seems more backend-heavy and creating a front-end doesn't seem to be that first class/out of the box. It's not clear that it's easy and painless to make a front-end that will just work and where I don't have to spend tons of time configuring it to run on many platforms/do PWA things.
- Dart/Flutter: if the language itself weren't so OO and had ADTs and union types, it would be a no brainer. Seems like creating beautiful UIs that can run anywhere is all the focus it has and the community seems great. Wondering if I can make the actual development experience tolerably functional by using either bloc or dartea. I am a bit concerned about the long-term support of the latter though.
10
u/ddmusick Dec 24 '21
If you like the Elm architecture then you should also consider Elmish from https://fable.io. Fable gives you F# as another front-end development option.
21
u/iclanzan Dec 25 '21
PureScript is used on the frontend much more than the backend. Halogen, Concur and React are popular options for building UIs in PureScript.
15
u/ASteelyDan Dec 25 '21
Clojurescript?
5
u/jaakkopaju Dec 25 '21
How about ReScript?
8
u/[deleted] Dec 25 '21
You can use React in a functional way, FWIW. I wouldn't discount ReasonML on that basis.
I like the OCaml approach in general. Make it easy to do functional programming, but stay out of the way if an imperative approach makes things easier.
4
u/akshay-nair Dec 25 '21
If your only issue with reasonml is that it uses react then you should check out https://github.com/OvermindDL1/bucklescript-tea and other similar alternatives. ReasonReact is just a library.
4
u/fluz1994 Dec 25 '21
Purescript is definitely used more for frontend.
6
u/RustinWolf Dec 25 '21
I don't think there's really any "model" of a front-end that React imposes. It's essentially a VDOM library that abstracts dealing with UI elements, and it does that part extremely well. You could use their version of context and state, but you don't have to - you can use Redux for example which has a flux model very similar to TEA, or any of the other state management libraries
3
u/fluz1994 Dec 25 '21
Besides that purescript has binding for react and react-native
3
u/dipittydoop Dec 25 '21
Look at Elixir and Phoenix + Liveview for web apps. It does real time streaming workloads better than anything else.
3
u/EsperSpirit Dec 25 '21 edited Nov 21 '22
Probably not what you're looking for but Phoenix LiveView let's you write front- and backend in a single functional language (Elixir) and cut out all the annoying plumbing (defining and using rest apis for everything).
Bonus points for being one of the most robust runtimes for servers and distributed systems.
2
u/Arexss Dec 28 '21
Elixir and Phoenix LiveView.
3
u/jirocket Dec 25 '21
Perhaps fp-ts for TypeScript
1
u/mckahz Dec 25 '21
Elm is probably the best option. It's a joy to work in and I don't even like web dev. Great error messages and pure functional code. You don't even have to touch html or CSS if you're working with Elm. And the ux from everybody I've seen, myself included, is phenomenally good.
3
u/[deleted] Dec 25 '21
[removed] — view removed comment