Fork me on GitHub
Jp Soares09:06:25

What's my best option is I need libs not included in bb? I guess I can call jars compiled by lein but it would just be slow, right?


@jpsoares106 Depends on the lib. Not all Clojure programs can be run by babashka.


You can run them by using the BABASHKA_CLASSPATH environment variable

Jp Soares09:06:39

But what if I want to use something else, like [juxt/tick] for example?

Jp Soares09:06:28

I think my only option it's to use its jar, right?


Same, use the BABASHKA_CLASSPATH environment variable and produce the classpath using a tool like clojure So:

export BABASHKA_CLASSPATH=$(clojure -Sdeps '{:deps {tick {:mvn/version "RELEASE"}}}' -Spath)


But unfortunately tick doesn't work with babashka yet, since it uses some stuff that's not supported in bb. There is an issue about this in the tick issue tracker

Jp Soares10:06:34

Nice, but let's say I'm already using bb and I realize I need a lib that doesn't work with babahska yet. I still can call its jar as in plain shell, right? My trade off would be the startup time?


yeah, you could shell out and start a JVM with clojure

Jp Soares10:06:18

The general context would be a project organized not only with clojure code, but using different script languages, like python or ruby. And I'm wondering what could happen if I get to a point where I need a random unknown lib.

Jp Soares10:06:00

I was thinking in splitting functions in different scripts. But if I have some scripts with jar dependencies, the startup time of each would some up as it would be several JVMs, not only one as in common projects.


In that case you might as well just use clojure to do scripts. Babashka also supports reader conditionals btw, :bb if that's something you might want to use.

Jp Soares10:06:47

Ok, I'll study the Clojure cli tools a bit more to understand my trade offs, thank you. Bb is a great tool btw. Thank you for creating it.

👍 3

( "")
should now work on master for the three major OSes now

👍 15
🕸️ 6
🎉 9

Hey, are there any specific limitations with SCI and Clojurescript (`thheller/shadow-cljs {:mvn/version "2.10.12"}`)? I'm having a bit of trouble. e.g. The following doesn't work for me

(sci/eval-string "(println 123)") ;; SyntaxError: missing ) after argument list
I have to manually bind println to make it work:
(sci/eval-string "(println 123)"
                 {:bindings {'println println}}) ;;=> prints 123 in browser console


The first error message seems unexpected, but an error is expected. The reason is that *out* is not bound by default


Re-binding println is probably what you want. By default sci does not allow side effects in the outside world, that's the reason


Wait sorry, I think that first error message is something else 😕


Ok, let me try that


More specifically, {:namespaces {'clojure.core {'println println}}} is probably what you want

👍 3

Maybe sci could also have a *print-fn* like CLJS but the CLJS side of it, but I haven't really explored that yet


That works


One other thing, the js namespace isn't recognized by default. Do I need to add any functions that I use manually?



(sci/eval-string "(js/alert 431)") ;;fail
(sci/eval-string "(js/alert 431)" {:bindings {'js/alert js/alert}}) ;; works


you could try:

{:classes {:allow :all 'js goog/global}}
and see how that works. If it doesn't work out, then look at the interop unit tests in sci for CLJS


Yes that fixes it, thanks!


I'm going to create a PR to write these down in the README. Hopefully that will prevent people from bumping into this. Unless it's already written down somewhere?


I'm not sure how well it works in general, so some (unit) testing of this approach would be good.


and some docs, yeah, makes sense


gotta go now, back in a few hours


there aren't any browser tests for sci yet, maybe also something to look into...


Ok, thanks for the help 👋


I didn't see any mention of this in the README, but maybe I skipped over it