Fork me on GitHub
#babashka
<
2020-12-15
>
noprompt00:12:08

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

noprompt00:12:50

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

onetom04:12:15

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.)

borkdude08:12:44

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?

borkdude09:12:09

(.getBytes "foo")

David Pham09:12:42

No need of the standard chars sets?

borkdude09:12:05

@neo2551 This also works:

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

David Pham09:12:23

wow 🙂 Is this supported in Clojure overall?

borkdude09:12:25

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?

borkdude10:12:14

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

David Pham10:12:20

Haha ok!! Thanks!

kwrooijen13:12:09

https://github.com/clj-commons/clj-ssh Maybe interesting for BB? Or at least as a pod?

borkdude13:12:05

@kevin.van.rooijen there is https://github.com/epiccastle/spire. 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.

Crispin13:12:56

I will be resuming work on it next year.

Crispin13:12:42

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.

Crispin13:12:17

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.

Crispin13:12:32

but clj-ssh should be usable for simple usage.

borkdude13:12:45

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

borkdude13:12:24

But potentially interesting, thanks

kwrooijen13:12:14

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

borkdude13:12:41

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

borkdude13:12:02

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

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

kwrooijen13:12:54

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

borkdude13:12:03

$ bb -e '(:out @(babashka.process/process ["ssh" "[email protected]"] {: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\nbb.zip\nbin..."

borkdude13:12:22

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

borkdude13:12:35

Clojure-as-bash FTW

parrot 1
David Pham13:12:29

I would you interact with it haha?

borkdude13:12:31

Is this a question?

David Pham14:12:17

Sorry, I wondered how you would interact with it.

borkdude14:12:05

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

victorb15:12:35

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?

borkdude15:12:02

@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.

victorb15:12:38

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

borkdude15:12:23

@victorbjelkholm429 there is this project: https://github.com/MnRA/nativity 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

👍 2
borkdude15:12:32

it's a bit out of date maybe

dharrigan15:12:49

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

victorb15:12:53

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

borkdude15:12:12

@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

dharrigan15:12:43

yeah, true true 🙂 Just being fanciful 🙂

borkdude15:12:14

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

borkdude15:12:29

maybe upx supports something like this?

borkdude15:12:37

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

borkdude15:12:13

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

dharrigan15:12:49

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?

isak17:12:08

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

borkdude17:12:08

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

borkdude18:12:29

So you could build a babashka-js using NodeJS probably

borkdude18:12:45

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.

borkdude19:12:23

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.

borkdude19:12:02

yes, that is possible

borkdude19:12:33

feel free to experiment :)

David Pham19:12:36

Haha. That would be interesting.

lread22:12:09

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.

borkdude22:12:24

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

lread23:12:22

will do!