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

8

u/dkvasnicka Nov 29 '19 edited Nov 29 '19

Can I troll this subreddit by adding a not-so-Clojure alternative to the list? ;) https://docs.racket-lang.org/rash/index.html

4

u/ws-ilazki Nov 29 '19

There's also Janet, which is isn't Clojure but has taken some inspiration from it. Fast start-up and a self-contained static binary that can be used almost anywhere, so it's convenient to keep around even if you can't just write normal Clojure in it.

Unfortunately, the problem with most of the proper Clojure options is that start-up is far too slow for anything you plan to run interactively. Aggressive JVM tweaking still only gets you to about the same speed as using lumo or planck, which is still noticeable and annoying. The options that are faster always seem to either be more limited or just look-alikes like Janet.

2

u/victorbjelkholm Nov 30 '19

Seems like future GraalVM will be the best option for hobby/open source projects wanting to use Clojure and have binaries that start fast. GraalVM still have a long way to go though.

1

u/didibus Nov 30 '19

It doesn't have as much a way to go as you think. Beyond windows support, it's pretty much usable.