Sunday, April 1, 2012

Clojure and OSGi/modularity?

Now that I am going full on with OSGi (and to a lesser degree, bone up on Java Servlets and maybe JavaServer Faces), I've been wondering about how Clojure will handle modularity.  Looking at the dev site for Clojure, there is a mention that Clojure should work with OSGi, and indeed, the Counter Clockwise plugin for Eclipse already must to some degree, but I noticed a few odd tidbits.

For example, if you look at the clojure dev site where it mentions modularity, it has an outdated reference to Project Jigsaw's scope (see here for a more recent coverage of Jigsaw's scope).  According to several sources, Project Jigsaw is not just an OpenJDK endeavor, but will be in the official Oracle release as well.  And some people are saying that the modularity aspect (combined with the long-awaited closures) will make Java 8 the most revolutionary release of Java to date.

Since Clojure's documentation is out of date, I wonder if the clojuremeister's are planning for how this new Java 8 modularity aspect might impact Clojure itself.  The good news is that if Clojure can support OSGi (and it kind of does thanks to clojure.osgi), then it should work with Java 8, since Jigsaw is supposed to be backwards compatible with OSGi.

What I would love to do is make several bundles in Clojure, and then let the framework take care of it.  I suppose I could just do an AOT compile of Clojure into Java, but the really killer app to me is if I could somehow embed a Clojure REPL as a bundle.  I might have to take a peak at CounterClockWise to see how they do it.  Hmmmm, a clojure NREPL, talking over websockets from a webpage....

All fancy ideas aside, all of this learning always comes at the expense of my "hobby time".  I suppose I should be thankful I have hobby time, but still, I'd prefer learning some other things.  I haven't done any clojure programming in awhile, and I don't want it to get rusty.  Heck, I never even got to practice a couple of things in Clojure (like multimethods or macros).  With regular POJOs, I can just take a java jar, and play with it in clojure.  But with OSGi bundles, I'm not quite sure how I can do that, since the bundle has to run inside the framework.

Anyway, something to think about.  I definitely want a "scripting" language for the stuff I'm doing (man I hate that word, and all the connotations it brings).  So if time permits, I'll see if I can eventually put up a blog post about writing an OSGi bundle in clojure.

No comments:

Post a Comment