Fork me on GitHub
#babashka
<
2021-12-09
>
h0bbit09:12:12

Hello @borkdude , I've been using Babashka for scripting at home and loving it. Recently I decided to convert two scripts at work into BB (a Python script and a lein plugin) and ran into an incompatible libraries problem: 1. the python script stores data in Redis. I used carmine in my Clojure code, which is incompatible with bb 2. the lein plugin uses clojure.tools.namespace library, which is incompatible with bb. My question is: Where I can find resources on "making a library compatible with bb" ? I'd love to know how to debug further in such situations and how to possibly add bb support for incompatible libraries.

borkdude09:12:45

@h0bbit A tools.namespace fork that is compatible with bb is maintained here: https://github.com/babashka/tools.namespace which only uses clojure built-ins and does not rely on tools.reader. As for Redis, I'm not sure what is necessary to make that work with bb. In general bb cannot load custom Java classes, they have to be explicitly added, but as long as a library uses standard JDK classes and pure Clojure, it should mostly work (or you can ask me when something is missing). To work around the "foreign class" constraint, one can also consider making a babashka pod. See https://github.com/babashka/pod-registry for available pods (sql, etc.). One common limitation is deftype since that is often relying on combining multiple Java interfaces which bb cannot do since you cannot create new Java classes at runtime in a graalvm native image. bb does support defrecord.

h0bbit09:12:17

Great! Thanks, I'll check out babashka/tools.namespace. Thank you for the immediate response.

borkdude09:12:20

@h0bbit There is also #nbb for SCI on Node.js which may also allow you to do some Redis stuff

h0bbit17:12:15

This was the script I wanted to write @borkdude : bb-components in https://github.com/vedang/bb-scripts :) It finds all the 'components' that are affected by a set of code changes. A 'component' is a namespace with a -main function in it. It's a handy way to make sure everything is tested in a monolithic code-base. babashka/tools.namespace worked wonderfully.

borkdude22:12:14

So here's the fork of clojure.spec with minimal changes for babashka: https://github.com/babashka/spec.alpha If you are interested, please try it out with babashka from master (see #babashka-circleci-builds) .

👏 2