ClojureScript + LiveView

I did not add this to a “this weekend I’ll learn” like my few other journals as I am decided on using this in the long term.

Last I worked with Clojure was first around 2011 (for a few months, to implement a TCP server but other programmers revolted and had to move to Netty + Java) and then ClojureScript in 2014, (with ClojureScript + Reagent, I actually learned Reagent before React), that stretched almost a year, but again, the other developers revolted and wanted to use Angular instead (I know right?), so that was just one project.

Last weekend while trying to embed Alpine 3 to my project, combined with dependa bot alerts, I wondered if I could go without “Webpack” and used “Parcel” instead, in the spirit of science, I did that and it went smooth. Alpine 3 worked too, seems like I needed Webpack 5 or something (but I am past caring about that now). Then it occured to me, hey, remember ClojureScript? Why not try that out, since I had enough JS fatigue for the hour?

I went on to Clojure land and discovered this thing called Shadow CLJS, along with some cool things like Spec, Transducers etc, folks were busy! So, I surfed the web for articles, found one, and with it, I converted my app.js to src/main.cljs, wrapped all my hooks with (deftype)-s, and an hour or two later, it worked!

I did keep the Parcel though, because I did not know how to copy SCSS in ClojureScript (yet).

Last weekend was a blast, sure, I worked hard. But when things failed, they had logical reasoning for it. And while Elixir and the Lisp are different on the surface, the data centric idea remained similar. So it was context switching without context switching for me. I had three hooks, some charts and a heat map, those were promptly converted. Wasn’t as easy as they were when I first made them, but was much more fun, and readable. Good times.

Therefore I decided to stick to it. This project will get more hooks, so more cljs coming along the way. My other project KarmaWerks (A LiveView + DGraph + JS ClojureScript) is getting a revival next month. And my short bike tracking weekend work (MilesToGo - realtime personal location tracking app something I want to track my next month’s vacation/hiking with) is going to keep me occupied during the weekends. All Open Source things! So lots of fun coming our way!

So here’s what I’ll do. I’ll update my work progress in this place. I will work with KarmaWerks AFTER I am done with a smallest workable unit of MilesToGo, the Covid19 dashboard is like somewhat workable already and is used as the experimentation field for the whole thing. I’ll speak on progress of whatever it is I am working with at the time. To remind myself of how things were should I get back to them after 2 years!

And before I leave, my gratitude to the authors of the two articles that helped me set up Parcel and ClojureScript with Phoenix:

  1. https://www.dwolla.com/updates/webpack-to-parcel/ (Setting up Parcel + Phoenix)
  2. https://darioghilardi.com/how-to-setup-a-phoenix-and-clojurescript-project/ (Setting up ClojureScript + Phoenix)

Thank you for getting me set-up without having to scratch my head.

5 Likes