does delay in calling clojure from java happen only once ?

2012-05-17 Thread raschedh
I use clojure more and more in production. To use it even more there, I need to be certain about the answer of the following question. My experiments lead me to the conjecture, that the answer is yes. But a proof can only be given by someone, who is familiar with clojure's implementation of which

Re: does delay in calling clojure from java happen only once ?

2012-05-17 Thread Softaddicts
This has nothing to do directly with Clojure :) The JVM needs to load the class(es) involved. It involves obtaining the class files from disk or cache if lucky (an already opened jar file ?). Then some wiring has to be done to insure that the references needed from the class(es) are met, After

Re: does delay in calling clojure from java happen only once ?

2012-05-17 Thread raschedh
Thank you, for your answer. It doesn't convince me, though. I am well aware of the class loading mechanism of the JVM. But if I compile against, say guava-12.0.jar (beautiful stuff by the way), and use those classes at runtime, there is no delay in using them whatsoever. At least not a delay of

Re: does delay in calling clojure from java happen only once ?

2012-05-17 Thread Softaddicts
Ah, do you compile your Clojure code to Java prior to using it (AOT compilation) ? If not, you must add the clojure compilation time to spit out the class(es) byte code. Here we deliver AOTed components so there's no compilation overhead, we do this for other reasons than this very small

Re: does delay in calling clojure from java happen only once ?

2012-05-17 Thread raschedh
Yes, I do compile my clojure code ahead of time (AOT) to byte code. Does that mean, that your, ahead of time compiled clojure code, has no noticeable delay, when you first call it ? If in the middle of the lifetime of an app, this delay happens, i can not consider it small, if 1 requests are

Re: does delay in calling clojure from java happen only once ?

2012-05-17 Thread Softaddicts
Compared to Java, not noticeable if any. We run our app in production on cluster of small computers. We replaced component written mostly in Java by Clojure equivalents without any degradation in service time. We used clojure from java a number of times using Java callable interfaces generated in

Re: does delay in calling clojure from java happen only once ?

2012-05-17 Thread raschedh
Hm. I do have the feeling, that we do not understand each other. Code is always unambigous. I give an example, and give my question another run. (ns p.x (:gen-class :methods [ ^{:static true} [f [] String] ])) (defn -f [] hello, world) Fire up a REPL, make sure, p/x.clj is in your

Re: does delay in calling clojure from java happen only once ?

2012-05-17 Thread raschedh
The following makes it clearer: package e; import p.x; public final class E { public static void main(String[] args) { System.out.println(before); for (int i = 0; i 100; ++i) { System.out.println(x.f()); } } Now: After launching, the string `before' gets

Re: does delay in calling clojure from java happen only once ?

2012-05-17 Thread Softaddicts
It's the time to get all the related classes loaded needed to support the Clojure code and yes it's a one time cost. The first reference to x gets this triggered. Luc The following makes it clearer: package e; import p.x; public final class E { public static void main(String[]

Re: does delay in calling clojure from java happen only once ?

2012-05-17 Thread Stuart Sierra
Yes, Clojure has a runtime which is initialized the first time you call any Clojure code. The initialization never happens more than once. -S -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to

Re: does delay in calling clojure from java happen only once ?

2012-05-17 Thread raschedh
Ah, cool ! Thank you very much for this insider knowledge, Mr. Sierra !!! Great. That means more clojure in production. Hurrah !!! Thanks again. Heinz. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to