This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-03-04
Channels
- # announcements (4)
- # asami (38)
- # babashka (20)
- # beginners (188)
- # cider (1)
- # clara (11)
- # clj-kondo (103)
- # clj-together (1)
- # cljs-dev (15)
- # clojure (138)
- # clojure-australia (5)
- # clojure-europe (33)
- # clojure-france (1)
- # clojure-losangeles (5)
- # clojure-nl (4)
- # clojure-norway (11)
- # clojure-serbia (3)
- # clojure-uk (11)
- # clojurescript (45)
- # community-development (3)
- # conjure (22)
- # core-async (18)
- # datomic (44)
- # defnpodcast (4)
- # deps-new (1)
- # depstar (49)
- # events (2)
- # fulcro (33)
- # girouette (2)
- # honeysql (37)
- # jackdaw (5)
- # jobs-discuss (16)
- # kaocha (3)
- # leiningen (4)
- # lsp (77)
- # malli (55)
- # membrane (4)
- # off-topic (61)
- # polylith (5)
- # quil (5)
- # reagent (33)
- # reitit (12)
- # remote-jobs (1)
- # reveal (4)
- # rewrite-clj (2)
- # sci (16)
- # shadow-cljs (22)
- # sql (1)
- # test-check (27)
- # tools-deps (44)
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
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.
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)