From: Dave Bakhash
Subject: alternative to Jlinker: Jython
Date: 
Message-ID: <c2965tza0pa.fsf@nerd-xing.mit.edu>
One of the sour points I've had with Common Lisp (using LispWorks) was
that I never felt I had the access to the JVM that I wanted.  It's easy
enough to write an interpreter in Java, and it's been done over and over
again.  Sticking a Lisp front-end onto that isn't the biggest deal, but
it's also not the most elegent solution, since you end up having to run
an additional process (in Java) waiting for evaluation requests from
Lisp.  Data between Lisp and Java have to be marshalled through a
network protocol (typically TCP/IP for simplicity and portability).

I liked the fact that Franz is working on JiL, and that people are
working on Lisp->Java translators, since given a program it would be a
nice option to be able to port it to the JVM -- even if you didn't use a
single Java library.  Of course, if this is done for CL, it's likely
that the library (jar) file associated with running the CL would be
bigger than, say, the jar file for embedding a Jython environment in
Java (720K).

Since JiL isn't nearly mature enough, and I haven't made any effort in
diving into the CL->Java translator, Jlinker was the best bet.  After
using it and seeing that it can be made to work, I decided a few things:

 o the Lisp image seems to grow considerably
 o you start a rather largish Java image running
 o the Lisp interface is not appealing (to me), though that could be
   improved on by an application programmer

After using Jython, I think that it can be done:

 o with about the same net increase in memory resources used
 o easer to move data back and forth between Lisp and Java
 o a REPL that is heavily analogous to what you get in CL
 o portability to other Lisps (e.g. LispWorks can easily interface with
   Jython).

here's an example of Jython, just to show people what I'm talking about:

Jython 2.1 on java1.3.1 (JIT: null)
Type "copyright", "credits" or "license" for more information.
>>> (2, 3, 4)
(2, 3, 4)
>>> x = (2, 3, 4)
>>> x
(2, 3, 4)
>>> y = [2, 3, 4]
>>> y
[2, 3, 4]
>>> y[0] = "two"
>>> y
['two', 3, 4]
>>> z = lambda x, y: x + y
>>> z(2, 3)
5
>>> z
<function <lambda> at 276277>
>>> dir(z)
['__dict__', '__doc__', '__name__', 'func_closure', 'func_code',
'func_defaults\
', 'func_doc', 'func_globals', 'func_name']
>>> getattr(z,'func_code')
<code object <lambda> at 1965402, file "<console>", line 1>
>>> dir(getattr(z,'func_code'))
['co_argcount', 'co_cellvars', 'co_filename', 'co_firstlineno',
'co_flags', 'co\
_freevars', 'co_name', 'co_nlocals', 'co_varnames']
>>> getattr((getattr(z,'func_code')),'co_varnames')
('x', 'y')

[you can see...there's a lot of instrospection there...]

I think this is the way to go (for people who don't use ACL, but want
something like Jlinker).

I might develop something like this for my company.  If poeple are
interested in getting the code, just send me a private email to
ยทยทยทยท@portusgroup.com).

dave