I have written a few small utility applications in Clojure that I compile into self-contained executable JAR files (\"uberjars\") using Maven and the maven-shade-plugin. The
On the Clojure site there is a nice description of AOT compilation. This will already shave off some startup time.
Edit: there have been some efforts to run Clojure programs on a persistent JVM, thus reducing the start-up time. Look-up jark + jvm. However the site seem to have disapeared :(
JVM (at least Oracle's HotSpot) makes very tricky thing to reduce startup time. It doesn't load to memory all program's classes and methods, it loads only resources it needs right now. There are not so many code needed to show a usage message or something like that, so only few functions are actually loaded and Java program gets started quickly. Moreover, HotSpot doesn't even compile these few functions - it uses JIT compilation (and other optimization) for the code, which is executed repeatedly. There's no reason to spend time to compile functions that will be executed only once, e.g. almost all startup methods, and HotSpot doesn't.
So, what about Clojure? I don't think you would like to rewrite Clojure's core to add similar functionality. Nevertheless, you can use same approach inside of your Clojure code. You said your utilities use several libraries, that can slow down startup. So, load libraries lazily as much as you can. For example, you can exclude :use
option from your namespace definition and call explicit use
in your principal functions instead. This won't reduce total time, but it will shift dalay to the moment, when it isn't so appreciable. You can even write small part of your program in Java and call Clojure code only when it is actually needed.
Of course, there is also the java -client JVM argument for improving JVM start up performance. This SO question goes into some detail about this topic.