babashka

https://github.com/babashka/babashka. Also see #sci, #nbb and #babashka-circleci-builds .
grazfather 2021-03-04T02:49:52.000400Z

nice work!

grazfather 2021-03-04T03:49:36.000700Z

Just tested, works well.

souenzzo 2021-03-04T13:05:14.004200Z

I remember some feature to invoke the JVM with bb, but I can't find it's docs. My use case is: use bb as launch script for my main application. The main reason for doing that is to get some parameters from aws ssm and use them as ENV (that can't be done inside the JVM)

borkdude 2021-03-04T13:08:47.004800Z

@souenzzo

$ bb -e "(println (:out @(babashka.deps/clojure '[-M -e (System/getenv \"FOO\")] {:env {'FOO 'BAR} :out :string})))"
"BAR"

đź‘Ť 1
borkdude 2021-03-04T13:09:32.005400Z

Note that you will have to merge (System/getenv) yourself if you want to pass other env vars from the parent process if you provide :env

souenzzo 2021-03-04T13:10:21.006100Z

babashka.deps/clojure ! Ok. Full control over env also nice 🙂

borkdude 2021-03-04T13:10:48.006600Z

Yes, it is the same API as babashka.process but focused on invoking clojure

borkdude 2021-03-04T13:10:54.006800Z

So for more docs you can look at that lib

2021-03-04T16:47:01.008200Z

Will babashka work with external packages like eg https://github.com/clojure/data.csv

borkdude 2021-03-04T16:47:35.008800Z

@anders152 Even better: clojure.data.csv is built into babashka

2021-03-04T16:48:33.009900Z

Oh, that’s great for my use case! But what about something that only exists on e g clojars?

borkdude 2021-03-04T16:48:49.010600Z

We have a (non-exhaustive) list of compatible libraries here: https://github.com/babashka/babashka/blob/master/doc/projects.md

❤️ 1
2021-03-04T16:49:39.012100Z

I’m still not sure I fully understand exactly what babashka is. Is it a separate runtime from the jvm? Or some strange hybrid?

borkdude 2021-03-04T16:51:17.013Z

@anders152 Good question. Babashka is similar to the JVM, but it supports a subset of both the JVM and Clojure. Usually enough for scripting, but there are some things missing like deftype.

borkdude 2021-03-04T16:51:41.013500Z

It is compiled to native using GraalVM native-image. Code evaluation is done using a Clojure interpreter.

borkdude 2021-03-04T16:52:16.014Z

Benefits for scripting: fast startup, built-in libraries

borkdude 2021-03-04T16:52:32.014300Z

If babashka is not sufficient you can often directly run your code on the JVM instead

2021-03-04T16:53:13.015300Z

I was directed here after asking how to best run Clojure scripts from a shell for eg file cleanup tasks. And I think in most cases this does fit the bill!

2021-03-04T16:54:03.016900Z

I just want to understand the rationale and history somewhat when I’m getting into a new tool. Learning Clojure and not having a JVM background is daunting enough sometimes - there’s a lot of “I guess this just works but I don’t really understand it” for me.

borkdude 2021-03-04T16:54:58.019Z

Feel free to ask anything here, we're friendly to beginners (at least, we should, if not, I will ban them :P)

2021-03-04T16:55:05.019300Z

But one thing I do notice with Clojure stuff is that’s everything seems to exist or be done a certain way for Good Reasons grounded in real world use and pragmatism, so I feel quite calm in just accepting things as they are and learning as I go.

2021-03-04T16:55:51.020300Z

Yes, I have found nothing but kindness and patience when asking questions here. Lovely environment to learn in :)