[armedbear-devel] Simpe swing examples using JSS and JFLI
Frederico Muñoz
fsmunoz at gmail.com
Fri Jul 20 14:22:28 UTC 2012
Greetings,
I've been playing around with ABCL for some days now, especially in
terms of the Java interop abilities and Swing. This is because I was
searching for a Lisp that could be easily used for cross-platform GUI
programming and easy deployed (for the user). This narrowed it down to
the several JVM-based Lisps (ABCL, Kawa, etc) and Clojure.
While I like Clojure - and "lein uberjar" is a great facility, for
example - I'm more confortable in CL, so I did this two small examples
that can perhaps be useful as a way to compare ABCL's different interop
facilities with themselves and Clojure. In a way I used this to get a
"feel" on how things would work out and make a decision.
ABCL JSS Swing Example: http://paste.lisp.org/display/130606
ABCL JFLI Swing Example: http://paste.lisp.org/display/130605
I'm going to make another use using the lower-level API (jcall, etc),
for the sake of completeness, but I think that perhaps this examples can
be helpful to others as a small reference, using a well-known
example. For me it was quite fun and my overall impressions thus far is
that:
1) ABCL offers different interop facilities that taken as a whole make
it a quite capable solution for overall Java interop, including GUI
programming.
2) The JSS approach has the advantage of being less verbose since the
methods need not contain the class name (which looks cleaner IMO). It is
also simpler to setup, i.e. no need for def-java-class et. al.
3) The JFLI approach integrates well with Lisp, since it provides
completion of methods, amongst other small things. The lack of #"foo"
syntax is also visually appealing IMO. It can also - theoretically - be
used by JFLI installations in other Lisps. It is more verbose though,
since methods must be preceeded with the class (class.foomethod)
4) Clojure's approach is (naturally) conceptually quite similar to
JFLI, in the "feel" that it provides, although the use of (.fooMethod
instance) is similar to (#"fooMethod" instance) in terms of synxtax. The
use of macros (like doto) significantly reduces number of words used.
5) I see nothing in the way of implementing similar macro mechanisms on
top of either JSS or JFLI - but I can be simplifying things brutally
here.
In the most simple scenario syntax differences are as follows:
ABCL JSS: (#"setText" my-label "The Larch")
ABCL JFLI: (jlabel.settext my-label "The Larch")
Clojure: (.setText my-label "The Larch")
The Clojure approach seems quite similar to the javadot approach of
jscheme (http://jscheme.sourceforge.net/jscheme/doc/javadot.html), as
noted in the ABCL blog - I was unaware of that.
More complex approachs envolving the need for proxies contain more
differences of course.
I would greatly welcome any comments concerning style and approach: I am
completely new to this so I am probably missing a lot. It was quite
enjoyable though, even if there are still some rough edges here and
there (quite understandable since for JFLI I had to used trunk). I think
that this is an area worth exploration, easy (meaning well-integrated,
clear syntax, small impact) interop is a huge advantage.
Thank you for your hard work, highly appreciated.
Cheers,
Frederico
More information about the armedbear-devel
mailing list