How to benchmark functions in Clojure?

If it’s just a matter of wanting to capture the string programmatically, you can bind *out* to something else before using time. user=> (def x (with-out-str (time (+ 2 2)))) #’user/x user=> x “\”Elapsed time: 0.119 msecs\”\n” If you want more control over the format, then you can create your own version of time using … Read more

Clojure : loading dependencies at the REPL

I’ll go from high-level down to your particular problem: How Clojure (or LISPs) Generally Work REPLs, or Read-Eval-Print Loops are the core of how LISPs are designed: The reader converts a stream of characters into data structures (called Reader Forms). The evaluator takes collection of reader forms and evaluates them. The printer emits the results … Read more

Is Clojure compiled or interpreted?

Clojure is always compiled. The Clojure compiler produces Java byte code, which is typically then JIT-compiled to native code by the JVM. The thing that can be confusing is the dynamic and interactive nature of Clojure that means you can invoke the compiler at run-time if you want to. This is all part of the … Read more