re-post: Java, please stop ruining my fun.

Spot-on description of Java hiccups that slow down Clojure development.

To minimize my own pain on this, i've made up a little template project, that I start from, when doing Clojure code, it looks like this:

clj-template/
build.properties
build.xml
clj
lib/
clojure-contrib.jar
clojure.jar
jline-0.9.94.jar
README
src/
myapp/
helper.clj
myapp.clj
test/
myapp/
my_test.clj
myapp_test.clj

  • I edit build.properties to specify the class of the Main App (myapp), and the class of the tests(myapp-test).
  • lib/ contains all the jar's needed for the app, just drop a new one into lib/ and is automatically included when running or compiling.
  • ./clj allows to get a repl or run a script if is called with a .clj file as argument. like: ./clj src/myapp.clj of course includes automatically all jar's existing in lib/
  • build.xml is used by ant(included with all Java distributions), where i have tasks for: compile, create stand-alone jar, run tests, extract documentation.
  • And then there's a bunch of small details to be aware off: naming of the Class has to match filename, specifying (:gen-class) in main Class to be able to create stand-alone jar, always defining a "-main" as the main entry point for the app, etc...
I see all these hiccups as a small cost of being on Java platform. When you then look at the benefits(of being in the Java platform) they largely overwhelm these costs. But yes they are annoying at times, so if we can fix them please do, after all programming should be about solving algorithmic puzzles not dependencies puzzles.

No comments: