Fork me on GitHub
#babashka
<
2021-09-06
>
plexus13:09:00

a small public service announcement, we're making lambdaisland.uri bb-compatible https://github.com/lambdaisland/uri/pull/22

🎉 10
plexus13:09:46

We looked at this before, at that point it didn't seem like we could make it work because of the interface implementations (IFn and Object), but turns out if we leave those out it's still a pretty useful library

borkdude13:09:03

> On babashka implementing interfaces is not supported More specifically: this is supported for only one interface at a time + an optional amount of protocols

plexus13:09:15

@U04V15CAJ I tried doing just the Object (toString []) implementation, leaving out the IFn but that didn't work. If that could be made to work that would be fantastic.

plexus13:09:35

(not an interface in this case but a base class override)

borkdude13:09:45

ah hmm, I see interfaces aren't supported on records, but only a single one in reify

plexus13:09:57

or alternatively if sci could provide an alternative way to override str for custom types

borkdude13:09:25

ok, feel free to post issue(s) at babashka and when I have time I'll look into it

borkdude13:09:56

you can for now use bb reader conditionals as well to work around things

borkdude13:09:20

(which is what you're doing I see now)

imre14:09:24

@U04V15CAJ is there a guide on how to check if a library is bb-compatible and what are the steps needed to make it compatible if it isn't?

borkdude14:09:57

Most of it has to do with the limitation that you cannot create new Java types at runtime in a native image

imre14:09:44

Gotcha. I'm trying to check if https://github.com/cgrand/xforms is compatible

imre14:09:32

Looks like it isn't atm 😞

; export BABASHKA_CLASSPATH="$(clojure -Sdeps '{:deps {net.cgrand/xforms {:mvn/version "0.19.2"}}}' -Spath)"

bb -e "
(require '[net.cgrand.xforms :as x])
(x/into [] cat [[1][2]])
"
----- Error --------------------------------------------------------------------
Type:     clojure.lang.ExceptionInfo
Message:  Unable to resolve classname: java.util.Comparator
Phase:    analysis

# ~  1 ↵

borkdude14:09:48

I was looking into as well. We could just add that class.

borkdude14:09:59

The next one is:

128:  (satisfies? #?(:clj clojure.core.protocols/IKVReduce :cljs IKVReduce) coll))
                  ^--- Could not resolve symbol: clojure.core.protocols/IKVReduce

borkdude14:09:10

That can also be accounted for, but takes some more work

borkdude14:09:06

Welcome to make an issue about trying to make xforms run in bb

borkdude14:09:25

What are you trying to use it for, for the library itself or is there another lib which depends on it?

imre14:09:55

I use it heavily in clojure (❤️ xducers) and I'd miss it from my utility belt. It hasn't been updated in a while and has a few https://github.com/cgrand/xforms/pulls, fixing reflection warnings among others so I have been thinking about merging those in my own fork. And when one of my colleagues asked whether it's available in bb I decided to check whether I could patch it so it's compatible. But it sounds like bb itself (or sci?) will need some additions for that, right?

borkdude14:09:29

adding classes is fairly easy, adding protocols requires more work, but can be done

imre14:09:42

Thanks, I'll add an issue there!

borkdude14:09:01

cool. there may be some other dragons, I don't expect this to work soon, but long term it'd be interesting to see what can be done

borkdude14:09:41

(after seeing this: https://github.com/cgrand/xforms/blob/62375212a8604daad631c9024e9dbe1db4ec276b/src/net/cgrand/xforms.cljc#L101, this is currently not possible in SCI, reify with multiple classes)

imre14:09:48

Thanks for the quick eyeballing.

plexus15:09:41

Christophe writes some pretty advanced Clojure... might be worth considering making a spin-off library which implements the functions you use most in a bb-compatible way

2
plexus15:09:02

He's currently busy with creating ClojureDart so I wouldn't expect him to provide too much support on this...

borkdude15:09:34

and since the lib is already .cljc it might not be too much work to introduce a few :bbs