Hacker News new | ask | show | jobs
by eyelidlessness 1066 days ago
Functional programming is excellent for UI in a FP context. It’s only awkward with eg React because it has to swim in a sea of imperative APIs—the underlying language, render target, and the world of libraries people expect to integrate with it.

Even eliminating/substituting one of those (underlying language) can go a long way towards making FP UI a nicer experience. For example, Reagent[1] in ClojureScript has a state management approach that’s conceptually similar to hooks, but it uses the language’s own reference type semantics in a way that makes it much less awkward. It’s still a challenge to integrate (JS) libraries with side effects, but the community does a pretty good job of wrapping the more popular ones in idiomatic functional APIs.

The concept that ui = function(state) is incredibly powerful if you can stay within the concept. It can have some performance downsides, but even those can benefit from a language/foundation designed for it (eg with Clojure[Script]’s persistent data structures).

1: https://reagent-project.github.io/