Fork me on GitHub
#clojure-uk
<
2019-10-30
>
dharrigan08:10:49

Good Morning!

dharrigan08:10:47

asking for a "friend"

dharrigan08:10:11

if one was to explore frontend development using Clojure, what's the trend? Reagent?

dharrigan08:10:05

this "friend" is a backend developer who is very put off by frontend shenanighans, but willing to try something "new" provided it doesn't mean spinning up a bazillion different stacks just to do something nice šŸ™‚

danielneal09:10:38

reagent/re-frame is a safe choice for a clojure dev. Iā€™d recommend shadow-cljs for doing the cljs building, eliminates a bunch of pain points and shouldnā€™t mean spinning up a bazillion different stacks

4
danielneal09:10:04

personally imo the exciting edge is React itself - concurrent mode, suspense, hooks etc. If you want to use that, then the library hx makes it easier to interop

danielneal09:10:24

it does a lot less than reagent et al, with the intention that you interop more directly with react

dharrigan09:10:31

thank you! šŸ™‚

dharrigan09:10:37

My "friend" will investigate

danielneal09:10:35

has your ā€œfriendā€ got a project in mind

dharrigan09:10:30

I'll ask šŸ™‚

maleghast09:10:10

Another beautiful day in the Clojureverse

mccraigmccraig10:10:40

+1 for shadow-cljs @dharrigan - so much better

šŸ‘ 8
dominicm11:10:48

My problem with shadow is that it doesn't integrate at all into the JVM.

dominicm11:10:16

It's a separate process, with a separate JVM. Which means I can't just piggieback.

rickmoynihan11:10:29

I spent some time looking into react/cljs frameworksā€¦ and developed workarounds to write isomorphic clojure(script) with SSR. My current feeling is that reagent (and consequently reframe) will eventually be obsoleted by smaller libraries, one of which might be just react itself. The biggest work (Iā€™d like to see done here) is to have an isomorphic hiccup dialect, that supports something like reagent flavoured hiccup. There are lots of hiccup dialects, but none that I have found that are properly isomorphic to clojure rendered HTML and CLJS backed react components. I think fulcro might do this, but fulcro incorporates too much of a framework mindset for my liking. My main problem with reframe is that itā€™s only for SPAs and doesnā€™t work very well for isomorphic apps with SSR. Weā€™re currently building an isomorphic clojure(script) app which does SSR ā€” but to do so we had to implement a bodge to do it. Essentially we use reagent (not reframe), and wrote a simple reagent-flavoured hiccup interpreter that can isomorphically run reagent cljc components on the server on the JVM. A simpler solution in my mind would be to ditch reagentā€™s state management, shim react hooks on the server (super trivial), and use an isomorphic libā€¦ then incorporate whatever pattern/system you want for state/flow etc; if you need it.

rickmoynihan11:10:51

Incidentally @dominicmā€™s post is probably the best post that sums up 1/2 of this desire: https://juxt.pro/blog/posts/react-hooks-raw.html

rickmoynihan11:10:29

If you donā€™t need SSR, you can probably just use reframe. We do a lot of work government and therefore have accessibility requirements. And the best way to meet 90% of accessibility requirements is to ship stuff that works without javascript and can work as such from an initial SSR; as itā€™s much simpler to verify behaviour without having to do full-blown accessibility testing which is very expensive; and even more so if you depend on RIA stuff to make javascript accessible. I suspect weā€™re probably some of the only people who still make sites that arenā€™t completely broken without javascript, and that progressively enhance from that point.

šŸ’Æ 4
acron11:10:15

Re-frame doesn't exclude SSR though; we render large parts of our frontend app on the server šŸ‘

rickmoynihan12:10:58

Sure. It depends if you can split it. It does exclude isomorphic SSR for the reactified SPAs DOM tree.

acron15:10:56

Of course. We're actually researching ways to "switcheroo" between SSR and React - partly for novelty, partly because it'd be useful

rickmoynihan15:10:09

Yeahā€¦ my conclusion was that reframe has too large a surface to shim and events etc donā€™t exist on the server. But you can more easily hack it by dropping the re-frame bells and whistles, and shimming a delay serverside over a reagent atom, and tree-walking the reagent-flavour hiccup server side like itā€™s a mini lisp machine. Thatā€™s essentially what we do. It works quite well, so long as you keep the client side interactions relatively simpleā€¦ i.e. simple enough not to require something like re-frame.

acron15:10:23

It sounds like our solutions are similar, although we opted to shim re-frame and it is mostly just to avoid reader macros all over the place!

rickmoynihan15:10:36

yeah ā€” I wanted to avoid a rats nest of reader macrosā€¦ you can obviously shim with them ā€” but itā€™s too granular. And I wanted to avoid shiming re-frame, as thereā€™s quite a lot of it.

rickmoynihan15:10:20

I also didnā€™t want to change the programming model on the server. The server side should just be ask the DB for some data, coerce it into a value/datastructure of your choice, and apply that to your view template function.

dharrigan11:10:43

I'm not down with all the kewl kids thesedays, what is SSR?

šŸ” 4
dominicm11:10:59

Server side rendering

dharrigan12:10:11

I used Thymeleaf extenstively in the past. Really enjoyed that.

thomas12:10:40

welcome @josh531 šŸ‘‹

šŸ‘‹ 16
folcon15:10:34

@rickmoynihan is the writeup ā€œWhat react hooks mean for clojurescriptā€ a good place to lookover what youā€™ve described? Or just part of it?

dominicm15:10:34

Definitely only part -author

rickmoynihan15:10:51

Yeah itā€™s more an interesting side note about what I think should be the direction for front end. I wanted to do that stuff, but found I couldnā€™t because there isnā€™t an isomorphic implementation of reagent-flavoured hiccup. Though note my requirements are to have an isomorphic app with SSR. If you can do an SPA with only a holding DOM to bootstrap from clientside, then that article is probably all you need, along with (optionally) a clojurescript hiccup implementation.

Ben Hammond15:10:34

ServerSide Rendering then

Ben Hammond15:10:43

(I presume)

šŸ‘ 12
folcon15:10:35

Ok, anywhere thatā€™s got a more complete writeup? Or should I just be paying more attention to the chat ;)ā€¦

dominicm15:10:55

I think it's just speculation šŸ˜„

rickmoynihan15:10:09

Thereā€™s no more complete write up that Iā€™m aware ofā€¦ except possibly in a few comments on our issue tracker somewhere. Itā€™s mainly something I wish existed. I donā€™t think Iā€™m the right person to solve it though. I have a work around, that seems good enough for now.

folcon16:10:14

Ok, good to know =)ā€¦