I don't know if this question is appropriate, so if not, please ignore it and accept my apologies for being off-topic.
I am setting out to add scriptability to a largish and relatively mature, though still evolving, Java application. The application is a theorem prover and it operates on formulas expressed in the CLIF notation, about which it's enough to know that it's syntactically a Lisp-like language.
Because of this I'd like to use a Lisp dialect to add scripting. Right now, I'm looking mostly at SISC and Kawa.
So my question is this: What sort of analysis should I be making to select between these two?
One thing I'll point out is that there will be quite a lot of interaction across the boundary between the scripting language and the existing Java application. I.e., there will be a lot of functions or methods that can be invoked on the scripting side to gather information about and manipulate the content being operated on and to initiate problem execution on the Java side.
I mention this because if it's tedious to make any given bit of Java-side functionality accessible to the scripting side, that will be a negative.
Lastly, if there are other Lisp-like scripting languages that integrate well with Java, I'd like to hear about them, too. My research suggests that while many such projects have been created, not many are actively developed or are very complete implementations of Lisp (or Scheme).
> I don't know if this question is appropriate, so if not, please ignore > it and accept my apologies for being off-topic.
> I am setting out to add scriptability to a largish and relatively > mature, though still evolving, Java application. The application is a > theorem prover and it operates on formulas expressed in the CLIF > notation, about which it's enough to know that it's syntactically a > Lisp-like language.
> Because of this I'd like to use a Lisp dialect to add scripting. Right > now, I'm looking mostly at SISC and Kawa.
Lisp-like language in the sense of having lots of ( and ), or do you also have macros?
> So my question is this: What sort of analysis should I be making to > select between these two?
> One thing I'll point out is that there will be quite a lot of > interaction across the boundary between the scripting language and the > existing Java application. I.e., there will be a lot of functions or > methods that can be invoked on the scripting side to gather information > about and manipulate the content being operated on and to initiate > problem execution on the Java side.
> I mention this because if it's tedious to make any given bit of > Java-side functionality accessible to the scripting side, that will be > a negative.
maybe you should simply give both a try and take what felt to be the best. Maybe asking for help on the mailing list of these languages would help too, especially if you describe your language and what you need. I am sure they can tell you where a possible problem hides.
> Lastly, if there are other Lisp-like scripting languages that integrate > well with Java, I'd like to hear about them, too. My research suggests > that while many such projects have been created, not many are actively > developed or are very complete implementations of Lisp (or Scheme).
> > I don't know if this question is appropriate, so if not, please > > ignore it and accept my apologies for being off-topic.
> > I am setting out to add scriptability to a largish and relatively > > mature, though still evolving, Java application. The application is > > a theorem prover and it operates on formulas expressed in the CLIF > > notation, about which it's enough to know that it's syntactically a > > Lisp-like language.
> > Because of this I'd like to use a Lisp dialect to add scripting. > > Right now, I'm looking mostly at SISC and Kawa.
> Lisp-like language in the sense of having lots of ( and ), or do you > also have macros?
CLIF is to Lisp as Java is to C++. That is, if you blur your eyes, you can't tell them apart. Otherwise they have nothing in common. (Actually, Java has a lot more in common with C++ than CLIF does with Lisp.)
One reason I'm looking to Lisp or Scheme as the scripting language is that I don't want a lot of disparate syntaxes in my system. The other is that I'm fond of Lisp as a language.
[ As an aside, my application supports user-definable search heuristics. They are specified in a Lisp-y manner, too, even though that's done with a separate Lisp reader and data structure library and a purpose-built compiler and evaluator. Unfortunately, the Lisp reader library has no evaluator, it just reads and write (Common) Lisp lists and atoms, so it's not an option as far as my scripting needs go. But the nice part is that users don't know that. They just see lots of S-Expressions. ]
> > So my question is this: What sort of analysis should I be making to > > select between these two?
> > ...
> maybe you should simply give both a try and take what felt to be the > best. Maybe asking for help on the mailing list of these languages > would help too, especially if you describe your language and what you > need. I am sure they can tell you where a possible problem hides.
Well, we're a very small operation with more to do than we can really accomplish, so I don't have the luxury of running competitive implementations. I have to do my best to choose correctly up front.
> > Lastly, if there are other Lisp-like scripting languages that > > integrate well with Java, I'd like to hear about them, too. My > > research suggests that while many such projects have been created, > > not many are actively developed or are very complete > > implementations of Lisp (or Scheme).
> how complete does it have to be?
I'm inclined to say not very, but I have a niggling feeling that it would be a mistake to choose something that is only a toy fragment of a real language. SISC and Kawa both purport to be complete or near-complete R5RS implementations, and while that's not a first-order requirement, it is nice and I think it could turn out to be serendipitous to have a full implementation. (Is it contradictory or oxymoronic to antipicate serendipity?)
On Tue, Apr 29, 2008 at 4:07 PM, Randall R Schulz <rsch...@sonic.net> wrote:
> I am setting out to add scriptability to a largish and relatively > mature, though still evolving, Java application. ... > So my question is this: What sort of analysis should I be making > to select between these two?
Be sure to consider issues of deployment -- will you need to load source files out of jars or as classloader resources? Does the application use classloaders in interesting ways that might trip up the language implementation? Do you need to create multiple independent language runtimes, and if so, does the language implementation support that? Some of these features, if missing, might be easy for you to add -- ask a developer. And (of course) ask programmers on the language's user mailing list to share their experiences.
On Tuesday 29 April 2008 14:42, David Huebel wrote:
> On Tue, Apr 29, 2008 at 4:07 PM, Randall R Schulz <rsch...@sonic.net> wrote: > > I am setting out to add scriptability to a largish and relatively > > mature, though still evolving, Java application.
> ...
> > So my question is this: What sort of analysis should I be making > > to select between these two?
Thanks for the feedback. Though I know you don't need or want to know these things, I'll outline the answers in case it leads to any secondary concerns:
> Be sure to consider issues of deployment -- will you need to load > source files out of jars or as classloader resources?
I will probably want to bundle some scripts (in the JAR file or files) and certainly will need to allow others to be supplied from outside the the application proper. (More or less—in many cases scripts would come from the content repository which in one of the two key deployment modes is a Grails application and they whole business is bundled together and deployed into a servlet container.)
> Does the application use classloaders in interesting ways that might > trip up the language implementation?
My application does not, but the fact that its deployed in a servlet container might make the answer a de facto "yes." I'm not sure.
> Do you need to create multiple independent language runtimes, and if > so, does the language implementation support that?
I believe the answer is yes, since the Web app deployment mode is multi-threaded with multiple concurrent users, in general.
> Some of these features, if missing, might be easy for you to add -- > ask a developer. And (of course) ask programmers on the language's > user mailing list to share their experiences. > -David
Randall R Schulz wrote: > Because of this I'd like to use a Lisp dialect to add scripting. Right > now, I'm looking mostly at SISC and Kawa.
> So my question is this: What sort of analysis should I be making to > select between these two?
> One thing I'll point out is that there will be quite a lot of > interaction across the boundary between the scripting language and the > existing Java application. I.e., there will be a lot of functions or > methods that can be invoked on the scripting side to gather information > about and manipulate the content being operated on and to initiate > problem execution on the Java side.
> I mention this because if it's tedious to make any given bit of > Java-side functionality accessible to the scripting side, that will be > a negative.
Kawa provides very easy access to almost all of Java, and because Kawa is compiler-based, there is little or no impedance mismatch between your code and Kawa: You can easily call a Java method, access a Java array, set a Java field, invoke a synchronized section, catch or throw an exception, etc, etc. And doing so compiles into the similar bytecode that javac generates, so there is no need to use reflection or emulation. There is never (well, hardly ever) a need to "escape into Java" for performance reasons or because you can't access a feature from Kawa. (An example of one of the rare exception is annotations - Kawa doesn't yet provide a mechanism to annotation a declaration. It's on my to-do list ...)
Kawa also provides deployment flexibility: You can use eval, a repl, compile your "script" into class files, compile a file on-the-fly, create a servlet, etc. And Kawa takes care with line numbers and other debug information, so you get useful exception stack traces. -- --Per Bothner p...@bothner.com http://per.bothner.com/
On Tuesday 29 April 2008 16:33, Per Bothner wrote:
> ...
> Kawa provides very easy access to almost all of Java, and because > Kawa is compiler-based, there is little or no impedance mismatch > between your code and Kawa: ...
> Kawa also provides deployment flexibility: You can use eval, a repl, > compile your "script" into class files, compile a file on-the-fly, > create a servlet, etc. ...
Thanks, Per. That's all very useful information.
I've done a little experimentation with SISC (mostly on a tangential aspect), but I'll look into Kawa.
Randall R Schulz wrote: > By the way, does Kawa rhyme with Java??
Most of the time I pronounce it that way ... But "Kawa" is based on the Polish word for coffee, and IIRC the "w" is closer to the English "w" than the English "v". The original Kawa 0.1 was an interpreter started by Alex Milowski, who is of Polish heritage. I took over Kawa early on (with Alex's blessing), implemented a compiler, and over the years have essentially re-written it a couple of times over ... -- --Per Bothner p...@bothner.com http://per.bothner.com/
> I don't know if this question is appropriate, so if not, please ignore
> it and accept my apologies for being off-topic.
> I am setting out to add scriptability to a largish and relatively
> mature, though still evolving, Java application. The application is a
> theorem prover and it operates on formulas expressed in the CLIF
> notation, about which it's enough to know that it's syntactically a
> Lisp-like language.
> Because of this I'd like to use a Lisp dialect to add scripting. Right
> now, I'm looking mostly at SISC and Kawa.
> So my question is this: What sort of analysis should I be making to
> select between these two?
> One thing I'll point out is that there will be quite a lot of
> interaction across the boundary between the scripting language and the
> existing Java application. I.e., there will be a lot of functions or
> methods that can be invoked on the scripting side to gather information
> about and manipulate the content being operated on and to initiate
> problem execution on the Java side.
> I mention this because if it's tedious to make any given bit of
> Java-side functionality accessible to the scripting side, that will be
> a negative.
> Lastly, if there are other Lisp-like scripting languages that integrate
> well with Java, I'd like to hear about them, too. My research suggests
> that while many such projects have been created, not many are actively
> developed or are very complete implementations of Lisp (or Scheme).
Hi Randall,
I recommend you also take a look at Clojure. While not Scheme or
Common Lisp, it is functionally rich, and has a number of advantages
over a 'standard' Lisp in the Java environment, particularly as
regards interoperability:
It shares the Java type system. For instance Clojure strings are Java
strings (that can't be true of any standard Lisp where strings are
mutable). Clojure collections implement java.util.Collection.
Clojure has a large sequence library (first/rest/map/filter/reduce/
take/drop etc) that is defined on an abstraction rather than cons
cells, and as such works on all Clojure data structures as well as
Java strings, Java arrays, and any Java Iterable collection or
Enumerator.
Clojure uses Java's calling conventions and call stack. Clojure
closures (fns) implement Callable, Runnable and Comparator.
All Clojure data types are represented by a well-factored set of Java
interfaces that are easy to consume from Java.
Clojure compiles to JVM bytecode and has excellent performance. It
supports optional type hints and simple inference that allow it to
avoid reflection. Clojure supports standard Java debug information.
Clojure's math library works directly with Java's boxed Number types,
including BigInteger and BigDecimal, adding only a Ratio type of its
own.
Clojure has a clean and intuitive Java call interface:
user=> (def s "foobar")
#'user/s
user=> (s.replace "o" "e")
"feebar"
The net result is much more of an integrated feel than one language
bridging to another.
On Tuesday 29 April 2008 17:15, Rich Hickey wrote:
> On Apr 29, 5:07 pm, Randall R Schulz <rsch...@sonic.net> wrote: > > ...
> > Lastly, if there are other Lisp-like scripting languages that > > integrate well with Java, I'd like to hear about them, too. My > > research suggests that while many such projects have been created, > > not many are actively developed or are very complete > > implementations of Lisp (or Scheme).
> Hi Randall,
> I recommend you also take a look at Clojure. While not Scheme or > Common Lisp, it is functionally rich, and has a number of advantages > over a 'standard' Lisp in the Java environment, particularly as > regards interoperability:
Oh, great. Another system I have to look at...
Seriously, thanks for the information. I've heard of Clojure, but know nothing about it (beyond what you've written). I'll definitely check it out. At least I know how to pronounce it (I think).