你对Clojure有什么看法?

时间:2022-02-18 22:50:33

What do you guys think about Clojure? I'm thinking of learning it next, currently using Erlang and in general happy with it except the records fiasco... Is Clojure as powerful as LISP?

你们对Clojure有什么看法?我正在考虑接下来学习它,目前正在使用Erlang并且除了记录惨败之外总体上对它很满意...... Clojure和LISP一样强大吗?

10 个解决方案

#1


Consider learning it. If for no other reason then because you can actually use it in a real project.

考虑学习它。如果没有其他原因那么因为你可以在一个真实的项目中实际使用它。

You : Can I use this small Java library called Clojure?
Boss: Why do you need it?
You : For some concurrency improvements.
Boss: Ok.

#2


What you're refering to by Lisp-1 vs Lisp-2 is the question of whether functions and variables share the same name space. In Lisp-1 Lisps, like Scheme and Clojure, they do. In Lisp-2 Lisps, like Common Lisp, they do not. This is mostly a matter of taste and/or convenience - it doesn't affect the power of the programming language.

你在Lisp-1和Lisp-2中引用的是函数和变量是否共享同一名称空间的问题。在Lisp-1 Lisps中,就像Scheme和Clojure一样。在Lisp-2 Lisps中,就像Common Lisp一样,它们没有。这主要是品味和/或方便的问题 - 它不会影响编程语言的力量。

As an example, in Clojure you can do this:

举个例子,在Clojure中你可以这样做:

(defn my-apply [func arg1 arg2]
  (func arg1 arg2))

This is a function that takes a function and two values and applies the function to the values. For example:

这是一个函数,它接受一个函数和两个值,并将函数应用于值。例如:

user=> (my-apply + 1 2)
3

In Common Lisp, you'd have to write this as

在Common Lisp中,你必须把它写成

(defun my-apply (func arg1 arg2)
  (funcall func arg1 arg2))

The reason you need "funcall" is that, since "func" is in the name space of variables, you cannot directly use it as a function, like you can in Clojure, which does not make this distinction. So you have to tell Common Lisp "please interpret this variable as a function and call it with these arguments". Another consequence of this is that to get the same result you must call "my-apply" like this:

你需要“funcall”的原因是,因为“func”在变量的名称空间中,你不能直接将它用作函数,就像你在Clojure中那样,它没有做出这种区分。因此,您必须告诉Common Lisp“请将此变量解释为函数并使用这些参数调用它”。这样做的另一个结果是,要获得相同的结果,您必须像这样调用“my-apply”:

=> (my-apply #'+ 1 2)
3

Here the problem is reversed: "+" is a function, but you want to pass it as a variable, so you have to "convert" it. "#'+" is short for "(function +)", btw.

这里的问题是相反的:“+”是一个函数,但你想把它作为变量传递,所以你必须“转换”它。 “#'+”是“(function +)”的简称,顺便说一下。

#3


I use Clojure and not CL because:

我使用Clojure而不是CL,因为:

  • It communicates well with Java, so I can outsource my coding
  • 它与Java很好地通信,所以我可以外包我的编码

  • It has access to the zillions of java libraries that do all sorts of things, including Swing and Weka
  • 它可以访问各种各样的java库,包括Swing和Weka

  • Since it runs on the JVM, you can more safely assume that your problem will work everywhere
  • 由于它在JVM上运行,因此您可以更安全地假设您的问题无处不在

  • If you can show the same libraries being used with much less code, you can convert Java programmers to the lambda way
  • 如果您可以使用更少的代码显示相同的库,则可以将Java程序员转换为lambda方式

  • And, most importantly, I don't get tied to Emacs
  • 而且,最重要的是,我没有与Emacs联系在一起

:wq

#4


Clojure is a dialect of LISP so, yes, it's as powerful as LISP.

Clojure是LISP的一种方言,所以,是的,它和LISP一样强大。

For no other reason than we now have a good LISP tool for the JVM I like this language.

除了我们现在为JVM提供一个好的LISP工具之外没有其他原因我喜欢这种语言。

#5


I think the name is clever.

我觉得这个名字很聪明。

#6


"Clojure has the potential to do for concurrency-oriented programming what Java did for object-oriented programming a decade ago: make it simpler to do properly using a language (or, in Clojure’s case, a “language environment”) that is similar to what programmers are already used to. " -- Bill Clementson

“Clojure有可能为面向并发的编程做十九年前Java为面向对象编程做的事情:使用一种语言(或者,在Clojure的情况下,一种”语言环境“)使得更简单程序员已经习惯了什么。“ - Bill Clementson

And people, LISP consists of a family of programming languages. There are Lisp dialects like Common Lisp and Clojure. And on top of that, there are many implementations of Common Lisp or Scheme.

人们,LISP由一系列编程语言组成。有Lisp方言,如Common Lisp和Clojure。最重要的是,Common Lisp或Scheme有很多实现。

#7


I used Erlang at work for coordinated network load testing and it was perfect for that because the problem was well within Erlang's "sweet spot" of "doing distributed communication oriented software correctly". I find Clojure MUCH better for code that needs to do something complex on a single box with several threads (this is a more common scenario).

我在工作中使用Erlang进行协调的网络负载测试,并且它非常适合,因为问题完全在Erlang的“正确执行分布式通信软件”的“甜蜜点”内。我发现Clojure对于需要在具有多个线程的单个盒子上执行复杂操作的代码更好(这是更常见的情况)。

You are ahead of the curve because you know Erlang and this will help you spot the problems in which it really shines. What do you thing Clojures real "sweet spot" is?

你已经领先于曲线,因为你知道Erlang,这将帮助你发现它真正闪耀的问题。 Clojures真正的“甜蜜点”是什么?

#8


Clojure is a Lisp-1, yes. Think of it as a nicer Common Lisp without all the historical baggage. It also has several modern concurrency features like STM and Agents (they decided not to implement Erlang's Actors model). The advantage of running on the JVM is simple- there are already SO many libraries written for it (mostly in Java).

Clojure是一个Lisp-1,是的。把它想象成一个没有历史包袱的更好的Common Lisp。它还有几个现代并发功能,如STM和Agents(他们决定不实现Erlang的Actors模型)。在JVM上运行的优点很简单 - 已经为它编写了许多库(主要是Java)。

Clojure in Clojure is an ongoing effort to rewrite the Clojure compiler in Clojure, to make it more portable and maintainable. Apart from core.clj, most of Clojure is written in Java presently. After this move, it'll be possible to port it to a LOT of VMs, including Parrot.

Clojure中的Clojure是在Clojure中重写Clojure编译器的持续努力,以使其更具可移植性和可维护性。除了core.clj之外,目前大多数Clojure都是用Java编写的。在此移动之后,可以将其移植到很多虚拟机,包括Parrot。

#9


I like Common Lisp better than Clojure because the syntax is more regular and it's not tied to the horrible (IMHO) Java APIs.

我喜欢Common Lisp比Clojure更好,因为语法更规则,并且它与可怕的(IMHO)Java API无关。

For Common Lisp I also have the choice between several excellent and well-tested implementations and a mature standard to rely on.

对于Common Lisp,我也可以选择几个优秀且经过良好测试的实现和一个成熟的标准来依赖。

But if I had to use Java for a job then I would definitely consider using Clojure. :)

但是,如果我不得不使用Java作为工作,那么我肯定会考虑使用Clojure。 :)

#10


what I mean by "is Clojure as powerful as LISP" is that i read someplace here on * that Common Lisp is lisp-2 and Clojure is lisp-1? (I could easly be rambling here)...

我的意思是“Clojure和LISP一样强大”是我在*上读到的地方,Common Lisp是lisp-2而Clojure是lisp-1? (我可以轻松地在这里散步)......

as far as concurrency is concerned I really like the Erlang story since its so easy to distribute apps by writing them in the Actor model

就并发性而言,我非常喜欢Erlang的故事,因为它很容易通过在Actor模型中编写它们来分发应用程序

from the creator of Clojure at http://groups.google.com/group/clojure/browse_thread/thread/2a2b24ffef5d1631?pli=1

来自Clojure的创建者http://groups.google.com/group/clojure/browse_thread/thread/2a2b24ffef5d1631?pli=1

"Even with actors, Clojure will not yet have a distributed concurrency story, but I am considering just adopting Erlang's wholesale, using Jinterface for Clojure<->Clojure or even Clojure<->Erlang distributed processes. Maybe that will look like Termite when it is done. Stay tuned. "

“即使有演员,Clojure也不会有分布式并发故事,但我正在考虑采用Erlang的批发,使用Jinterface进行Clojure < - > Clojure甚至是Clojure < - > Erlang分布式进程。也许这看起来就像是白蚁已经完成了。请继续关注。“

#1


Consider learning it. If for no other reason then because you can actually use it in a real project.

考虑学习它。如果没有其他原因那么因为你可以在一个真实的项目中实际使用它。

You : Can I use this small Java library called Clojure?
Boss: Why do you need it?
You : For some concurrency improvements.
Boss: Ok.

#2


What you're refering to by Lisp-1 vs Lisp-2 is the question of whether functions and variables share the same name space. In Lisp-1 Lisps, like Scheme and Clojure, they do. In Lisp-2 Lisps, like Common Lisp, they do not. This is mostly a matter of taste and/or convenience - it doesn't affect the power of the programming language.

你在Lisp-1和Lisp-2中引用的是函数和变量是否共享同一名称空间的问题。在Lisp-1 Lisps中,就像Scheme和Clojure一样。在Lisp-2 Lisps中,就像Common Lisp一样,它们没有。这主要是品味和/或方便的问题 - 它不会影响编程语言的力量。

As an example, in Clojure you can do this:

举个例子,在Clojure中你可以这样做:

(defn my-apply [func arg1 arg2]
  (func arg1 arg2))

This is a function that takes a function and two values and applies the function to the values. For example:

这是一个函数,它接受一个函数和两个值,并将函数应用于值。例如:

user=> (my-apply + 1 2)
3

In Common Lisp, you'd have to write this as

在Common Lisp中,你必须把它写成

(defun my-apply (func arg1 arg2)
  (funcall func arg1 arg2))

The reason you need "funcall" is that, since "func" is in the name space of variables, you cannot directly use it as a function, like you can in Clojure, which does not make this distinction. So you have to tell Common Lisp "please interpret this variable as a function and call it with these arguments". Another consequence of this is that to get the same result you must call "my-apply" like this:

你需要“funcall”的原因是,因为“func”在变量的名称空间中,你不能直接将它用作函数,就像你在Clojure中那样,它没有做出这种区分。因此,您必须告诉Common Lisp“请将此变量解释为函数并使用这些参数调用它”。这样做的另一个结果是,要获得相同的结果,您必须像这样调用“my-apply”:

=> (my-apply #'+ 1 2)
3

Here the problem is reversed: "+" is a function, but you want to pass it as a variable, so you have to "convert" it. "#'+" is short for "(function +)", btw.

这里的问题是相反的:“+”是一个函数,但你想把它作为变量传递,所以你必须“转换”它。 “#'+”是“(function +)”的简称,顺便说一下。

#3


I use Clojure and not CL because:

我使用Clojure而不是CL,因为:

  • It communicates well with Java, so I can outsource my coding
  • 它与Java很好地通信,所以我可以外包我的编码

  • It has access to the zillions of java libraries that do all sorts of things, including Swing and Weka
  • 它可以访问各种各样的java库,包括Swing和Weka

  • Since it runs on the JVM, you can more safely assume that your problem will work everywhere
  • 由于它在JVM上运行,因此您可以更安全地假设您的问题无处不在

  • If you can show the same libraries being used with much less code, you can convert Java programmers to the lambda way
  • 如果您可以使用更少的代码显示相同的库,则可以将Java程序员转换为lambda方式

  • And, most importantly, I don't get tied to Emacs
  • 而且,最重要的是,我没有与Emacs联系在一起

:wq

#4


Clojure is a dialect of LISP so, yes, it's as powerful as LISP.

Clojure是LISP的一种方言,所以,是的,它和LISP一样强大。

For no other reason than we now have a good LISP tool for the JVM I like this language.

除了我们现在为JVM提供一个好的LISP工具之外没有其他原因我喜欢这种语言。

#5


I think the name is clever.

我觉得这个名字很聪明。

#6


"Clojure has the potential to do for concurrency-oriented programming what Java did for object-oriented programming a decade ago: make it simpler to do properly using a language (or, in Clojure’s case, a “language environment”) that is similar to what programmers are already used to. " -- Bill Clementson

“Clojure有可能为面向并发的编程做十九年前Java为面向对象编程做的事情:使用一种语言(或者,在Clojure的情况下,一种”语言环境“)使得更简单程序员已经习惯了什么。“ - Bill Clementson

And people, LISP consists of a family of programming languages. There are Lisp dialects like Common Lisp and Clojure. And on top of that, there are many implementations of Common Lisp or Scheme.

人们,LISP由一系列编程语言组成。有Lisp方言,如Common Lisp和Clojure。最重要的是,Common Lisp或Scheme有很多实现。

#7


I used Erlang at work for coordinated network load testing and it was perfect for that because the problem was well within Erlang's "sweet spot" of "doing distributed communication oriented software correctly". I find Clojure MUCH better for code that needs to do something complex on a single box with several threads (this is a more common scenario).

我在工作中使用Erlang进行协调的网络负载测试,并且它非常适合,因为问题完全在Erlang的“正确执行分布式通信软件”的“甜蜜点”内。我发现Clojure对于需要在具有多个线程的单个盒子上执行复杂操作的代码更好(这是更常见的情况)。

You are ahead of the curve because you know Erlang and this will help you spot the problems in which it really shines. What do you thing Clojures real "sweet spot" is?

你已经领先于曲线,因为你知道Erlang,这将帮助你发现它真正闪耀的问题。 Clojures真正的“甜蜜点”是什么?

#8


Clojure is a Lisp-1, yes. Think of it as a nicer Common Lisp without all the historical baggage. It also has several modern concurrency features like STM and Agents (they decided not to implement Erlang's Actors model). The advantage of running on the JVM is simple- there are already SO many libraries written for it (mostly in Java).

Clojure是一个Lisp-1,是的。把它想象成一个没有历史包袱的更好的Common Lisp。它还有几个现代并发功能,如STM和Agents(他们决定不实现Erlang的Actors模型)。在JVM上运行的优点很简单 - 已经为它编写了许多库(主要是Java)。

Clojure in Clojure is an ongoing effort to rewrite the Clojure compiler in Clojure, to make it more portable and maintainable. Apart from core.clj, most of Clojure is written in Java presently. After this move, it'll be possible to port it to a LOT of VMs, including Parrot.

Clojure中的Clojure是在Clojure中重写Clojure编译器的持续努力,以使其更具可移植性和可维护性。除了core.clj之外,目前大多数Clojure都是用Java编写的。在此移动之后,可以将其移植到很多虚拟机,包括Parrot。

#9


I like Common Lisp better than Clojure because the syntax is more regular and it's not tied to the horrible (IMHO) Java APIs.

我喜欢Common Lisp比Clojure更好,因为语法更规则,并且它与可怕的(IMHO)Java API无关。

For Common Lisp I also have the choice between several excellent and well-tested implementations and a mature standard to rely on.

对于Common Lisp,我也可以选择几个优秀且经过良好测试的实现和一个成熟的标准来依赖。

But if I had to use Java for a job then I would definitely consider using Clojure. :)

但是,如果我不得不使用Java作为工作,那么我肯定会考虑使用Clojure。 :)

#10


what I mean by "is Clojure as powerful as LISP" is that i read someplace here on * that Common Lisp is lisp-2 and Clojure is lisp-1? (I could easly be rambling here)...

我的意思是“Clojure和LISP一样强大”是我在*上读到的地方,Common Lisp是lisp-2而Clojure是lisp-1? (我可以轻松地在这里散步)......

as far as concurrency is concerned I really like the Erlang story since its so easy to distribute apps by writing them in the Actor model

就并发性而言,我非常喜欢Erlang的故事,因为它很容易通过在Actor模型中编写它们来分发应用程序

from the creator of Clojure at http://groups.google.com/group/clojure/browse_thread/thread/2a2b24ffef5d1631?pli=1

来自Clojure的创建者http://groups.google.com/group/clojure/browse_thread/thread/2a2b24ffef5d1631?pli=1

"Even with actors, Clojure will not yet have a distributed concurrency story, but I am considering just adopting Erlang's wholesale, using Jinterface for Clojure<->Clojure or even Clojure<->Erlang distributed processes. Maybe that will look like Termite when it is done. Stay tuned. "

“即使有演员,Clojure也不会有分布式并发故事,但我正在考虑采用Erlang的批发,使用Jinterface进行Clojure < - > Clojure甚至是Clojure < - > Erlang分布式进程。也许这看起来就像是白蚁已经完成了。请继续关注。“