biff

chromalchemy 2025-04-25T16:22:39.773809Z

@andersmurphy I want to try out Datastar from a Biff context. This might be overcomplicating things but I was thinking i could add Datastar to a specific route in my biff app, to try it out in context with the other data and resources already set up in my app. And try things out on both sides as I continue to develop. Looking at Hyperlith examples. Do you see it as possible to interleave these frameworks (per reitit route..) or is that insane and should think more towards forking and maintaining seperate project to try this concurrent development.

chromalchemy 2025-04-25T16:26:19.881189Z

With regard the Hyperlith skeleton: -You mentioned Reitit could easily be used, so that should be compatible with Biff. -The requirement for the reverse-proxy Caddy stuff or the Hyperlith server setup.. wonder if that would not jibe with the Biff setup. https://github.com/andersmurphy/hyperlith/blob/master/examples/README.md -You provide instructions for uberjar. Biff has uberjar setup too, But currently I am using Biff’s default rsync and ssh commands to deploy (soft debloy = reload, and hard deploy = full restart). Do you think that would be compatible? Or is there some magic in the jar build?

2025-04-25T16:30:52.283209Z

I haven't dug into hyperlith too much, but I imagine the main thing for reverse-proxy / server stuff would be to make sure you can compress your responses with brotli (?). Not sure whether that's best done in the reverse proxy or in the app's web server (jetty). In any case it should definitely be possible to set things up with Biff's default production setup. (uberjar shouldn't make a difference either).

chromalchemy 2025-04-25T16:31:00.519589Z

Or maybe Hyperlith is more opinionated than would be compatible with Biff, and I should start with the Datastar clj api?

chromalchemy 2025-04-25T16:32:25.953199Z

@foo Thanks for the feedback. Deployment stuff is my achilles heel. Fractal uncertainty 😵‍💫

🙂 1
2025-04-25T16:41:16.084019Z

I've played around a bit with datastar. I haven't done any CQRS stuff like in hyperlith; just request-response & frontend reactivity. See this commit: https://github.com/jacobobryant/yakread/commit/5b666b0e05fc8e880ab80f27d629cd59a2318e84. e.g.: • https://github.com/jacobobryant/yakread/commit/5b666b0e05fc8e880ab80f27d629cd59a2318e84#diff-789bc3bab35f5f7fc01d57e105e65d2b751b408635584941b89bba813db110c3 -- for the sake of learning/understanding things I opted to write my own helper functions for now rather than use the existing clojure datastar sdk. It has some wrap-sse-response middleware you can stick in your app, then if your ring responses have an :sse key (set to a sequence of "event maps") it'll be converted to an sse/datastar response. There are also some helper functions for constructing event maps, like merge-fragments. If :sse is a lazy sequence then the connection will be held open and the response will be streamed until the sequence is consumed, so you could use that for server push. • https://github.com/jacobobryant/yakread/commit/5b666b0e05fc8e880ab80f27d629cd59a2318e84#diff-0bb863394b5e6d71bda58ab628f03187ffdf9606f6ed683ca01880cb2ec3fc0f here has an example of using signals to toggle an overflow menu. If you're wanting to try out more of the approach in hyperlith (cqrs with a single endpoint that renders everything), not sure how easy or hard that would be--I didn't get there myself. If you have issues doing it in biff you could always play around with a plain hyperlith app first for a bit.

chromalchemy 2025-04-25T16:52:28.703029Z

Awesome! Thanks for the code example. I should probably start small and play with that. (and try hyperlith on the side). Any personal impressions of Datastar v HTMX, in the capacity you would use them in Biff?

2025-04-25T17:00:54.005409Z

Biggest thing that stuck out so far is that it was nice having some tools for frontend reactivity built in. With htmx / hyperscript it did feel a bit more like bubble-gum-and-duct-tape in comparison. datastar has a smaller surface area too which could make it easier to learn. On the other hand, htmx is actually becoming somewhat mainstream (kinda? sorta?), whereas datastar is a niche within a niche--if I end up switching biff over to datastar, I would want to make sure that the benefits are actually large enough to justify going with something less mainstream that fewer people will be familiar with. Maybe if I get around to experimenting more with CQRS then datastar will become more interesting.

chromalchemy 2025-04-25T17:22:10.300739Z

Thanks for the feedback. Ultimately I think I’m looking for more unified programming models. I ranted somewhere else about my personal aversion to having to know the boundaries and stitch together N limited declarative DSL’s, that are often nested in strings and not directly executable like repl-style dev. In this sense i am even deeply suspicious of HTML+CSS! So i was a little bit averse to htmx + hyperscript + alpine.js + custom js (+ css = 5 languages/grammars for rich front end, and counting.. 🫠). Of course this is just the state of affairs on the web stack, that I should probably just embrace, especially since the some of the DSL’s have a pretty limited/simple syntax. But in the meantim… even Datastar bundling the hyperscript + alpine.js layers might be worth it for me. I am also trying out Replicant (+ Biff) in parallel in this regard.

2025-04-25T17:29:22.543089Z

yeah it's definitely worth trying out. Probably can't ever escape all the layers completely, but datastar does shave them down a little bit at least 🙂