简体   繁体   中英

How to run Clojure code faster from the command line?

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.

grenchman ,它使用固定的clojure进程,然后使用小型OCaml程序向其发送命令并返回结果。

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.

如果您对ClojureScript满意,那么lumo是一个不错的选择。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM