With clojure
I canโt believe that no one suggested this. You should just do
clojure path/to/script.clj
This works using clojure installed on Ubuntu with apt-get. Not sure about other installations ...
With lein-exec
However, if the script you are working on has any dependencies, I would recommend the lein-exec plugin. This has the advantage of allowing Leiningen to be used to handle any dependencies that are enjoyable. Leiningen already has a lein run command, but it only works for basic functions in a complete Clojure / lein project. Thus, the lein-exec plugin is a really nice add-on for small scripts.
Dependency Information ...
Note. For thoroughness, if you use a lane, you can add any libraries that you would like to use in the ~/.lein/profiles.clj file, or in your project.clj file if you are working in a project. Then, when you run lein deps all the dependencies will be installed and available in your scripts / projects using lein exec / lein run . In addition, lein repl provides you with clojure repl with access to these dependencies. Again, definitely the way to go if you have any dependencies in the library.
In any case, consider using drip for faster startup.
Drip is a neat tool that provides you with a ready-to-boot, ready-to-run JVM image. This can be useful to reduce the startup time of JVM applications. clojure may take quite a while to configure itself, so a drip application is a good tool to speed up this process. This is especially true when you write small scripts that you usually expect to run quickly with. If you are using leiningen, check out the lein-drip plugin .
For ClojureScript
I would recommend http://planck-repl.org/ . It now supports (bootable) quick start of ClojureScript scripts without having to run JVM or Clojure. For most scripting tasks, fast execution is important, so when you donโt need something specific for the JVM, this is my No. 1 recommendation.
metasoarous Aug 30 '13 at 4:41 2013-08-30 04:41
source share