This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-12-21
Channels
- # adventofcode (8)
- # announcements (20)
- # babashka (43)
- # beginners (8)
- # biff (12)
- # calva (2)
- # cider (5)
- # clerk (6)
- # clj-commons (12)
- # clj-kondo (16)
- # clojure (20)
- # clojure-denver (1)
- # clojure-europe (14)
- # clojure-nl (1)
- # clojure-norway (105)
- # clojure-uk (2)
- # clojuredesign-podcast (5)
- # clojurescript (29)
- # datomic (2)
- # hyperfiddle (13)
- # jackdaw (1)
- # jobs (4)
- # jobs-discuss (4)
- # lsp (2)
- # malli (12)
- # pathom (2)
- # pedestal (1)
- # re-frame (22)
- # shadow-cljs (37)
- # squint (28)
- # xtdb (28)
- # yamlscript (4)
Hi all, It's been quite a long while I haven't been in touch with CLJS and lately I've been wondering how the ecosystem was doing. I don't mean at all to sound like I am complaining about anything or trying to raise some sort of alarm, it's just that I have missed a lot and would like to collect your impressions on what's the future of CLJS and what it means for you professionally. Some aspects I'm wondering about: • Closure Library is "going in maintenance mode" • JS keeps growing and evolving into something that just feels "different" (subjective opinion) • For non frontend work, compiling Clojure JVM to native images have become a viable alternative to using CLJS (even preferable I find, although we could argue about it) • For frontend work, although I've been detached from that line of work, there is an ever growing trend towards frameworks like NextJS for which CLJS is simply not a good fit from what I understand ◦ At the expense of those "big" single page applications that were so popular in the recent-ish past • The CLJS ecosystem beyond any doubt has pioneered some ideas that mainstream JS took years to catch up ; but that disparity feels a lot less apparent nowadays, is that competitive advantage fading away? Frankly I haven't properly looked at Squint yet, which to some extent might offer some answers here, but I would suggest scoping the discussion to CLJS as opposed to closely-related alternatives.
I personally do see quite a gap where something like Next / Remix could be. Part of the problem is that the JVM is not a good fit for server (pre)rendering as npm libraries wont work there. I would like to see an answer to those in the ecosystem. They would probably have to build on top of Node/Deno/Bun for the server rendering.
Closure Library being dead doesn't matter at all to CLJS in general. Only maybe matters if you make heavy use of it directly, which most people do not do. cljs.core
itself doesn't use much and could easily be replaced.
JS keeps churning out useless nonsense and breakage for no reason whatsoever. Glad we are not doing that.
for backend I'd always use JVM Clojure. CLJS via node/bun/deno whatever is not even a consideration for me personally, so no argument on that front.
I personally think nextjs and frameworks like it are nonsense as well, and will be replaced by the next next new thing inevitably. That doesn't mean we couldn't benefit from a proper framework for CLJ/CLJS, but it would look nothing like those.
I’m all open for new ideas on that front and am not very happy with Nextjs and the like either. But there (at least currently) is a need for server-side rendered websites/applications and the lack of npm libraries for rendering that content on the JVM is a problem. I’d still use the JVM for the backend but Next etc. can prepare content on a server before delivery for SEO and performance boosts. The node server often gets used only as “frontend server” rather than “backend server”. For nothing more than the rendering . If we can create something alike or (hopefully) better on JVM side i’d be very happy.
I generally like that backend development is much simpler and doesn't need to worry about "updating" the DOM. just spit out some html string, e.g. via hiccup. I like simplicity in that way. IMHO there is no need to bring all the extra complexity of frontend to the backend, just to spit out some html string again. and the now commonly called "island architecture" CLJ+CLJS is almost perfect in many ways, it could use some "sugar" to remove some boilerplate but otherwise its great
I still have some reading to do on island architecture and its state. It does look very promising and I generally like the idea. My doubts come - there too - with SEO support - and maybe how well libraries can be made for it (I got some catching up to do on that front). Context: Projects we have very often are such that take their data from some CMS, display information from it and then enhance some functionality on the website. Island architecture sounds like a perfect fit in general but the CMS data has to be there in the string that is delivered from the server already making it the servers “job” to get that data. Not that it cannot be done, but some complexity even then has to be pushed to the server - unless we ignore the need for SEO.
https://code.thheller.com/blog/shadow-cljs/2023/07/13/the-lost-arts-of-cljs-frontend.html
https://code.thheller.com/blog/shadow-cljs/2023/07/16/applying-the-art-of-cljs-frontend.html
easy way to pass data from the server to the client and for the client to "enhance" the existing html
I've been doing this for a really long time now and things like next.js always look like 10 steps in the wrong direction to me
of course I'm old and used to my ways of doing things, so maybe I'm just not getting it 😛
Hey thanks! looks like you had a lot of thoughts and investigation on that topic. Gotta catch up there and read through in my time!
I’m young (relatively) and next.js always looked like 10 steps in the wrong direction to me too but I felt… a bit stuck with the like
one thing missing for sure in CLJ/CLJS is people writing about it. there is plenty of that on the JS world which makes it look more "alive", when its mostly just noise though
IMO r/Clojure and related places misinterpreted the Closure library’s announcement very hard. Read carefully into the announcement and you will see not much will actually change. > We are committed to retaining the core functionality [of GCL] ... This includes Closure dependency management This is the ONLY part that matters for ClojureScript IMO. The fact that GCL itself is being frozen isnt really any bad news considering GCL is a mature library and a lot of it is easily replaced with the standard library of modern JS anyway.
The real concern for CLJS itself — GCC support for goog modules — is not going away and doesnt seem to be changing any time soon, and as thomas heller pointed out, cljs.core doesnt really depend on GCL, so you should only be concerned if you use goog.ui or something 😛
RE: SSR, #uix does it just fine with JVM-backed rendering; so unless you need something specific on the node side there you can have your cake and eat it https://github.com/elken/uix-ssr-demo
hmm… last time I tried JVM SSR in Helix and Uix I ran into lots of subtle hydration mismatches (e.g. generate IDs for form elements that are stable across server and client renders) that I would not recommend using it over the official React Server APIs at all
you essentially have to reimplement React in the JVM if you want JVM SSR so I have always stuck with Node.js — its unfortunate Macchiato is sparsely documented, but it isnt any harder to go down this route than using Express + React
I tried it with uix but it chokes on any use of an UI library from npm - as the JVM cannot use npm packages. Meaning using SSR on the JVM using uix or helix will cut you out of the use of any libraries from the JS-verse.
Granted it is easy to overreact to GCL going down given Google's history of being cavalier about dropping support. Thanks, overall I was secretly hopping for that sort of answers 😛 @U05224H0W Interesting blog posts, I really like how simple it is. Sure at some point it might be lacking but you did a great job of showing that incremental progression to React without rewriting the whole thing.
I agree with everything thheller said, with one additional point being that web browsers seem to be extremely backwards compatible. The only thing that comes to mind that won't work anymore are the <marquee>
and <blink>
tags.
@U6JS7B99S SSR with Reagent is one of the things I have tried to make simple with https://github.com/chr15m/sitefox. In some of my apps I have Reagent components that are rendered both on the backend (statically to the browser) and also "hydrated" on the front-end. As Thomas said, people in the CLJS world maybe don't write about what they are doing enough, and I've been guilty of that too. Hope to improve in the new year and describe the architecture I am shipping with "full stack" cljs. Example: here's a function which renders a simple Reagent component into the "#app" element of some HTML template string:
(fn view:hello-world [_req res]
(->> [:div "Hello world!"]
(render-into html-string "#app")
(.send res))))
The Reagent component could equally be something which takes args and can be shared by both front-end and back-end code e.g. [my-shared-component some-state-arg]
.a fun holiday experiment: build a library like https://github.com/ryansolid/dom-expressions/ for CLJS that can be used to build a web UI framework on top of any reactive lib without a VDOM. Here's an example working with #reagent's reactive capabilities, 0 react or any other JS 🎉 (I've implemented just enough for this demo 😛 don't get excited)
Well, this is a reactive framework that can sit atop any UI, and here sits atop plain HTML/CSS/SVG, manipulating the DOM itself: https://github.com/kennytilton/web-mx Now what do I do for 🎄? More Flutter/MX videos? I just found out my climbing buddy says they are good background noise for doing the laundry. 🧺 I never aimed so high!