Does the fact that clojure is hosted on JVM mean that it is possible to run clojure codes on computers without clojure installed on them? How could one get a clojure code running on another computer without having to install clojure on it?
- Anything running in the JVM just needs to have the code it depends on in the classpath. Just figure out which JARs your application need and deploy them with your application.Tripp Kinetics– Tripp Kinetics2015-07-31 21:14:07 +00:00Commented Jul 31, 2015 at 21:14
- 1... You're not going to run Clojure without Clojure--but Clojure is just a bunch of jars.Dave Newton– Dave Newton2015-07-31 21:15:11 +00:00Commented Jul 31, 2015 at 21:15
1 Answer
This was one of my first questions when I heard about Clojure. When I can use Java code from Clojure there must be away to make something in Clojure and use it from Java. The answer is YES!
Ahead of time compilation and class generation is possible. The link explains the following reasons one would want to do this:
- To deliver your application without source
- To speed up application startup
- To generate named classes for use by Java
- To create an application that does not need runtime bytecode generation and custom classloaders
It will still rely on clojure jars, probably for the special data types, but it will be in the same manner as class files rely on other class files bexause they are used or extended. No compilation or interpreting is done with the target class files.