Fork me on GitHub
#babashka
<
2020-06-23
>
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?

borkdude09:06:16

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

borkdude09:06:06

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?

borkdude09:06:03

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)

borkdude09:06:28

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?

borkdude10:06:31

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.

borkdude10:06:02

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
borkdude13:06:07

(clojure.java.browse/browse-url "")
should now work on master for the three major OSes now

👍 15
🕸️ 6
🎉 9
Kevin17:06:45

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

borkdude17:06:32

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

borkdude17:06:18

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

Kevin17:06:27

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

Kevin17:06:15

Ok, let me try that

borkdude17:06:49

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

👍 3
borkdude17:06:13

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

Kevin17:06:23

That works

Kevin17:06:49

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

Kevin17:06:36

e.g.

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

borkdude17:06:05

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

Kevin17:06:48

Yes that fixes it, thanks!

Kevin17:06:29

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?

borkdude17:06:11

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

borkdude17:06:18

and some docs, yeah, makes sense

borkdude17:06:25

gotta go now, back in a few hours

borkdude17:06:57

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

Kevin17:06:53

Ok, thanks for the help 👋

Kevin17:06:48

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