Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

the best reason to learn clojure is reagent[1], by far the best way to use react.

shadow-cljs[2] makes using npm libraries easy.

i’ve settled on go backends and reagent frontends as my default setup[3].

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

2. https://github.com/thheller/shadow-cljs

3. https://github.com/nathants/aws-gocljs



Reagent is nice and has been around for about a decade now, but I moved away from it towards very thin wrappers around React[1], because I felt like it was adding too much additional complexity on top of React, which is already quite complex on its own. I wanted a clearer view at what is going on and a simpler way to interop with native React components.

Although it seems to catch up with experimental support of React 18 now, Reagent has fallen behind the latest developments in React and may not benefit from all of its performance optimizations. It is still using class components instead of hooks and there have been concerns that the runtime conversion of Hiccup may drag down performance. I guess in most cases it is not really an issue or in any way noticable, so if you’re not doing any fancy stuff it should be fine. I may even come back to Reagent at some point, since I have to admit that I miss the UI-as-data model with Hiccup.

What I highly recommend, however, is using re-frame[2] for state management. It has also been around for a long time (2014, around the same time Reagent came along) and pioneered some popular ideas in that area. It may seem a bit overwhelming at first, but the docs provide a great introduction and I find the model very clear once you wrap your head around it. At the moment it depends on Reagent, but there are ways around that. [3]

[1]: see Helix (https://github.com/lilactown/helix) or UIx (https://github.com/pitch-io/uix)

[2]: https://day8.github.io/re-frame/

[3]: refx (https://github.com/ferdinand-beyer/refx) is an almost drop-in replacement without the Reagent dependency, but hasn’t been updated in a while. Alternatively, re-frame can be integrated with UIx/Helix by adding some interop code https://github.com/pitch-io/uix/blob/master/docs/interop-wit...


you think reagent is more complex?

i don’t even know what the difference between hooks and classes are, reagent has never given me a reason to care.

if that’s not simplicity, i don’t know what is.

if i were to build a 3d high performance game in react, maybe i’d experiment with dropping reagent. instead i’d just use cpp.

not sure why people want yelp complexity websites to be 3d games.

i love react! i absolutely do not care about the details. never have…


Completely agree. Though I’ve also found an Elixir backend works well because of the power of the Beam VM.


Does your setup do code splitting, SSG? I can't really be shipping a blank html file in 2024, destroys SEO. Otherwise am interested in trying.


no, i’m not interested in seo.

this setup is a single go binary that serves a single pre-gzipped html file from a lambda.

that html file contains inlined js, that is a reagent app.

there is also a favicon. total of 3 files in the lambda zip.

you desired setup is certainly possible though. you’d probably want clojure on the backend though, so you could more easily do SSG.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: