Fork me on GitHub
#babashka
<
2022-07-31
>
imre10:07:19

Is my observation correct that java.util.concurrent.ConcurrentHashMap is not available in bb?

borkdude10:07:46

Seems so:

$ bb -e 'java.util.concurrent.ConcurrentHashMap'

borkdude10:07:44

If you can explain what you're using it for, we could consider adding it

imre10:07:57

As according to my measurements, satisfies? also suffers from relatively poor performance in bb not only clj

borkdude10:07:34

This implementation won't work in bb as protocols are implemented entirely differently

imre10:07:35

But if theres an alternative class I could use I don't insist on concurrenthashmap

imre10:07:02

Ah okay, that settles it then

borkdude10:07:07

Oh I see it's only using memoization, then it should be good actually

borkdude10:07:34

Well maybe you can use a regular java util HashMap with locking?

borkdude10:07:52

I think adding the class is almost a no-brainer though, feel free to post an issue

imre10:07:15

Cool, thank you

imre10:07:46

I'll try the locking route though

imre13:07:21

Is there a shortcut to invoke babashka from babashka (start another babashka process), like invoking (clojure ...?

borkdude13:07:41

@imre No, there isn't. You can do (shell "bb" ...)

1
borkdude15:07:49

There is also (babashka.process/exec ["bb" "(+ 1 2 3)"])

borkdude15:07:11

This does a true exec call, leaving the parent bb

imre16:07:33

Thank you

lilactown16:07:05

what's the recommend approach to using a library that depends on clojure.spec.alpha?

lilactown20:07:46

is there any sort of debugging one can do in bb?

lilactown20:07:09

I am trying to use one of my libraries. calling a function in it just hangs the REPL in bb

borkdude20:07:53

Hmm. Insert println ?

lilactown20:07:21

I'll have to load it from source rather than using maven

borkdude20:07:19

yes, I would do that if you want to debug. Sorry to hear about your problem though

lilactown20:07:58

are there docs for adding reader conditionals for libs? e.g. do I need to make sure that the :bb branch appears before :clj?

lilactown20:07:53

ah! I was perusing the docs dir in the repo

lilactown20:07:10

on investigation, I'm finding that there are some clojure.lang. classes and interfaces I'm using in some internal implementation details for performance that don't exist in bb. would you appreciate issues created for those?

lilactown20:07:09

I already opened one for clojure.lang.MapEntry/create. I just found an interface, clojure.lang.IKVReduce/reducekv that doesn't seem to exist

borkdude20:07:26

In bb it's usually not worth it using those internal clojure.lang stuff - just using the core functions is likely faster

borkdude20:07:14

unless we start heavily optimizing interop - which is on the TODO list

borkdude20:07:27

but interop in bb is quite slow compared to pre-compiled stuff

lilactown20:07:05

if I'm going to add a bunch of reader conds to my lib for bb, is there an easy way to run my tests in CI using bb?

lilactown20:07:12

I'm using kaocha for CLJ and CLJS

lilactown20:07:42

I guess mainly looking for a good example

borkdude20:07:43

The cognitect test runner is compatible with bb if you add the bb fork of tools.namespace to your project: https://github.com/babashka/tools.namespace

lilactown20:07:58

cool, just what I needed! thanks

borkdude20:07:09

For comparison:

$ bb -e '(time (dotimes [i 10000000] (first {:a 1})))'
"Elapsed time: 998.372221 msecs"

$ bb -e '(time (dotimes [i 10000000] (clojure.lang.MapEntry. :a 1)))'
"Elapsed time: 4668.442018 msecs"

borkdude20:07:12

Currently interop is done using reflection and we could cache some things here and there to make it faster, or special-case some stuff