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.)
@onetom There is a nixOS thread here: https://github.com/NixOS/nixpkgs/pull/105815#issuecomment-738687147
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.
A really noob question: how do you transform in string int o an array of bytes in Babahska?
(.getBytes "foo")
No need of the standard chars sets?
https://docs.oracle.com/javase/7/docs/api/java/nio/charset/StandardCharsets.html
wow π Is this supported in Clojure overall?
yes
it's just the Java API
https://docs.oracle.com/javase/7/docs/api/java/lang/String.html#getBytes(java.lang.String)
Wow π So great!
why does one need the standardcharts set then?
I think the Java folks like IDE assistance by using the enums
Haha ok!! Thanks!
@borkdude https://twitter.com/JakeWharton/status/1334177665356587008 <-- good quote for babashka? π
@helios thanks :)
https://github.com/clj-commons/clj-ssh Maybe interesting for BB? Or at least as a pod?
@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.
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\nbb.zip\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
I would you interact with it haha?
Amazing
Is this a question?
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.
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: 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
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
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
You could also build with nexe?
Basically shipping chrome xD
Here is a sci cljs repl: https://babashka.org/xterm-sci/
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
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.
Or if that even make sense.
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.
Just an idea.
yes, that is possible
feel free to experiment :)
Haha. That would be interesting.
https://twitter.com/borkdude/status/1338905522846769155 π
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!
here ya go: https://github.com/borkdude/babashka/issues/684