babashka

Casey 2025-07-10T08:51:17.119049Z

The https://github.com/exoscale/cloak/ library doesn't work in babashka because it does deftype with clojure.lang.IPending (https://github.com/exoscale/cloak/blob/49c8ab0fc54725d363b6a47ac1f887deef6f55d4/src/exoscale/cloak.cljc#L8-L17), which results in the error defrecord/deftype currently only support protocol implementations, found: clojure.lang.IPending is there any easy fix for this that could be proposed to the cloak maintainers?

mpenet 2025-07-10T09:10:16.892809Z

I suppose that could be excluded for bb

mpenet 2025-07-10T09:10:31.865909Z

with a reader conditional

Casey 2025-07-10T09:19:24.301609Z

By adding a :bb () branch before the :clj? It would mean that Secret loses its derefable powers in babashka, but I guess that is an ok trade off?

az 2025-07-10T09:40:00.962009Z

In babashka.fs there are file and path . From the source code I see they correspond to java.io.File and java.nio.file.Path respectively. Sadly I'm not familiar with Java, only know nio is newer than io from some quick search. So, is path preferred than file ? Can they be used interchangeably?

Kirill Chernyshov 2025-07-10T09:43:51.731529Z

Both are quite useful. For example you can't check if Path is executable

az 2025-07-10T09:49:27.112559Z

Tested it in bb, seems executable? also works for path ?

user=> (require '[babashka.fs :as fs])
nil
user=> (def p (fs/path "."))
#'user/p
user=> (fs/executable? p)
true

az 2025-07-10T09:50:43.653949Z

Oh I see.. it recognize a directory as executable.

az 2025-07-10T09:52:45.721509Z

But using file is the same?

user=> (def f (fs/file "."))
#'user/f
user=> (fs/executable? f)
true

Kirill Chernyshov 2025-07-10T09:54:28.603869Z

I mean Path does not have isExecutable method and I use it as an example. Some functions that expects a File might don't work properly if you give it a Path instead of File

Kirill Chernyshov 2025-07-10T09:58:07.271789Z

tldr; path is to represent a destination to a file. file is to represent actual file

😯 1
borkdude 2025-07-10T10:29:36.433199Z

File and Path can be used interchangeably in babashka.fs. Path is a later introduction in the Java standard library. The vanilla Clojure standard library is designed around File when Path wasn’t around yet

👍 1
Casey 2025-07-10T09:43:20.965899Z

@mpenet would you prefer I open a github issue on cloak?

borkdude 2025-07-10T10:01:09.967669Z

Please use a thread when discussing the same topic

👍 1
mpenet 2025-07-10T11:47:57.394189Z

yes, an issue is fine

👍 1
2025-07-10T17:00:03.431029Z

Hi, in a bb repl I am trying to (import java.io.Flushable) and get java.lang.Exception: Unable to resolve classname:. What am I doing wrong?

✅ 1
borkdude 2025-07-10T17:12:25.483729Z

I guess this class isn't part of babashka yet. Can you provide a fuller snippet of code of what you're trying to do? I might be able to support it in the next release

2025-07-10T17:14:07.861599Z

We're getting ready to release v1 of the datastar SDK and I wanted to test if I could use it with bb. I use the this interface in just 1 place in the code I believe...

borkdude 2025-07-10T17:14:37.344639Z

do you have a link to the code?

borkdude 2025-07-10T17:19:59.664659Z

ok, this can be easily fixed in bb. but using this dep won't work right now:

com.aayushatharva.brotli4j/brotli4j {:mvn/version "1.18.0"}

2025-07-10T17:22:04.819449Z

The actual brotli integration we provide is separate from the core SDK and the http-kit impl.

borkdude 2025-07-10T17:23:06.520159Z

ok great. I'll add Flushable and will try the code again

2025-07-10T17:24:42.728789Z

With some luck that's the only java interface I use that is missing.

borkdude 2025-07-10T17:31:21.870909Z

the next thing I''m hitting after adding Flushable is:

$ clj -M:babashka/dev -e "(require 'starfederation.datastar.clojure.api 'starfederation.datastar.clojure.adapter.http-kit)"
----- Error --------------------------------------------------------------------
Type:     clojure.lang.ExceptionInfo
Message:  defrecord/deftype currently only support protocol implementations, found: Closeable

borkdude 2025-07-10T17:31:38.477279Z

----- Context ------------------------------------------------------------------
71:
72: ;; -----------------------------------------------------------------------------
73: ;; SSE gen
74: ;; -----------------------------------------------------------------------------
75: (deftype SSEGenerator [ch lock send! on-exception]
    ^--- defrecord/deftype currently only support protocol implementations, found: Closeable
76:   p/SSEGenerator
77:   (send-event! [this event-type data-lines opts]
78:     (u/lock! lock
79:       (try
80:         (send! event-type data-lines opts)

2025-07-10T17:32:14.418239Z

So I tested importing all the java apis in a bb repl and flushable seems to be the only one I miss.

2025-07-10T17:35:46.060779Z

I think i could get around deftype not supporting implementing java interfaces. Make it a cljc file and not include the closeable implementation in the bb case.

2025-07-10T17:36:53.467199Z

I'll stay alert to future bb releases and fix this. Thank you!

borkdude 2025-07-10T17:37:21.487439Z

ok great. I added Flushable on master now. you can test this yourself with:

bash <(curl )  --dev-build --dir /tmp
when CI finishes building

2025-07-10T17:37:51.162599Z

Cool!

borkdude 2025-07-10T17:38:57.762859Z

it would be cool to be able to run datastar in bb, thanks for the effort and let me know if you run into anything else

2025-07-10T17:41:25.041319Z

No problem. Since bb embeds http-kit you already can use datastar. It's just sending sse events with fields set a certain way. Now our SDK manages that for you so yeah it'd be nice to make it work 🙂

🤩 1
borkdude 2025-07-10T17:43:05.613409Z

which os are you on? the macos aarch binary is built pretty quickly on CI

2025-07-10T17:44:04.815179Z

ubuntu and I confess I am lazily using bb by installing it with mise...

2025-07-10T17:44:27.299449Z

I'll run the script to install the fresh version later

borkdude 2025-07-10T17:44:45.060469Z

the invocation I gave you installs it into /tmp/ so it shouldn't conflict

2025-07-10T17:45:26.757579Z

yeah and i can remove the one install quickly if I need to

borkdude 2025-07-10T17:46:09.731869Z

ah the amd64 static binary just got uploaded now

borkdude 2025-07-10T17:46:25.092169Z

(which is the one that's installed by default on linux with the script)

2025-07-10T17:48:03.397259Z

Ok I am gonna go eat something then I'll get to it

borkdude 2025-07-10T17:48:29.873849Z

no hurry, enjoy

2025-07-10T17:48:35.104539Z

thx

borkdude 2025-07-10T18:41:58.533629Z

When commenting this out:

#_#_Closeable
  (close [this]
    (p/close-sse! this))
this now loads:
/tmp/bb -e "(require 'starfederation.datastar.clojure.api 'starfederation.datastar.clojure.adapter.http-kit)"

borkdude 2025-07-10T18:42:11.489109Z

but if it runs correctly needs to be tested of course

2025-07-10T18:42:39.145759Z

man you never stop 🙂 I just got back!

borkdude 2025-07-10T18:42:53.461069Z

oh I did stop for a while, I just tried ;)

2025-07-10T18:46:37.739289Z

That's probably the way I am gonna do it, make the file cljc then add the closable part in a clojure reader conditional. Since the rest of the api doesn't use the .close method but a close-sse! protocol fn I just need to mention not to use CloseAble to bb users...

borkdude 2025-07-10T18:47:31.167399Z

👍

2025-07-10T18:51:06.242089Z

By the way I don't think I have to install bb with the script, latest version on homebrew is from 10 minutes ago...

borkdude 2025-07-10T18:51:56.911079Z

eh... that doesn't sound right

2025-07-10T18:53:17.792689Z

Built from source on 2025-07-10 at 20:40:46 I don't know if your CI pipeline publishes the brew formula automatically

borkdude 2025-07-10T18:53:31.033149Z

huh!

borkdude 2025-07-10T18:53:37.355749Z

which tap are you using

2025-07-10T18:54:08.392379Z

babashka/brew would be the one I believe

borkdude 2025-07-10T18:54:21.448329Z

built from source... never seen that before

2025-07-10T18:54:55.359199Z

that's what I get when doing brew info babashka

borkdude 2025-07-10T18:55:19.707159Z

oh that's not right

borkdude 2025-07-10T18:55:29.093159Z

I mean, that's just the released version

borkdude 2025-07-10T18:55:48.166369Z

that one doesn't have Flushable, just try it

borkdude 2025-07-10T18:56:13.318829Z

"built from source" is probably just the data you ran brew upgrade

2025-07-10T18:56:32.740809Z

oh that makes sense

2025-07-10T18:56:50.661909Z

so time to use the script 🙂

borkdude 2025-07-10T18:57:22.951929Z

ok, if you run this:

bash <(curl )  --dev-build --dir /tmp
you'll get the dev build into /tmp`

2025-07-10T18:59:07.087699Z

it works!

🎉 1
2025-07-10T19:14:18.453569Z

And the code loads. Now I'll write a little demo to make sure.

borkdude 2025-07-10T19:15:27.586549Z

yeah. if you have tests, might be worth it to run some of them with bb too

borkdude 2025-07-10T19:16:10.417519Z

but just a smoke test is a good start

2025-07-10T19:16:18.876929Z

is lazytest bb compatible? I haven't checked.

borkdude 2025-07-10T19:16:26.480119Z

it is now :)

2025-07-10T19:17:34.252069Z

well that's another thing to do I guess...

borkdude 2025-07-10T19:18:14.372769Z

if you can put together an example, I can make a low key release to celebrate DataStar v1.0 and we can make some noise on the socials ;)

2025-07-10T19:19:18.201019Z

I'll keep you updated

2025-07-10T19:48:27.641299Z

Quick question, which version of http-kit bb is embeding?

2025-07-10T20:00:50.907429Z

nvm I think it is 2.8.0-RC1. So the SDK seems to work, however http-kit 2.8.0 has a bug that isn't Server Sent Events friendly.

borkdude 2025-07-10T20:25:16.664949Z

oh lol I should have upgraded to 2.8.0 a long time I think

borkdude 2025-07-10T20:25:34.790759Z

what about the bug, did you file it with httpkit?

2025-07-10T20:29:50.014919Z

the bug is fixed in the 2.9.x versions

borkdude 2025-07-10T20:30:00.131339Z

Happy to upgrade to v2.9.0-beta1

borkdude 2025-07-10T20:30:06.532159Z

I'll bump the version

2025-07-10T20:31:00.464379Z

Cool between this and the Flushable everything is in place for the D* SDK. 🙏

borkdude 2025-07-10T20:33:29.073599Z

Awesome. Is there an example I can link to perhaps?

borkdude 2025-07-10T20:35:12.603839Z

Pushed to master, let's test in 10m again

borkdude 2025-07-10T20:45:20.268639Z

ok, re-installing the dev build should work for your OS now

2025-07-10T21:00:50.795859Z

Thanks I just reran the bash cmd and tried. The sse behavior is good now.

borkdude 2025-07-10T21:09:59.318889Z

would it help if I released another bb tomorrow or no hurry?

2025-07-10T21:10:29.364459Z

no hurry

👍 1
2025-07-10T21:13:37.644709Z

I'll try make the test run on bb. I don't really have examples ready for the SDK beyond some little experiments i have kept in the repo to test D* behavior. So yeah not in a hurry 🙂

👍 1
borkdude 2025-07-17T15:06:41.156529Z

@jeremys keep me posted about any release, I will give a shout out

2025-07-17T15:41:51.530079Z

Hi! So the SDK has it's own repo now <https://github.com/starfederation/datastar-clojure/tree/main>. One can use it via git deps, the clojars release is almost there.

🎉 1
2025-07-11T14:45:48.544639Z

Ok little demo of the D* SDK running in bb. The animation is all done on the server. The "canva" is a div of 50x50 divs sent every frame. In the video 44 frames where sent. That's quite a lot of html to morph... Gzip compression is used 519kb of html were streamed. Well I think everything works! Oh and the 2 browsers share the same state so it's mutliplayer.

borkdude 2025-07-11T14:46:32.440459Z

Amazing!

😅 1
2025-07-11T14:48:06.353869Z

Thanks again for your help. Right now we distribute the SDK via git deps. I am finishing the clojars release process. I think I'll release that first. When bb get's a new release I'll signal the SDK is ready for bb!

borkdude 2025-07-11T14:49:04.895099Z

Is there a small example in the examples dir maybe where you have a similar demo?

2025-07-11T14:50:20.541969Z

I have not published it yet but that a port of one of the example that is already there. I made it when I was testing/integrating stream compression in the SDK. I ported it this afternoon to bb.

borkdude 2025-07-11T14:51:35.159999Z

would it be helpful for bb users to submit this example as well to the repo? or perhaps a separate repo

2025-07-11T14:54:45.445379Z

I have just pushed a branch if you want to take a look at it. https://github.com/JeremS/datastar/tree/bb-support/sdk/clojure/src/bb-example

2025-07-11T14:56:52.745749Z

Thing is right now all the examples in the repo are more test benches I have used when developing the SDK. I might work on proper examples in a dedicated repo later. The focus right now is to finish the clojars release process and mark the SDK v1.

borkdude 2025-07-11T14:57:35.073679Z

awesome

2025-07-11T15:00:42.940049Z

thanks D* allows for really cool things, I don't know if you have seen Anders demos? https://example.andersmurphy.com/

2025-07-11T15:01:00.910799Z

He also made the billion checkboxes demo and the billion cells one...

2025-07-11T15:01:30.529949Z

He is using his own backend, but the front end tool is datastar

borkdude 2025-07-11T15:01:33.009389Z

yep. I've also met him on reClojure recently :)

2025-07-11T15:01:37.230809Z

cool

2025-07-11T15:03:57.828839Z

I got to go, thanks again for the help.

borkdude 2025-07-11T15:05:28.763879Z

you too!

borkdude 2025-07-16T09:58:31.568949Z

new bb is released

2025-07-16T12:08:45.031529Z

great! Thanks you !