babashka

https://github.com/babashka/babashka. Also see #sci, #nbb and #babashka-circleci-builds .
borkdude 2021-03-09T08:50:24.059800Z

babashka v0.2.13: minor bugfix/enhancement release https://github.com/babashka/babashka/blob/master/CHANGELOG.md#v0213 Thanks @dstephens, @wilkerlucio, @kiraemclean, @tekacs and @eamonn.sullivan for contributing!

๐ŸŽ‰ 6
Eamonn Sullivan 2021-03-09T09:21:02.066100Z

Here's a question: The (probably overly elaborate) https://github.com/eamonnsullivan/backup-scripts I wrote in babashka is working well, and I was thinking I would like to move it to some dedicated hardware. I was thinking of using a Raspberry Pi 4 with a couple of USB SSD disks attached, but am I right in thinking that babashka doesn't yet support that ARM processor? What would be a work-around? I should be able to compile the script into a normal uberjar, right?

onetom 2021-03-09T09:21:56.067300Z

I remember seeing something like 2 shebang lines used in context of babashka, but i can't recall what was it for or where did i see it. For example, u can create self-contained shell scripts which pull their dependencies from the Nix package manager, if u start your script with a "double shebang", like this:

#! /usr/bin/env nix-shell
#! nix-shell -i python3 -p python3 python34Packages.pygobject3 libnotify gobjectIntrospection gdk_pixbuf
I remember there was something similar for babashka:
#!/usr/bin/env bb
#! ... ???

borkdude 2021-03-09T09:26:55.067500Z

There is a thread about ARM here: https://github.com/babashka/babashka/issues/241

borkdude 2021-03-09T09:27:53.067900Z

#!/bin/sh

#_(
   "exec" "bb" "$0" hello "$@"
   )
(prn *command-line-args*)
./script.clj 1 2 3
("hello" "1" "2" "3")

๐Ÿ‘ 1
Eamonn Sullivan 2021-03-09T09:30:45.068300Z

Ah, so it looks like progress, but I should probably wait. Presumably I could just add a deps.edn to my project, specifying the dependencies in the usual way and compile it to a jar, right? The Raspberry supports running jars, as far as I know.

borkdude 2021-03-09T09:31:24.068500Z

Yes, that is certainly possible. But as you can see in that thread, someone already made some ARM binaries available.

borkdude 2021-03-09T09:32:02.068700Z

And you can possibly compile it yourself on ARM if you need a more updated one. How many GB of memory do you have on ARM?

Eamonn Sullivan 2021-03-09T09:32:36.069Z

I'm looking at the P4 with 8GB of RAM. Or, rather, I'm going to ask my kids for one for my birthday...

borkdude 2021-03-09T09:33:09.069200Z

Yeah, 8GB should be ok for compiling bb yourself

Eamonn Sullivan 2021-03-09T09:33:14.069400Z

(I have 5 kids, all in their 20s and 30s, so they can afford it...)

borkdude 2021-03-09T09:33:45.069600Z

You need the 64bit one

borkdude 2021-03-09T09:33:59.069800Z

Compilation takes around 15-20 minutes on a Raspberry

๐Ÿ‘Œ 1
Eamonn Sullivan 2021-03-09T09:34:03.070Z

Yes, I'm pretty sure the P4 (and the P3) are 64-bit CPUs.

Eamonn Sullivan 2021-03-09T09:34:38.070200Z

So I gather cross-compiling isn't a thing...

borkdude 2021-03-09T09:34:51.070400Z

4GB of memory is probably just a bit too low, so make sure: 64bit and 8gb, this will work. No, GraalVM doesn't support cross compilation

borkdude 2021-03-09T09:35:06.070600Z

Some people also have tried qemu for cross compilation

Eamonn Sullivan 2021-03-09T09:35:52.070900Z

:thumbsup: -- Another side project to add to the ever-growing list.

borkdude 2021-03-09T09:40:22.071100Z

If there was a CI that exposed linux ARM 64 bit then I would distribute the binary from there

Eamonn Sullivan 2021-03-09T10:01:13.071500Z

Yeah, AWS EC2 arm-64 instances exists, so technically something like CircleCI should be able to spin one up. I'll google around. I use CircleCI already on one my libs. It would be something to play with until I have an actual Pi to use.

Jakub Holรฝ 2021-03-09T17:02:36.076800Z

I've asked in #clojure but it is rather bb specific. I want to extract all calls to log/warn from cljc code, using bb (to make a dictionary of possible app errors for users). But edn/read does not handle reader conditionals. Tips? Use it anyway and register custom reader for #? that returns the content as a map {:clj.., :cljs...}? ๐Ÿ™

borkdude 2021-03-09T17:05:30.079Z

@holyjak You can do this from babashka using https://github.com/babashka/pod-babashka-parcera This will give you the code including the whitespace, you can then select from this code and spit out some data. Other than that, #rewrite-clj is a really good library for this too, but doesn't work with babashka. If you want to do this using s-expressions directly, you can also use https://github.com/borkdude/edamame which accepts a :features option which you can set to #{:cljs} to only get cljs branches

borkdude 2021-03-09T17:05:48.079600Z

You might also be able to do it using tools.reader directly

borkdude 2021-03-09T17:19:40.079900Z

If you are going with the JVM I would recommend joining #rewrite-clj and use that tool

Jakub Holรฝ 2021-03-09T17:21:07.080200Z

Thanks a lot!!!

borkdude 2021-03-09T17:27:08.080700Z

I suggested to @lee that we should maybe work on a rewrite-clj command line scripting tool for this purpose, I think that would be really neat

lread 2021-03-09T17:28:41.081800Z

Sounds interesting to me! Iโ€™m going to try to get rewrite-clj v1 alpha out the door first, getting close!

๐ŸŽ‰ 1
borkdude 2021-03-09T17:33:56.082300Z

@lee If you think that rewrite-clj nodes are serializable, then I think a pod can also work

borkdude 2021-03-09T17:34:32.083200Z

can you e.g. store a rewrite-clj AST to a file and then read it back?

lread 2021-03-09T17:34:45.083400Z

They arenโ€™t easily yet, but we have an open issue on that.

borkdude 2021-03-09T17:35:24.084Z

I think it will also be a bit painful when it comes to zippers, so a separate scripting tool makes sense, I think

borkdude 2021-03-09T17:59:55.084700Z

@holyjak I forgot about https://github.com/borkdude/grasp which is exactly made for this use case: find s-expressions that match a certain shape

โค๏ธ 1
borkdude 2021-03-09T18:02:03.085100Z

it also has a binary

flowthing 2021-03-09T18:03:59.085900Z

I had a feeling you had made a tool specifically for this purpose, but also couldn't remember it. ๐Ÿ™‚ You need to make a new tool that can find a relevant Borkdude tool for your use case.

๐Ÿ’ฏ 4
๐Ÿ˜‚ 5
Jakub Holรฝ 2021-03-09T18:26:01.086900Z

Is it bb or Clj-only?

borkdude 2021-03-09T18:27:55.087100Z

You can use it from the JVM or a standalone binary. I would start with the JVM

borkdude 2021-03-09T18:28:05.087300Z

and if you need to run often, you can make a script

๐Ÿ‘ 1