在java中比在lisp中更容易做什么? [英] Is anything easier to do in java than in lisp?

查看:55
本文介绍了在java中比在lisp中更容易做什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

经过多年使用LISP,我正在上Java学习并找到

这两个在某些方面大致相当,而在其他方面则非常不同

方式。每个都有一个相当大的有用实用程序库,分别作为核心语言的标准

可移植部分,LISP包和java.lang

包。两者都有很大的整数,尽管据我所知,只有LISP有
的理由。因为CL支持关键字参数,

它有更广泛的字符串搜索实用程序等,其中:key和

:test和:start:end等是参数而不是固定或

这里特别装,但没有。我看到的唯一主要差异是

速度和交互性:


FreeBSD Unix上的速度比较:


javac或java需要appx。第一次启动24秒,然后

几乎是在短时间内的后续时间。

然而即使立即重新运行,javac也需要2到2之间的时间。 7秒

编译一个非常小的文件(总共23行,只有10行实际

代码)。


CMUCL需要appx。第一次启动时间为2秒,然后在短时间内几乎立即启动后续时间。

重新编译33行文件的速度非常快,即便使用

*错误输出*转移到位下沉,以便抑制列出每个编译的
函数,其限制仅限于19200 bps打印输出

值。

(let((* error-output *(make-broadcast-stream)))(编译文件tabsp.lisp))

#p" /home/users/rem/JavaWork/tabsp.x86f"


每次要编译时都需要重新启动java

你想要运行你编译的内容,你不能让jvm运行

并将任务加载到其中。因此,如果你离开java以获得

分钟来编辑源代码以重新编译它等等,那么你将回到24

秒启动再次当你想编译你编辑的内​​容时,一个皇家的痛苦!相比之下,你可以留在CMUCL并在那里做几乎所有的事情,所以你不必忍受即使是两秒钟的第一次启动
在会话期间再次。


交互性:在CL(以及几乎任何LISP自原版以来),你

可以坐在read-eval-print循环中编写并尝试一行代码

,将正确计算的结果存储在全局

变量中,以便进入下一步的编写和尝试。通过

比较,在java中你必须在编辑之间来回切换

不仅仅是你要测试的内容的来源而是整个测试台

围绕它制作一个完整的程序,编译完成

程序字节码,并运行完整代码只是看看

你是否有一行新代码是正确的。在将一个新的LISP表单输入到REP中时,比较即时反馈

,对于24+秒
周转来尝试一个新的java代码行,LISP是一个*大*赢家!


所以我问,是否有任何特殊的任务,其中java比LISP有优势?b $ b优势?我唯一能想到的就是网络。我听说
听说java有语言内置网络,比如

套接字,TCP / IP,HTTP等等,而他们不是CL本身和

需要由不同供应商提供。这是真的,

对于网络来说,java比CL好吗?另外,是否还有其他区域,其中java胜过CL?


嗯,这里有Unicode,它内置于java但不是CL,但是我现在没有用它,因为这不算数。但是我想写一些网络代码,以取代我目前使用的hack,其中lynx

作为CL下的子流程运行,lynx确实如此处理所有的工作

cookies等。如果java可以比CL更直接地完成所有这些工作,我可以试试吧。

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&trying. 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.

推荐答案

经过多年使用LISP,我正在上Java并找到两个大致可比的方式和其他方式非常不同。
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.




< snip>


世界上有什么?使用数百个源文件重新编译一个大的
应用程序需要不到一秒钟。我不知道为什么你的应用程序需要花费很长时间来编译,但它肯定不是因为java本身。



<snip>

What in the world? It takes me less than a second to recompile a large
application with hundreds of source files. I have no idea why your apps take
so long to compile, but it''s surely not because of java per se.


个人,我通常不会使用Java,而我只是在学习口齿不清。我已经用C / C ++编程了大约五年了。我仍然认为我可以通过将其与C范式相关联来回答这个问题:


1)更多的人知道C / C ++比lisp。

2)Java就像C / C ++,因此它便宜/快速/容易让人们学习。

3)Java有更多的支持。通过这种方式,我的意思是更多的企业支持。


我注意到使用Java(我有几次)的另一件事就是

它非常简单编写标准的GUI。换句话说,

Java应用程序在大多数情况下看起来和行为相似。为了自己掩盖

,我还没有在lisp中编写GUI,所以我不知道是否或者b / b不是lisp是一样的。


无论如何,确实Java是类似C的,并且提供了一个简单,标准的
GUI工具包,不难看出为什么很多人/公司都会转而投入b $ b。此外,lisp仍然有很多古代的东西。术语

嵌入到许多初学程序员可能会发现令人困惑的语言中。我必须承认,当我第一次开始学习lisp时,它对我来说几乎是落后的:语法设置的方式,你必须先写下你的第一件事。想要做到最后,你想要的最后一件事首先要做的事情:


;; lisp

(车(cdr) foo))


// C ++(假设我已经使用push& pop类型方法制作了链接列表)

var = llist.rest( );

返回var.first();


这当然只是一个简单的例子,但我假设你看到了我的内容/>
是的意思。我的主要观点是,我不确定天气或不是lisp或java是否更快,更好,或者哪个优势比另一个好,而是

那个那些事情是无关紧要的。 Java节拍 lisp只是因为它不是像bpm那样的b / b,它就像C一样。


为了再次掩盖自己,我实际上更喜欢lisp到目前为止,只有

,因为:

1.它有函数式语言的各个方面。

2.它使列表工作变得简单。


顺便说一下,这可能不是喜欢的最佳方式。但是:

我是新来的名单!
Personally, I don''t normally use Java, and I''m just learning lisp. I have
been programming in C/C++ for about five years though. I still think I may
be able to answer that though, by relating it to a C-paradigm:

1) More people know C/C++ than lisp.
2) Java is like C/C++, therefore it is cheap/fast/easy for people to learn.
3) Java has more support. By that, I mean more corporate support.

Another thing I noticed about using Java (the few times I have), is that
it is extraordinarily easy to write a standard-looking GUI. In other words,
Java apps look and act similarly, for the most part. Just to cover
myself, I haven''t written a GUI in lisp yet, so I don''t know whether or
not lisp is the same way.

Anyway, do to the fact that Java is C-like, and provides an easy, standard
GUI toolkit, it''s not hard to see why a lot of people/companies are
switching to it. Also, lisp still has a lot of "ancient" terminology
embedded into the language that a lot of beginning programmers are likely
to find confusing. I must admit that when I first began learning lisp, it
seemed almost backward to me: the way the syntax is set up, you have to
write the first thing you want to do last, and the last thing you want to
do first:

;;lisp
(car (cdr foo))

// C++ (assume I''ve made a linked list with push & pop type methods)
var = llist.rest();
return var.first();

This is just a simple example of course, but I''m assuming you see what I
mean. My main point is that I''m not sure weather or not lisp or java is
faster, better, or which advantages one has over the other, but rather
that those things are irrelevant. Java "beats" lisp simply because it''s not
lisp-like, it''s C-like.

Just to cover myself again, I actually prefer lisp to Java so far, if only
because of the fact that:
1. It has aspects of a functional language.
2. It makes working with lists easy.

Btw, this probably wasn''t the best way to "" but:
Hi, I''m new to the list!





Ryan J Bovorasmy写道:


Ryan J. Bovorasmy wrote:
就我个人而言,我通常不会使用Java,而我只是在学习口齿不清。我已经用C / C ++编程了大约五年了。我仍然认为我可以通过将其与C范式相关联来回答这个问题:

1)更多人了解C / C ++而不是lisp。
2) Java就像C / C ++,因此它便宜/快速/容易让人们学习。
3)Java有更多的支持。通过这种方式,我的意思是更多的企业支持。

我注意到使用Java(我有几次)的另一件事是,编写标准外观的GUI非常容易。换句话说,在大多数情况下,Java应用程序的外观和行为类似。


我正在努力(请参阅签名中的大提琴)。

无论如何,确实Java是类似C的,并提供了一个简单,标准的GUI工具包,不难看出为什么许多人/公司正在转向它。


我认为这是很好理解的。 OP想知道在Java中是否有什么东西是实际/更容易的。这是残酷的,因为Java是如此简单,无价值的b $ b无能为力的语言,但是c.l.l.是一个野蛮和恶魔的温床

仪式折磨。

...我必须承认,当我第一次开始学习口齿不清时,它似乎几乎落后于我:语法设置的方式,你必须写下你想做的第一件事,以及你想要做的最后一件事:

;; lisp
(car(cdr foo))

// C ++(假设我已经使用push& pop类型方法制作了链接列表)
var = llist.rest ();
返回var.first();


我不了解你,但是当我写CI的时候总是写代码

喜欢这样(取得自由):

if(car(cdr(foo))){

...

}其他....


这也对应于英语:


我生活在从税收中扣除税后剩下的东西

我赚的钱。


当然海明威会说,肯尼挣钱。他们拿出税。

他靠其他人生活。在雨中。

顺便说一句,这可能不是嗨的最佳方式。但是:
我是新来的名单!
Personally, I don''t normally use Java, and I''m just learning lisp. I have
been programming in C/C++ for about five years though. I still think I may
be able to answer that though, by relating it to a C-paradigm:

1) More people know C/C++ than lisp.
2) Java is like C/C++, therefore it is cheap/fast/easy for people to learn.
3) Java has more support. By that, I mean more corporate support.

Another thing I noticed about using Java (the few times I have), is that
it is extraordinarily easy to write a standard-looking GUI. In other words,
Java apps look and act similarly, for the most part.
I''m working on it (see Cello in sig).
Anyway, do to the fact that Java is C-like, and provides an easy, standard
GUI toolkit, it''s not hard to see why a lot of people/companies are
switching to it.
I think that is well understood. The OP was wondering if anything was
/actually/ easier in Java. That is cruel since Java is such a simple,
powerless language, but c.l.l. is a hotbed of savagery and demonic
ritual torture.
... I must admit that when I first began learning lisp, it
seemed almost backward to me: the way the syntax is set up, you have to
write the first thing you want to do last, and the last thing you want to
do first:

;;lisp
(car (cdr foo))

// C++ (assume I''ve made a linked list with push & pop type methods)
var = llist.rest();
return var.first();
I do not know about you, but when I wrote C I was always writing code
like this (taking liberties):

if ( car( cdr( foo ) ) ) {
...
} else ....

This also corresponds to English:

"I live on what is left over after taxes are taken from the money
I earn."

Of course Hemingway would say, "Kenny earned money. They took out taxes.
He lived on the rest. In the rain."
Btw, this probably wasn''t the best way to "" but:
Hi, I''m new to the list!




c.l.l的野人将是欢迎你很快。


:)


kenny


-

回家? http://tilton-technology.com

细胞? http://www.common-lisp.net/project/cells/

大提琴? http://www.common-lisp.net/project/cello/

为什么选择Lisp? http://alu.cliki.net/RtL%20Highlight%20Film

您的项目在这里! http://alu.cliki.net/Industry%20Application



The Savages of c.l.l. will be "welcoming" you shortly.

:)

kenny

--
Home? http://tilton-technology.com
Cells? http://www.common-lisp.net/project/cells/
Cello? http://www.common-lisp.net/project/cello/
Why Lisp? http://alu.cliki.net/RtL%20Highlight%20Film
Your Project Here! http://alu.cliki.net/Industry%20Application


这篇关于在java中比在lisp中更容易做什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆