r/Clojure • • Nov 29 '19

Scripting in Clojure, many great options!

I'd recommend looking at all the awesome scripting options for Clojure:

Honestly, scripting is just a solved problem for Clojure in my opinion. At this point. There's even too many good options probably.

My current favorite is Joker. I find it is the most bash like in that the standard library is very small, so just like on bash, you end up delegating to forked processes using sh. Works on Windows, Linux and Mac alike. Single binary.

Inlein is best if your script needs a ton of Clojure dependencies.

Babashka is quite promising, it competes with Joker, but windows support isn't great yet, and it is still alpha. But it has great potential.

Closh is just awesome. It is a literal replacement for bash, in that it is a full shell implemented in Clojure/Script. I really want to see it evolve and get super stable and feature complete. I'd love to make it my default shell instead of zsh.

Lumo and Planck are both great ClojureScript repls that can be used for scripts. Since I'm less familiar with Node and JavaScriptCore APIs I don't tend to use them as much. Also, installing Node is cumbersome, and Planck doesn't support windows. So I've stopped using them for scripting. But great options if you know the JS world a lot.

The last one can be a good replacement for inlein. Similarly, it's a good option if you need a lot of extra Clojure dependencies. It's a clever hack that lets a simple sh script self bootstrap Clojure code within itself and pull in dependencies from tools.deps. There were times when I needed to do more maneuvering to get it working, but it only needs sh and Clojure, which is nice.

73 Upvotes

33 comments sorted by

View all comments

Show parent comments

2

u/Borkdude Dec 01 '19

Haven't tried Babashka so I don't know if that's also the case with it or not.

Babashka tries to be as compatible with JVM Clojure as it can, so you can easily switch between the two. E.g. see this portable script:

https://github.com/borkdude/babashka/blob/master/README.md#portable-tree-command

1

u/ws-ilazki Dec 01 '19

Cool, that could be a good option for some stuff then. Shame about no external libraries, but I'm guessing that's a GraalVM limitation, right?

1

u/Borkdude Dec 01 '19

Correct. There may be an option to have libraries, but that's probably a giant rabbit hole :-) https://github.com/lread/clj-graal-docs/issues/15

1

u/ws-ilazki Dec 01 '19

Yeah, about what I figured. Still, cool project despite that.

I'll eventually get around to trying out making projects with GraalVM myself, since that's probably the path that I need to take to get everything I want, especially once it becomes a viable route to make fast-starting Android applications in Clojure, which is one of the things I've always wanted to use it for. I don't have a lot of free time, though, so I've been holding off for now.

1

u/Borkdude Dec 08 '19

Btw, is possible to add dependencies to a fork of babashka relatively easy and compile it with those.