1

I need a way to run Clojure code faster. I use SciTE for almost all languages including Clojure which means that you have to run Clojure pretty much the same way you run it from the command line. I've created some batch file that runs the Clojure file on hitting <F5>:

@java -cp C:\clojure-1.5.1\clojure-1.5.1.jar clojure.main %*

My main gripe is that running a Clojure file takes almost 2 seconds to run, which is unacceptable. I want the code to run(compile faster?) as fast as in Clooj and at the same time have a python or Lisp file in another tab for experimentations and other stuff something that SciTE can provide.
I want to know how Clooj can run/evaluate the whole file in less than a second so that I can reproduce the same in SciTE and not have to switch between the two when for example testing if some code can run unmodified in Common Lisp. It would be awesome if there was a way to evaluate code from the command line like clisp -q -x "(print 'under-a-second)".

My main objective is not to move away from SciTE(Clojure-Lisp code comparison) and still be able to run code faster(I'm talking about startup, not optimization).

UPDATE:

The Clojure compiler can evaluate code from the command line(found it in main.clj in the jar file), this way:

java -cp clojure-1.5.1.jar clojure.main -e "(print 'hello)"  

The bad news is that it compiles the expressions which take on average 2 seconds like the previous one.

tshepang
  • 12,111
  • 21
  • 91
  • 136
gebby
  • 155
  • 1
  • 5

3 Answers3

3

There is grenchman, which uses a standing clojure process, and then a small OCaml program to send it commands and return the results.

noisesmith
  • 20,076
  • 2
  • 41
  • 49
  • There doesn't seem to be any binaries for windows. From the looks of [it](http://clojure-log.n01se.net/date/2013-10-09.html), it may not be possible to build `Grenchman` in windows. I decided to give nailgun a shot and ran the server only to find out that it needs a Java classfile for it to work. That means I have to create a project makefile, `lein compile` it then `ng ng-cp test.class` at the end. That's a step forward and a 100 backwards ... – gebby Nov 13 '13 at 18:06
  • Oh, I did not notice it wasn't available for windows. OCaml is generally pretty good about cross-platform stuff and easy to compile, unless grenchman uses POSIX stuff that Windows does not support. Windows is kind of a second class citizen for most programming environments because it is the only widespread non-*NIX platform anymore. – noisesmith Nov 13 '13 at 22:02
  • Cygwin provides POSIX support in Windows, along with a lot of other things. Might be a lot of trouble just to port one application. – Mars Nov 14 '13 at 01:39
2

I didnt try it myself yet, but you should check out https://github.com/flatland/drip

from the Readme:

Drip uses a different strategy. It keeps a fresh JVM spun up in reserve with the correct classpath and other JVM options so you can quickly connect and use it when needed, then throw it away. Drip hashes the JVM options and stores information about how to connect to the JVM in a directory with the hash value as its name.

Shlomi
  • 4,708
  • 1
  • 23
  • 32
  • Drip is Linux only, unfortunately. I'm trying to avoid build automation tools at this stage. My Clojure knowledge is very little. I'm still working my way through Halloway's book so Nailgun,cake and any JVM launchers are out of the question. – gebby Nov 13 '13 at 14:50
0

If you are happy with ClojureScript then lumo is a great alternative.

mac
  • 9,885
  • 4
  • 36
  • 51