from.. 2011-05-15 12:15 采纳率: 100%
浏览 275
已采纳

Clojure vs 其他 lisp 语言(关闭)

The intent of my question is not to start a flame war, but rather to determine in what circumstances each language is "the best tool for the job."

I have read several books on Clojure (Programming Clojure, Practical Clojure, The Joy of Clojure, and the Manning Early Access edition of Clojure in Action), and I think it is a fantastic language. I am currently reading Let Over Lambda which mostly deals with Common Lisp macros, and, it too, is a very interesting language.

I am not a Lisp expert (more of a newbie), but this family of languages fascinates me, as does functional programming, in general.

Advantages of Clojure (and disadvantages of "others"):

  • Runs on the JVM.

    • The JVM is a very stable, high-performance language environment that pretty well meets Sun's dream of "Write once, run [almost] anywhere". I can write code on my Macbook Pro, compile it into an executable JAR file, and then run it on Linux and Microsoft Windows with little additional testing.

    • The (Hotspot, and other) JVM supports high-quality garbage collection and very performant just-in-time compilation and optimization. Where just a few years ago, I wrote everything that had to run fast in C, now I do not hesitate to do so in Java.

    • Standard, simple, multithreading model. Does Common Lisp have a standard multithreading package?

    • Breaks up the monotony of all those parentheses with [], {}, and #{}, although Common Lisp experts will probably tell me that with reader macros, you can add those to CL.

Disadvantages of Clojure:

  • Runs on the JVM.
    • No tail recursion or continuations. Does Common Lisp support continuations? Scheme requires support for both, I believe.

Advantages of Others (Common Lisp, in particular) (and disadvantages of Clojure):

  • User-definable reader macros.

  • Other advantages?

Thoughts? Other differences?

转载于:https://stackoverflow.com/questions/6008313/clojure-vs-other-lisps

  • 写回答

4条回答 默认 最新

  • 三生石@ 2011-05-15 14:00
    关注

    My personal list of reasons for preferring Clojure to other Lisps (p.s. I still think all Lisps are great!):

    • Runs on the JVM - hence gets automatic access to the fantastic engineering in the JVM itself (advanced garbage collection algorithms, HotSpot JIT optimisation etc.)

    • Very good Java interoperability - provides compatibility with the huge range of libraries in the Java/JVM language ecosystem. I have used Clojure as a "glue" language to connect different Java libraries with good effect. As I also develop a lot of Java code it is helpful for me that Clojure integrates well with Java tooling (e.g. I use Maven, Eclipse with Counterclockwise plugin for my Clojure development)

    • Nice syntax for vectors [1 2 3], maps {:bob 10, :jane 15} and sets #{"a" "b" "c"} - I consider these pretty essential tools for modern programming (in addition to lists of course!)

    • I personally like the use of square brackets for binding forms: e.g. (defn foo [a b] (+ a b)) - I think it makes code a bit clearer to read.

    • Emphasis on lazy, functional programming with persistent, immutable data structures - in particular all the core Clojure library is designed to support this by default

    • Excellent STM implementation for multi-core concurrency. I believe Clojure has the best concurrency story of any language at the moment (see this video for more elaboration by Rich Hickey himself)

    • It's a Lisp-1 (like Scheme), which I personally prefer (I think in a functional language it makes sense to keep functions and data in the same namespace)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?