Thanks.
Could you explain the reasoning behind compiling the Clojure code
before the Java code?
I would like to be able to demo the sample code from the book in IDEA
Reading this description I become unsure of whether you want to call
into Java from Clojure, or into Clojure from Java.
Here's where I stand:
I presume that in most Clojure programs, the majority of the business
logic will be implemented in Clojure. The Java code, if any, will be
used for implementing low-level stuff (ie. primitive math, mutating
algorithms) and library intergration work. In this case, the wirering
work will be done mostly in Clojure using the standard interop
features of the language. Considering this, the Java code will know
little or nothing about Clojure and is easily compiled first, whereas
the Clojure code might want to have the class files from the Java code
handy during compilation for things such as avoiding reflection, type
hinting and what have you. In short: the Java code *should* be
compiled first.
The inverse case is where Java uses Clojure as a scripting language of
sorts. Here, the Java code may or may not be dominant, but in either
case it knows about Clojure; it may work with the data structures and
it may call functions implemented in Clojure. However, because of the
dynamic nature of Clojure there is seldomly any new types defined in
it, with the intent of direct consumption from Java. Instead, the Java
code interacts with the Clojure code through the various interfaces
defined in clojure.jar. Here's an example of what I mean:
http://en.wikibooks.org/wiki/Clojure_Programming/Tutorials_and_Tips#Invoking_Clojure_from_Java
As we see from that example, the reference to the "foo" function is,
in the Java sense, resolved at run-time. Therefor, the Java code *can*
be compiled first, and if the Clojure code, for some reason, knowingly
interacts with the types defined in the Java code, it *should* [have
the Java compiled first].
This leaves us, to the best of my knowledge, just one case where the
Clojure code *must* be compiled first: When Clojure define new types
through gen-class (or the embedded ASM library) that needs to be
directly and knowingly interacted with in the Java code.
So, my *assumption* (because I have no way of knowing for sure) is
that this last case is the less common one, and therefor it makes
sense to compile the Java code first.
This is my reasoning anyway.