简体   繁体   English

如何从命令行更快地运行Clojure代码?

[英]How to run Clojure code faster from the command line?

I need a way to run Clojure code faster. 我需要一种更快运行Clojure代码的方法。 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. 我将SciTE用于几乎所有语言,包括Clojure ,这意味着您必须以与从命令行运行Clojure几乎相同的方式来运行Clojure I've created some batch file that runs the Clojure file on hitting <F5> : 我创建了一些批处理文件,在按<F5>运行Clojure文件:

@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. 我的主要抱怨是运行Clojure文件需要将近2秒钟才能运行,这是不可接受的。 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. 我希望代码能够像Clooj一样快地运行(编译速度更快?),并且同时在另一个选项卡中具有pythonLisp文件,用于实验和SciTE可以提供的其他功能。
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 . 我想知道Clooj如何在不到一秒钟的Clooj内运行/评估整个文件,这样我就可以在SciTE重现该文件,而不必在例如测试某些代码是否可以在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)" . 如果有一种方法可以从命令行评估代码,例如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). 我的主要目标不是离开SciTEClojure - Lisp代码比较),而是仍然能够更快地运行代码(我说的是启动,而不是优化)。

UPDATE: 更新:

The Clojure compiler can evaluate code from the command line(found it in main.clj in the jar file), this way: Clojure编译器可以从命令行评估代码(在jar文件的main.clj中找到它),方法是:

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. 坏消息是它像上一个一样编译平均需要2秒钟的表达式。

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

I didnt try it myself yet, but you should check out https://github.com/flatland/drip 我自己还没有尝试过,但是您应该查看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. 通过正确的类路径和其他JVM选项,它可以保留最新的JVM,以便您可以在需要时快速连接和使用它,然后将其丢弃。 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. Drip对JVM选项进行哈希处理,并将有关如何连接到JVM的信息存储在以哈希值作为名称的目录中。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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