This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2024-03-17
Channels
Is there any difference between using Clojure.var
and .invoke
inside a Java class to import Clojure methods and doing AOT provided by leiningen and then importing it inside Java? Referring to https://cljdoc.org/d/leiningen/leiningen/2.9.3/doc/polyglot-clojure-java-projects-with-leiningen#interleaving-compilation-steps.
The flow looks like
1. Java class uses a Clojure function from the project
2. Then we import the Java class inside another clojure function (Create object and invoke)
In Java class, when I am initialising the constructor I'll be setting variable = Clojure.*var*("namespace", "method")
. Then calling invoke on the variable. Is there any benefit when I just do precomp option given by leiningen?
Asking this because, saw a difference in response time. Also traces of reflection in Clojure.var usage but not on AOT when we profiled a service.
The Clojure has to be compiled at some point, so if not aot then it’s compiled when the namespace is loaded
You should also create the var once and reuse, not look it up every time