Fork me on GitHub
#babashka
<
2022-10-19
>
mkvlr07:10:17

is there a .cljs equivalent for babashka? An file extension by which I can override an existing .clj file which bb will pick up? Asking because I don't like reader macros…

borkdude07:10:29

Yes, .bb :)

❤️ 3
💯 1
mkvlr07:10:42

excellent, thanks!

borkdude07:10:47

Even Github recognizes that as Clojure now :)

🙌 11
1
2
github-dark 1
borkdude17:10:18

^ clerk in babashka, nice!

💪 7
🚀 3
🔥 3
clojure-spin 3
nextjournal 2
borkdude21:10:00

I think this could be fun for #adventofcode as well: visualizing puzzle solutions in clerk

yes 1
Andrea06:10:54

How would you suggest to package it, if we’re not so keen on having the extra .bb s in clerk’s own repo. Own repo with a this bb config as the default? https://github.com/nextjournal/clerk/blob/b6bd4c402b6ff831ca8d54f1b4d3e7d9e9bef5e1/bb-runtime.edn#L1-L24

borkdude06:10:27

What are the reasons not to check those files into clerk? Then bb users could just use the normal clerk coordinates?

borkdude06:10:44

And you can reuse some of the tests as well

Andrea06:10:00

I guess we can work in reducing the diff. ... maybe I don’t even need an extra bb config?

borkdude06:10:57

Libraries don’t have their own bb config, they are always deps.edn based

borkdude06:10:07

Bb.edn is only for local project configuration

mkvlr06:10:20

@U9EQP1K0X how to package it is clear, @U04V15CAJ what I’m unsure about if I’m ready to take on that extra runtime complexity at this point inside of clerk. Maybe having a branch or fork that’s updated periodically is also fine for now and doesn’t require me keeping the bb version up to date with every commit

Andrea06:10:23

makes sense. How would you share tasks? Or is the bb folder in the release? I’m confused at times, sorry

mkvlr06:10:26

@U9EQP1K0X there’s no need to package the bb edn, we can just have a branch or fork that folks can use with bb, using deps edn and nothing else. This will contain the .bb files and then it just works.

Andrea06:10:04

ok, this is clear...

borkdude06:10:23

Having forks and branches leads to staleness. Why not merge it?

borkdude06:10:59

Btw I’m fine with whatever choice you make

borkdude07:10:44

So, I see the bb.edn has the same source and deps directories as the deps.edn, right? So you can just refer to that in bb.edn as {:deps {current/project {:local/root "."}}}. There is no need for a separate bb.edn to expose it as a library (that doesn't even work that way).

borkdude07:10:29

You could also call this project clerk-lite and rename .bb to .clj so it can be used from Clojure as well. Just some ideas ;)

mkvlr07:10:02

> Having forks and branches leads to staleness. Why not merge it? Yes, but I think I prefer a slate Blerk over a decreased dev velocity of JVM Clojure Clerk while there's still quite a few open design questions, one Clerk settles down that's different

mkvlr07:10:24

and on the question of clerk-lite I'm curious of how lite it really has to be, might be easier to just implement the whole enchilada rather than talk describe the differences from normal clerk. Speaking of which, iirc nippy does run somehow, was this by ways of https://github.com/justone/brisk#babashka-pod-support?

mkvlr07:10:21

this was meant as a first experiment, to probe if it's possible, what the limitations are, and if there's interest from users in this existing…

mkvlr07:10:59

the first question is a yes, the second we're still figuring out and I haven't heard much on the third question, yet

mkvlr07:10:34

I guess pandoc doesn't even need to be a pod, it's just about distributing the binary to users and shelling out to it…

mkvlr07:10:01

so could ask folks to install pandoc on their own

borkdude07:10:16

that's also an option

mkvlr07:10:22

or is there good ways to distribute a binary using maven?

borkdude07:10:55

no, pods have their own distribution mechanism which works seamlessly. https://github.com/babashka/pod-registry

mkvlr07:10:06

ah so that's a thing that pods solve

borkdude07:10:25

currently there is ongoing work to have "pods as library" so you can use deps.edn to get the newest version of a pod but this is in progress

mkvlr07:10:54

does a pod only distribute the needed architecture then?

borkdude07:10:48

re "that's also a thing pods solve", yes. clj-kondo also has a pod while you can also install it yourself, but when using it as a pod, it's installed for you. e.g. quickdoc uses clj-kondo but you won't notice this, it's automatic

mkvlr07:10:57

nice, so even if it's just a single binary, looks like a pod might make sense

mkvlr07:10:49

is there also stateless pods?

borkdude07:10:54

> does a pod only distribute the needed architecture then? yes, only the architecture you need is pulled

borkdude07:10:45

a pod is as stateless as your library that is exposed is. but the idea is that it's started only once so you can run functions from it without paying the startup time each time

mkvlr07:10:02

ok, so for the padoc pod there would not need to be another process running unless I'm just in the process of parsing a file

borkdude07:10:12

the pod runs for the duration of your program: it is started only once, used many times

mkvlr07:10:01

if pods is only used as a binary delivery mechanmism, is it also possible to write a pod that doesn't "run"?

borkdude08:10:00

> if pods is only used as a binary delivery mechanmism It's not intended as "only a binary delivery mechanism", it's intended to provide functionality to bb from other platforms that bb can't run from source. You can view these are libraries that run in another process.

borkdude08:10:40

When you load a library in Clojure, you don't normally unload that library after using that library. Similar to pods: they define namespaces in your environment, you don't remove these namespaces.

borkdude08:10:05

You can conditionally load pods if you don't want the process if you're not using it, if that is a concern

mkvlr09:10:06

my concern is having another process running that might not get cleaned up properly, and in the case of a pandoc pod wouldn't provide any value since the main process can also just shell out

mkvlr09:10:38

I hear @U9EQP1K0X has markdown in quickjs working. Does bb expose some of the new interop from Project panama already?

mkvlr09:10:51

has anybody ever created a pod using https://justine.lol/cosmopolitan/?

Andrea11:10:08

@U04V15CAJ this is a pass at using quickjs: https://github.com/nextjournal/clerk/pull/232/commits/995e2645487ba76c86175b1559526cf16e736a63 it’s a bit of a hack. I need to copy our es module from resources (inside the jar) to a local file in order for quickjs to be able to import it with relative paths. Or would you have a better idea around that?

borkdude11:10:47

Fun approach :) No, I don't think there is a way around this, unless you use clerk as a git dep, then all files are available on disk

Andrea11:10:29

also the string escaping is pretty so-la-la

borkdude11:10:10

@U9EQP1K0X you could maybe slurp the markdown resource and feed it as an -e expression to quickjs as well, to make the string escaping even worse :-D

Andrea11:10:32

I tried, had some troubles with the size of the module

borkdude11:10:05

you could also spit everything out to a temp folder and run qjs from there

Andrea11:10:55

right, and that just once at bb init?

borkdude11:10:00

you could also create a fallback for nodejs (which is more commonly installed)

borkdude11:10:58

> right, and that just once at bb init? yeah, or only when necessary

Andrea11:10:00

much nicer