Niels Mayer | 1 Aug 02:36 2009
Picon

Re: JSR 223

http://www.xwiki.org/xwiki/bin/view/Main/ReleaseNotesXWikiEnterprise20M2On Fri, Jul 31, 2009 at 9:04 AM, Mike <ckimyt <at> gmail.com> wrote:
Are there plans for Clojure to work in JSR-223 (Java Scripting
Framework)?  I see a lot of languages up there already.  In fact, the
only major JVM languages missing are Scala and Clojure.


Clojure has a JSR-223 implementation according to:
http://github.com/pmf/clojure-jsr223/tree/master
http://groovy.codehaus.org/JSR-223+access+to+other+JVM+languages
http://sayspy.blogspot.com/2009/03/interacting-between-jvm-lang-here-and.html

I've been told I'd need to "Build the Clojure JSR223 engine from http://github.com/pmf/clojure-jsr223/tree/master and place it inside WEB-INF/lib" in order to add Clojure as a scripting language to Xwiki (alongside existing velocity/groovy and jRuby scripting implementations). Any special instructions or suggestions or "gotchas" in creating the clojure jsr223 engine? (I'm still upgrading to Xwiki 2.0M2 prior to starting my clojure experiment, so any prior advice before doing anything stupid --  e.g. running the jsr223 engine on an incompatible version of clojure -- would be helpful.)


PS: I've always seen xwiki as the "emacs of webapps" (and wikis)...
So I'm looking forward to having a real emacsish type language -- clojure -- 
to extend it via a more appropriate language for scripting.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure <at> googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+unsubscribe <at> googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

pmf | 1 Aug 08:00 2009
Picon
Picon

Re: JSR 223


On Aug 1, 2:36 am, Niels Mayer <nielsma... <at> gmail.com> wrote:
> PS: I've always seen xwiki as the "emacs of webapps" (and wikis)...
> So I'm looking forward to having a real emacsish type language -- clojure
> --
> to extend it via a more appropriate language for scripting.

I'm the author of the JSR 223 bridge for Clojure. At the moment, I
have several uncommitted changes (mainly related to wrapping it up in
a nice OSGi service component (to be used optionally). The Invocable-
stuff is not implemented at the moment, but will be painless to
implement. The Compilable-interface is a bit harder to do, and given
Clojure's AOT compilation, I'm not sure if there's really a use case
(because if you use require within a small script, Clojure will
already out of the box transparently choose a compiled implementation,
given a proper classpath setup). It's not quite the same, but comes
pretty close.

Aside from that, I have some unresolved design issues regarding
isolation of engines; this works differently for Clojure than for
other dynamic languages for the reasons explained below.

Due to the static initialization of the Clojure runtime, it is much
harder to create different independent Clojure-engine instances, since
this would require loading each Clojure-runtime under a separate
classloader, which I am not opposed to, but was unable to implement.

At the moment, I'm using a weird kind of isolation in which each
Clojure-engine runs in its own thread, using a shared runtime, and
bindings are isolated by pushing and popping them.

I'm going to abandon this rather stupid approach and use a simpler
"one namespace per engine"-scheme. This change should (hopefully) be
transparent for little scripts that don't have their own explicit
namespaces. If your scripts use user-defined namespaces, I'll just
assume you break this isolation intentionally (which is true to the
meaning of namespaces, after all).

If anybody would like to look into the classloader-based isolation,
I'd happily to integrate this change (even if this means a severe
startup-overhead for the creation of each engine-instance; it's simply
the proper way to do it).

For production (at least if you plan to have more than one active
engine instance), I'd recommend to wait for either the namespace-based
isolation or (should anybody get involved) the classloader-based
approach. I'll reply to this thread again if one of these approaches
is implemented.

Gmane