[FAQ] Will Chesnut support Reagent/Quiescent/Rum/etc

This came up in a private email conversation. Since this is a common question I asked if I could share this here as well.

The subject of supporting reagent/quiescent/rum/… has come up before. First off, there is actually a fork of Chestnut for Reagent https://github.com/jellea/acorn by my friend Jelle. It’s been a one time fork though, and he hasn’t really kept up with changes in Chestnut. I’m sure he would be happy to accept contributions.

Chesnut itself is not going to get support for React wrappers besides Om any time soon. The main reason is I want to avoid extra command line options, because we already have a handful, and testing just blows up exponentially. I’d like to guarantee that all combinations work out of the box, including on Heroku, and that’s just really hard if you have dozens of combinations of flags to test for. I started automating testing of Chestnut itself http://plexus.github.io/chestnut/testing.html but it’s also tedious and hard and only in the early stages.

What I’d love to see happening instead in an ideal universe, is that instead of having so much logic in templates, we can have “recipes” that intelligently add the needed stuff to an existing project, based on semantic transformations of source files. I did some initial expirementing here https://github.com/plexus/seed based on the very cool rewrite-clj, and would love to explore that more, but at the moment I barely have the time for basic maintenance on Chestnut.

This would solve two things though: it would make chestnut itself much simpler, because most of it would just be a number of isolated recipes applied in order, and it gives people with existing apps an upgrade path, which is another very common question. As in: you didn’t use --cljx but now you want it? Run lein seed cljx. Or we could even provide “upgrade” recipes, so if you have a Chestnut 0.5 app and you want the goodness from 0.8, you can run lein seed upgrade-chestnut, for example.

I think the seed (add features incrementally to a project) sounds more like functionality that should be part of lein templates proper. Thoughts?

Possibly… I don’t see it happening any time soon though. Leiningen templates at this point are purely text based, they have no knowledge of the structure of the code they are generating. For a LISP this seems a missed opportunity, but it’s pragmatic. Programatically altering code isn’t trivial, especially if the end result needs to look like it was written by humans, e.g. with correct whitespace usage. Simple text-based templating tends to be more intuitive for that. (although it’s also not easy, half of the effort of maintaining Chestnut is checking whitespace).

There’s nothing stopping you from writing your lein templates in a more structural/semantic way though, it doesn’t force you to do textual templating. If rewrite-clj and seed could make that easier then we might start seeing more of that.