Fork me on GitHub

I need to wrap up what I’ve been working on with meander first before a step over to this.


But I’m familiar with the goal of the code and feel confident.


Is there anyone here using babashka under macOS, but via Nix? In a recent London Clojure online meetup it was mentioned that some ppl are using the JAR distribution of Babashka with Nix somehow. I would be curious what does it mean. (I would really like to integrate Babashka into our projects, but for that I would need a cross-platform solution to install it via Nix.)


What I meant was that the uberjar is built for building the nixOS package, at least, that's why I distribute it because someone had asked me to do this.

David Pham09:12:13

A really noob question: how do you transform in string int o an array of bytes in Babahska?


(.getBytes "foo")

David Pham09:12:42

No need of the standard chars sets?


@neo2551 This also works:

$ bb -e '(.getBytes "foo" "UTF-8")'

David Pham09:12:23

wow 🙂 Is this supported in Clojure overall?


it's just the Java API

David Pham10:12:17

Wow 🙂 So great!

David Pham10:12:32

why does one need the standardcharts set then?


I think the Java folks like IDE assistance by using the enums

David Pham10:12:20

Haha ok!! Thanks!

Kevin13:12:09 Maybe interesting for BB? Or at least as a pod?


@kevin.van.rooijen there is It doesn't yet have a pod interface but it might have one if @retrogradeorbit is picking work back up. He's going through a busy period right now.


I will be resuming work on it next year.


I tested clj-ssh when I was first building spire but found it to be incomplete. The ssh inside spire used clj-ssh as a starting point but fixed the broken parts and added some features.


Things that I had trouble getting working were things like recursive copying (it may work for you but I had troubles) and I added stuff like ssh-agent authentication support so the ssh client can access your keychain, and authentication forwarding so you can shell onwards to other hosts using your local ssh agent keys without copying.


but clj-ssh should be usable for simple usage.


Usually shelling out works too if it's one-shot invocations


But potentially interesting, thanks


Yeah I was thinking of just using bb's shell interface


@kevin.van.rooijen bb recently added babashka.process which is more suitable for longer running programs. Depends on your usage.


@kevin.van.rooijen e.g. this is how you can launch an interactive ssh session:

$ bb -e '@(babashka.process/process ["ssh" "borkdude@..."] {:inherit true})'


Very cool!


That might really come in handy if I need to script multiple commands


$ bb -e '(:out @(babashka.process/process ["ssh" "borkdude@..."] {:out :string :in "ls"}))' "Linux ... #1 SMP Fri May 8 15:27:51 UTC 2020 x86_64\n\nThe programs included with the Debian GNU/Linux system are free software;\nthe exact distribution terms for each program are described in the\nindividual files in /usr/share/doc/*/copyright.\n\nDebian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent\npermitted by applicable law.\nNo mail.\nadvent-of-cljc.git\nbalcony\nbalcony.clj\nbalcony.cljs\nbalcony.cljs~\nbalcony-hs\nbalcony.js\nbb\\nbin..."


I'm sure ssh also supports passing the command directly, so you can use all of this for scripting using the utilities we already have on our systems


Clojure-as-bash FTW

parrot 3
David Pham13:12:29

I would you interact with it haha?


Is this a question?

David Pham14:12:17

Sorry, I wondered how you would interact with it.


Like any process, either manually or or writing and reading from the in/outputstreams. See babashka.process docs


not sure if I'm missing something/not finding the right docs so here goes nothing: is it possible to turn a babashka script into a single binary ala what graalvm does?


@victorbjelkholm429 babashka doesn't really support this. the closest you would get to this is creating an uberjar or uberscript which you can invoke with bb itself.


@borkdude that's unfortunate, but understandable. Thanks!


@victorbjelkholm429 there is this project: which converts your script into a binary using GraalVM. How it works: it has a deps.edn with all the libs from bb and from then on its just a normal GraalVM native project

👍 6

it's a bit out of date maybe


It would be pretty darn cool if babashka could compile scripts to binaries 🙂


I see, interesting, I'll take a look, might be Good Enough(TM). Cheers


@dharrigan that would require something built-in like nativity and something which would download GraalVM and then do compile. but not every script that you can run with babashka can run with graalvm, since babashka supports eval and graalvm doesn't =). So even if I would write this integration, I can't guarantee that the end product works


yeah, true true 🙂 Just being fanciful 🙂


if there's a tool which can package bb along with a script inside some container like thing, then that could work. but I don't see the added value really


maybe upx supports something like this?


you can build docker images with bb + script very easily btw


maybe something like flatpack or the ubuntu snap thing can also work


indeed. but, tbh, as you say, a uberjar works just as well and is portable too

David Pham17:12:27

Just as a curiosity, could babashka compiles ClojureScript?


For production builds, compiling ClojureScript requires running some Java (Closure), and babashka "just" has a Clojure intepreter, so I think no, unless you compiled a custom version of babashka that included those java libraries. @neo2551


@neo2551 Babashka itself doesn't, but the Clojure interpreter powering it, sci, does work with CLJS


So you could build a babashka-js using NodeJS probably


The new Deno stuff lets you compile to a native binary I read recently

David Pham19:12:35

You could also build with nexe?

David Pham19:12:49

Basically shipping chrome xD

David Pham19:12:00

My idea was more to compile (simple not advanced) ClojureScript project, so that we could show a light version of CLJS.


This is advanced compiled btw

David Pham19:12:28

Hum, maybe I am lacking the correct vocabulary. One of the difficult part for starting with ClojureScript is the many tools required before getting started [npm, Clojure, Java and all]. What if we could just download babashka (or a version of it) with some deps (like react) and people could start writing a web app? Then, if they want to make advanced compilation, they would need all the shebang, but just for the repl+live-reloading, I wonder if it could be achieved with “just” babashka.

David Pham19:12:34

Or if that even make sense.

David Pham19:12:36

With org-http-kit you can now create simple backends, which is great and shows the power of BB and Clojure. It would be interesting if we could have the same story with ClojureScript.

David Pham19:12:01

Just an idea.


yes, that is possible


feel free to experiment :)

David Pham19:12:36

Haha. That would be interesting.


Hiya @borkdude, I just noticed that maybe bb/sci does not support auto-resolve current namespace maps?

> bb --repl
Babashka v0.2.5 REPL.
Use :repl/quit or :repl/exit to quit the REPL.
Clojure rocks, Bash reaches.

user=> #::{:a 1 :b 2}
[line 1, col 4] Invalid keyword: .
user=> {:b 2, :a 1}
Note this is not a problem for me. It is just something that I stumbled upon. Happy to raise an issue if you’d like.


Aha, that's an edge case I haven't encountered before in real code. Thanks for discovering it! An issue is surely welcome.


will do!