Fork me on GitHub
#clojurescript
<
2023-03-05
>
Dallas Surewood19:03:19

There's a lot of writing about Clojurescripts strengths with react, and how React has adopted some ideas from Clojurescript libraries to improve its performance. How the immutability and LISP syntax makes working with React easy. But has anybody found that using a LISP around javascript has obviated the need for React? Have you been able to leverage language features in a way that makes most of React's usecases unnecessary? Just curious

p-himik19:03:22

Quite a few people have had those thoughts. So far, it has resulted in some new libraries but nothing that would truly take off, for one reason or the other.

Rupert (All Street)21:03:42

The changes to react (ie adding hooks) have meant that clojure wrappers around react can be much lighter weight - e.g. uix and helix are lighter weight and more aligned with react than reagent. They also allow easier interop with the rest of the react ecosystem. I do see some growing criticism of react (and virtual dom in general) around its slow performance and complexity, which makes me think that clojurescript with react could be viable for some apps. One approach to eliminating react that has some momentum is - server side rending with hiccup + clojure - then using https://github.com/bigskysoftware/htmx and https://github.com/bigskysoftware/_hyperscript to add some extra interactivity. This can be much simpler than SPA architecture and does better for SEO.

kennytilton22:03:29

I do not think Lisp is the issue. ("LISP"? You must be as old as me! 👨‍🦯 ). I think the problem with React, ironically, is that they skimped on reactivity in the beginning, went with fake reactivity aka VDOM ("don't worry, just repaint everything, it will be fast"), and eventually came around to rejecting reactivity explicitly, so they could be in control of rendering. They jokingly proposed a name change to ScheduleJS. I digress. The immutability thing does work great with knowing when to setState or blow off rerendering (forget the lifecycle method), but then you have the other React problems anyway, so it is. a mixed blessing. The wonderful thing about CLJS is that it was "done" the day it shipped, and they did a great job with the execution. JS is doing great things lately, but churn. Back to digressing, because they faked reactivity, they struggled with inconsistent state, and to solve that they saddled the world with Flux, which became Redux, which sank the good ship productivity with boilerplate. What makes React unnecessary are truly reactive frameworks such as the original MobX (JS), SolidJS, binding.scala, and my upcoming Web/MX. (You knew there was a catch to this rant.) https://kennytilton.github.io/web-mx-quickstart/

👍 2
pithyless15:03:41

Adding to the original thread question, I think https://github.com/thheller/shadow-grove is one example of asking the question "what if we built a React-like system, but leaning more into ClojureScript idioms". Check out the docs for some reasoning behind the design choices: https://github.com/thheller/shadow-grove/tree/master/doc I think one of the reasons why a lot of the libraries that are experimented on in CLJS-land as alternatives to React never catch on as the one true React-killer, is just due to sheer number of React-specific UI widgets available in NPM. If you build from scratch, you need to build everything from scratch.

p-himik15:03:07

That, and also sometimes design choices do not reflect the needs of real-life projects - for the case of shadow-grove, see https://clojurians.slack.com/archives/C03NTBBSF46/p1675812058640829?thread_ts=1675800678.926309&amp;cid=C03NTBBSF46 and below.

p-himik15:03:45

(The preview makes it seem as if it's about shadow-grove itself, but they way I understood it it's about some particular pieces of it, which is nonetheless important).

geeky_vin22:03:24

Hey Everyone, I'm new to clojurescript but familiar with clojure. I'm confused about reframe and figwheel.main. How are they different? Does reframe use figwheel underneath? Is there a way to write or leverage angular libraries with clojurescript?

kennytilton22:03:20

re-frame is the GUI framework, figwheel.main the build tool. You can also build re-frame apps with Shadow CLJS. I will let others more knowledgable than I address the Angular question, but this looks promising: https://github.com/lynaghk/todoFRP/tree/master/todo/angular-cljs

Grigory Shepelev04:03:09

I disagree on "re-frame is a GUI framework". It's a system to handle web application's state and user-interations, "state handling framework" maybe.

kennytilton13:03:16

@U04R4718WAJ Good point! I always conflated the GUI with the re-frame framework, but that is wrong. And come to think of it, my Matrix-based UI wrappings likewise just manage state, passing through GUI responsibility to HTML, React, RN, Flutter...good insight!