473,854 Members | 1,486 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Is anything easier to do in java than in lisp?

After many years of using LISP, I'm taking a class in Java and finding
the two roughly comparable in some ways and very different in other
ways. Each has a decent size library of useful utilities as a standard
portable part of the core language, the LISP package, and the java.lang
package, respectively. Both have big integers, although only LISP has
rationals as far as I can tell. Because CL supports keyword arguments,
it has a wider range of string search utilities etc. where :key and
:test and :start :end etc. are parametric instead of fixed or
special-cased here but not there. The only major differences I see are
speed and interactivity:

Speed comparisons on FreeBSD Unix:

javac or java takes appx. 24 seconds to start up the first time, then
is virtually instant subsequent times within a short time span.
However even on immediate re-runs, javac takes between 2 and 7 seconds
to compile a very small file (23 lines total, only 10 lines of actual
code).

CMUCL takes appx. 2 seconds to start up the first time, then is
virtually instant subsequent times within a short time span.
Recompiling a 33-line file runs so blindly fast that even with
*error-output* diverted to bit sink so as to suppress listing of each
function compiled, its limited only by 19200 bps printout of the return
value.
(let ((*error-output* (make-broadcast-stream))) (compile-file "tabsp.lisp "))
#p"/home/users/rem/JavaWork/tabsp.x86f"

You need to re-start java every time you want to compile and every time
you want to run what you compiled, you can't just leave the jvm running
and load tasks into it. Consequently, if you go away from java for a
minute to edit the source to recompile it, etc., then you're back to 24
seconds start-up again when you want to compile what you edited, a
royal pain! By comparison, you can stay in CMUCL and do almost
everything there, so you don't have to suffer even the two-second
first-time-start ever again during a session.

Interactivity: In CL (and virtually any LISP since the original), you
can sit in a read-eval-print loop composing and trying one line of code
at a time, storing the results of correct computation in global
variables to feed into the next step of composing&tryin g. By
comparison, in java you have to switch back and forth between editing
the source of not just what you want to test but a whole test rig
around it to make a "complete program", compiling that "complete
program" to bytecode, and running that "complete code" just to see if
you got one line of new code correct. Comparing the instant feedback
when typing one new LISP form into the R-E-P, against the 24+ second
turnaround to try one new line of java code, LISP is a *big* winner!

So I ask, is there any particular kind of task where java has an
advantage over LISP? The only thing I can think of is networking. I've
heard that java has networking built into the language, things like
sockets, TCP/IP, HTTP, etc., whereas they aren't part of CL per se and
need to be supplied by various vendors on the side. So is this true,
that java is better than CL for networking stuff? Also, is there any
other area where java beats CL?

Well, there's Unicode, which is built into java but not CL, but I have
no use for it at present so that doesn't count. But I'd like to write
some Web-networking code to replace the hack I currently use where lynx
is run as a sub-process under CL and lynx does all the work of handling
cookies etc. If java can do all that directly more easily than CL, I
might give it a try.
Jul 17 '05
73 8113
>>>>> On Fri, 25 Jun 2004 17:09:36 -0700, RobertMaas ("RobertMaas ") writes:
From: cs****@news.dtp q.com (Christopher C. Stacy)
If he writes a good implementation, why not sell it?


RobertMaas> I've written lots of software, much in lisp, that I'd
RobertMaas> like to sell, but there's no point in even inquring about
RobertMaas> somebody to buy some particular piece of my software with
RobertMaas> the whole market virtually non-existant in the first place.

Simply writing your software in Lisp will not make it marketable.
What marketable software products have you produced that happen to
be written in Lisp, and what happened when you tried to market them?
Jul 17 '05 #71
> From: Antonio Menezes Leitao <An************ @evaluator.pt>
I looked for interval arithmetic, but can't find what I want. My experience is that there are many more alternatives in the Java
camp than in the Lisp camp. Some of the alternatives are crap, of
course, but the probability of finding something that suits your needs
is, IMHO, higher in the Java camp.


So how should I go about searching for something, for example interval
arithmetic, with high probability of actually finding something
suitable?
The syntax is changing and new language constructs are still being
added.
So new source code might not compile under old compiler because it
happens to use some new syntax? Would any old syntax cease to work
under new compiler?
Have you tried to run Java 1.2 on older browsers?

I don't know what that question means. I run java on a computer, not on
a browser. Please clarify the question.

Applets are Java programs intended to run on the browser. Obviously,
the browser must contain a JVM. The problem is that you cannot use
certain language features because older implementations of the JVM
do not implement those features.


So what you really mean to ask was:
Have you tried to run Applets that use new language features, in
browsers that have old versions of the jvm?

No. The only Java-capable browser I've ever used for running an Applet
is Internet Explorer at DeAnza College, and that seems to be a recent
version of IE that had no trouble running my Applet.
On Unix, I
can use the whereis command, which on this FreeBSD Unix shell account
I'm using gives the directory as /usr/local/jdk1.2.2/bin/ so does that
mean we have version 1.2.2 installed here?

java -version


java version "1.2.2"
Classic VM (build jdk1.2.2-FreeBSD:root:20 00/11/25-02:08, green threads, nojit)

Thanks. Indeed what we have here is pretty old! But for my class work,
it seemed to work, except when I tried to run a GUI application here,
whereupon compilation ran just fine but a runtime exception occurred
because it was trying to find an X11 server, which of course doesn't
exist here. Too bad java doesn't support VT100 term the way lynx does
for HTML forms.
public class guiH {
public static void main(String[] args) {
JOptionPane.sho wMessageDialog( null, "Welcome", "Title",
JOptionPane.INF ORMATION_MESSAG E);
System.exit(0);
}
}
Exception in thread "main" java.lang.Inter nalError: Can't connect to X11 window
server using ':0.0' as the value of the DISPLAY variable.
at sun.awt.X11Grap hicsEnvironment .initDisplay(Na tive Method)
at sun.awt.X11Grap hicsEnvironment .<clinit>(X11Gr aphicsEnvironme nt.java:58)
at java.lang.Class .forName0(Nativ e Method)
at java.lang.Class .forName(Class. java:124)
at java.awt.Graphi csEnvironment.g etLocalGraphics Environment(Gra phicsEnvironmen t.java:63)
at java.awt.Font.i nitializeFont(F ont.java:262)
at java.awt.Font.< init>(Font.java :292)
at javax.swing.pla f.metal.Default MetalTheme.<ini t>(DefaultMetal Theme.java:59)
at javax.swing.pla f.metal.MetalLo okAndFeel.creat eDefaultTheme(M etalLookAndFeel .java:709)
at javax.swing.pla f.metal.MetalLo okAndFeel.getDe faults(MetalLoo kAndFeel.java:7 13)
at javax.swing.UIM anager.setLookA ndFeel(UIManage r.java:363)
at javax.swing.UIM anager.setLookA ndFeel(UIManage r.java:390)
at javax.swing.UIM anager.initiali zeDefaultLAF(UI Manager.java:85 0)
at javax.swing.UIM anager.initiali ze(UIManager.ja va:926)
at javax.swing.UIM anager.maybeIni tialize(UIManag er.java:948)
at javax.swing.UIM anager.getUI(UI Manager.java:55 9)
at javax.swing.JOp tionPane.update UI(JOptionPane. java:1318)
at javax.swing.JOp tionPane.<init> (JOptionPane.ja va:1281)
at javax.swing.JOp tionPane.showOp tionDialog(JOpt ionPane.java:63 0)
at javax.swing.JOp tionPane.showMe ssageDialog(JOp tionPane.java:4 98)
at javax.swing.JOp tionPane.showMe ssageDialog(JOp tionPane.java:4 78)
at guiH.main(guiH. java:4)
Apparently swing doesn't support VT100 term. I'm not trying to do any
actual graphics, just put up some text in a box. Why can't it put up
something like:
/===== Title =======\
| |
| Welcome |
| OK |
\============== =====/
with OK currently selected just like in lynx?
All these claims about java being platform independent are hooey!
Because I didn't found the time yet to install a FreeBSD system.


But if java were platform independent, as claimed, you could just
publish the compiled (.class) files and anybody could download them to
FreeBSD Unix and they'd just *work* from the start, right?
Jul 17 '05 #72
Ro********@Yaho oGroups.Com wrote:

Thanks. Indeed what we have here is pretty old! But for my class work,
it seemed to work, except when I tried to run a GUI application here,
whereupon compilation ran just fine but a runtime exception occurred
because it was trying to find an X11 server, which of course doesn't
exist here. Too bad java doesn't support VT100 term the way lynx does
for HTML forms.
public class guiH {
public static void main(String[] args) {
JOptionPane.sho wMessageDialog( null, "Welcome", "Title",
JOptionPane.INF ORMATION_MESSAG E);
System.exit(0);
}
}
Exception in thread "main" java.lang.Inter nalError: Can't connect to X11 window
server using ':0.0' as the value of the DISPLAY variable.
at sun.awt.X11Grap hicsEnvironment .initDisplay(Na tive Method)
at sun.awt.X11Grap hicsEnvironment .<clinit>(X11Gr aphicsEnvironme nt.java:58)
at java.lang.Class .forName0(Nativ e Method)
at java.lang.Class .forName(Class. java:124)
at java.awt.Graphi csEnvironment.g etLocalGraphics Environment(Gra phicsEnvironmen t.java:63)
at java.awt.Font.i nitializeFont(F ont.java:262)
at java.awt.Font.< init>(Font.java :292)
at javax.swing.pla f.metal.Default MetalTheme.<ini t>(DefaultMetal Theme.java:59)
at javax.swing.pla f.metal.MetalLo okAndFeel.creat eDefaultTheme(M etalLookAndFeel .java:709)
at javax.swing.pla f.metal.MetalLo okAndFeel.getDe faults(MetalLoo kAndFeel.java:7 13)
at javax.swing.UIM anager.setLookA ndFeel(UIManage r.java:363)
at javax.swing.UIM anager.setLookA ndFeel(UIManage r.java:390)
at javax.swing.UIM anager.initiali zeDefaultLAF(UI Manager.java:85 0)
at javax.swing.UIM anager.initiali ze(UIManager.ja va:926)
at javax.swing.UIM anager.maybeIni tialize(UIManag er.java:948)
at javax.swing.UIM anager.getUI(UI Manager.java:55 9)
at javax.swing.JOp tionPane.update UI(JOptionPane. java:1318)
at javax.swing.JOp tionPane.<init> (JOptionPane.ja va:1281)
at javax.swing.JOp tionPane.showOp tionDialog(JOpt ionPane.java:63 0)
at javax.swing.JOp tionPane.showMe ssageDialog(JOp tionPane.java:4 98)
at javax.swing.JOp tionPane.showMe ssageDialog(JOp tionPane.java:4 78)
at guiH.main(guiH. java:4)
Apparently swing doesn't support VT100 term. I'm not trying to do any
actual graphics, just put up some text in a box. Why can't it put up
something like:
/===== Title =======\
| |
| Welcome |
| OK |
\============== =====/
with OK currently selected just like in lynx?
All these claims about java being platform independent are hooey!


I think you are expecting too much there. Java does thrive to be
platform independent. However, Swing is a GUI library, intended to run
in a graphical environment. A VT100 does not qualify. That does not
mean that Java is not platform independent. You should have no problem
running console applications in this environment.

Ray

--
XML is the programmer's duct tape.
Jul 17 '05 #73
> From: Antonio Menezes Leitao <An************ @evaluator.pt>
You google for it. Type "interval arithmetic java" on google
I already did that several weeks ago.
and you will get several promising links (they look promising to me,
at least)
They looked promising to me too, until I actually clicked on the links
and started reading the details.
- the Brandeis Interval Arithmetic Constraint Solver (with Java
source code)
You need a java-enabled web brower to run the applet.
I don't have any such browser here on VT100 dialup into Unix shell. By
the way, Java Applets don't usually work. I wrote one for a class
assignment and put it up here: http://www.rawbw.com/~rem/Lab7.htm and
it works fine from InterNet Explorer in the computer lab at De Anza
College, but it doesn't work in InterNet Explorer in the instructor's
office, and it doesn't work in the classroom adjoining the computer
lab. (In the latter two places, the main dialog comes up, but none of
the buttons do anything.)
the current version is NOT sound since it relies on Java's underlying
math library which is not proven to be accurate to the last bit.
I.e. they don't really implement interval arithmetic, instead they use
ordinary sloppy floating-point arithmetic for the guts of it, then
pretend it's accurate when running interval constraints on top of that,
so it's not at all what I'm looking for which is interval arithmetic
where it counts to guarantee bounds on results of arithmetic
operations.
- interval.source forge.net/interval (a 100% Java, verifiable
implementation of interval arithmetic operations and constraint
contractors for the arithmetic operations and elementary functions
(exp,log,sin,co s,tan,asin,acos ,atan,sin2pi,.. .) Platforms supported
* RedHat Linux 6.1 on the PC and Macintosh OS X
Note: Porting to other architectures should not be hard. The only
non-portable code is that which deals with setting the rounding
modes!


The only java system I have access to from home is FreeBSD Unix, which
is neither of the above two systems. I have no idea what would have to
be done inside the jvm to set rounding modes on FreeBSD Unix.
Is adding annonymous inner classes a minor change?
No, that's a major sort of thing. If I try to port somebody else's
software that depends on that in a key place, I'd probably have to
rewrite the whole module to get it to work under an old version of
java.
Is adding automatic boxing and unboxing a minor change?
Yeah, it'd be a pain to explicitly box/unbox everywhere the compiler
gives an error message, if there are lots of places, but it's a simple
fix linear in number of such places, so I'd consider it a minor change.
Is adding generic types a minor change?
I don't know what that phrase means in java jargon. I know what
abstract classes and interfaces are, and how you can declare a variable
of the generic class and make it dispatch at runtime. Also I know about
the Object class and how LISP-like no-declared-type programming can be
done by passing everything as Object variables to static methods and
then having the static method do a typecase of the argument to dispatch
to all the specific methods. But I don't know whether the phrase you
used is anything like either of those.
I'm curious: what is your definition for "platform independent"?
If the desired task makes sense on a set of platforms, then the program
or whatever does that task on them all. For example, text-mode Web
browsing makes sense on both GUI systems and VT100 dialups, and indeed
some browsers work on GUI systems and some work on VT100 dialups so a
truly platform independent web browser would make sense, but in any
case using the appropriate web browser for each platform the text-mode
Web pages do indeed work on all such platforms. So text-mode Web pages
are in that sense platform independent. (They even work with
Web-by-email services!) There's no reason applets shouldn't work
everywhere HTML FORMs work, except the people in charge of java haven't
bothered to do that.
The Linj compiler that translates from Linj to Java is written in
Common Lisp and it needs a Common Lisp environment to run. It is the
Linj compiler that is not platform independent because binary Common
Lisp code is not platform independent.


Oops, sorry, in all this discussion of java classes that people say I
can download and run anywhere, I forgot Linj isn't java code. But if
you generate fasl files and then load them into a CL environment,
although the contents of the fasl files themselves are dependent on the
CPU, the process of making them is system independent (compile-file
...) so if you avoid calling anything from the SYSTEM package, if you
stick to making ANSI CL calls, it should be easy to make Linj run on
any ANSI-compliant CL system. I guess I'm overlooking something.
Jul 17 '05 #74

This thread has been closed and replies have been disabled. Please start a new discussion.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.