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. These uberjars contain unpacked versions of clojure.jar and other libraries (i.e.: commons-cli) that the application depends on. They are convenient because I can send them to a customer without requiring that the customer install Clojure (all customers already have the JRE installed).
I have found that the Clojure applications take several seconds to start up, whereas similar applications written in Java start in sub-seconds on the same machines (time to show a usage message, for example).
I suspect that it is because Clojure is on-the-fly compiling some of the code in the clojure.core library as there is source code (.clj
files) in the clojure.jar file.
Is there any way to precompile this source code? Can anything else be done to speed up startup performance? I have heard complaints from the customers about how long the startup takes (and they don't know or care that the application is written in Clojure or Java or Foobar).