nice work!
Just tested, works well.
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)
$ bb -e "(println (:out @(babashka.deps/clojure '[-M -e (System/getenv \"FOO\")] {:env {'FOO 'BAR} :out :string})))"
"BAR"
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
babashka.deps/clojure
!
Ok.
Full control over env
also nice 🙂
Yes, it is the same API as babashka.process
but focused on invoking clojure
So for more docs you can look at that lib
Will babashka work with external packages like eg https://github.com/clojure/data.csv
@anders152 Even better: clojure.data.csv
is built into babashka
Oh, that’s great for my use case! But what about something that only exists on e g clojars?
We have a (non-exhaustive) list of compatible libraries here: https://github.com/babashka/babashka/blob/master/doc/projects.md
I’m still not sure I fully understand exactly what babashka is. Is it a separate runtime from the jvm? Or some strange hybrid?
@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
.
It is compiled to native using GraalVM native-image. Code evaluation is done using a Clojure interpreter.
Benefits for scripting: fast startup, built-in libraries
If babashka is not sufficient you can often directly run your code on the JVM instead
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!
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.
Feel free to ask anything here, we're friendly to beginners (at least, we should, if not, I will ban them :P)
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.
Yes, I have found nothing but kindness and patience when asking questions here. Lovely environment to learn in :)