It seems that to install Clojure in every new IDE, I have to completely re-install it and create a copy of it. And running the REPL seems like it’s running a Java program.
I’m coming from a Ruby background, where Ruby programs are run by ruby program.rb, and the ruby being a program executed from one place, onto the file (I am aware that this is similar to how it works for java, python, etc. as well).
Is the clojure “interpreter” merely a compiled Java file which takes the .clj file as an argument, and does stuff to it?
Firstly, Clojure has no interpreter. All Clojure code is compiled into JVM bytecode when it is being loaded. I’m stressing this point, because this is were Clojure’s excellent performance story begins.
Secondly, you don’t really “install” Clojure in the sense that you do Ruby. Clojure comes as a
jarfile, which is just a bunch of Java classes; if you put thejarfile on your classpath, you can run methods of those classes. Of those classes,clojure.mainprovides amainmethod for running REPLs and “scripts”. So, running the REPL is indeed running a Java (that is, JVM) programme; and running acljfile amounts to askingclojure.mainto load and run it (the actual work is handed off to other classes in Clojure’s implementation, butclojure.mainis the entry point). BTW, this is exactly the same as with JRuby.Every JVM programme is ultimately “merely a compiled Java file”, or perhaps a bunch of such files. To run it, you need to have a JVM instance load it and run the appropriate
mainmethod. Note that C programmes (such asruby-the-command) are only different in that the operating system knows how to find theirmainfunctions for you (well, the equivalent of Java’s classpath works pretty differently too, but the main concepts are the same). With JVM programmes, you need to use an OS-friendly executable (java/java.exe) to kick things off.