fulcro 2025-01-25

I haven’t been following for past year or more. Does everyone use hooks these days (react people certainly do)? Should I try to change everything to use statecharts?

If you already have an app working without it, I would say it's too early to convert. If you are making a new app it's probably worth it to figure out the new way of doing things. There are some rough edges still with some rad controls not being automatic, so you will have to really grok how statecharts work in order to add the states needed.

Just to be clear I think statecharts are pretty amazing, it has been very good for me to learn them, and use them. The ability to reason about small chunks of code running in the states has really helped me not only find errors, but adding new states and functionality is much easier. It's just a big learning curve at first.

To give a concrete example, rad.report-options/form-links don't work, they generate dynamic routing links that go nowhere in statechart routing. You have to move to using column-formatters instead:

;ro/form-links          {r.account/email AccountForm}
ro/column-formatters   {:account/name (fn [this v {:account/keys [id name]}]
                                        (dom/a {:onClick (fn [] (ri/edit! this AccountForm id))}
                                               (str name)))
                        :account/active? (fn [this v] (if v "Yes" "No"))}

Can you recommend a learning path for them?

I would start with the statecharts guide: https://github.com/fulcrologic/statecharts/blob/main/Guide.adoc And after that reading the actual paper is what Tony recommended to me: https://www.sciencedirect.com/science/article/pii/0167642387900359

I have a toy ai chat bot I wrote that is all statecharts and runs in babashka if you want to see something that is working. I'm not a programmer by trade so it's probably riddled with bad practices, but it works great for my daily use of it from the command line in linux and macos. https://gitlab.com/michaelwhitford/gail

Hm this paper is like 200 pages

Quite a lot

Yeah it's not easy reading either, I've been through it 3 times or so and still feel like I barely scratched the surface. https://statecharts.dev was also useful to me in the early stages.

ok that’s useful, thanks

That paper's not 200 pages, it's more like 40 with plenty of diagrams. It's a great paper and I do recommend reading it. This video is also a great primer before you get into a bunch of reading https://youtu.be/8TRLk-nKrL0?si=yoCCWLNj-KVC9_SX

Hooks are super convenient for certain use cases where you need to manipulate the Dom and interact with low-level JS stuff in particular. For example, in my new state chart diagramming code, I use hooks to gather up the references to the Dom elements I want to lay out, so that I can then measure them, so that I can then asynchronously call the JavaScript library that is designed to do layout, and then move the elements around. React hooks made that relatively straightforward. On state charts, I'm still actively working on better and nicer integration namespaces. The basics that are there do work quite well, but I'm also trying to make some things like State charts based routing, and integrating that further with state chart invocations where you can co-locate a state chart with a component. I've been rather busy lately, and I've released some sort of alpha quality versions of this so people can get an idea and possibly contribute, but be a little careful about adopting the latest cutting edge thing from me in production, since I may choose the tinker with those apis a little bit still