Clojure vs Other Lisps

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

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

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

The advantages of Clojure (and the disadvantages of "others"):

  • Powered by JVM.

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

    • JVM (Hotspot et al.) Supports high-quality garbage collection and very efficient on-time compilation and optimization. Where, just a few years ago, I wrote everything that needed to be run quickly in C, now I'm not shy about doing it in Java.

    • Standard, simple, multi-threaded model. Does Common Lisp have a standard multi-threaded package?

    • The monotony of all these parentheses with [] , {} and #{} interrupts, although Common Lisp experts will probably tell me that with the help of reader macros you can add them to the CL.

Disadvantages of Clojure :

  • Powered by JVM.
    • No tail recursion or continuation. Does Common Lisp support continuation of continuation? I believe that the scheme requires support for both.

The advantages of others (general Lisp in particular) (and the disadvantages of Clojure):

  • User-defined reader macros.

  • Other benefits?

Thoughts? Other differences?

+70
comparison lisp clojure scheme common-lisp
May 15 '11 at 12:15
source share
4 answers

My personal list of reasons to prefer Clojure over other Lisps (ps I still think all Lisps are great!):

  • It works on the JVM - therefore, it gets automatic access to the fantastic engineering in the JVM itself (advanced garbage collection algorithms, JS HotSpot optimization, etc.).

  • Very good compatibility with Java - provides compatibility with a huge set of libraries in the Java / JVM language ecosystem. I used Clojure as an โ€œadhesiveโ€ language to connect various Java libraries with good effect. Since I also develop a lot of Java code, it is useful for me that Clojure integrates well with Java tools (for example, I use Maven, Eclipse with a counterclockwise plugin to develop Clojure)

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

  • I personally like the use of square brackets for linking forms: for example, (defn foo [ab] (+ ab)) - I think it makes the code more readable.

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

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

  • This is a Lisp -1 (e.g. Scheme), which I personally prefer (I think in a functional language it makes sense to store functions and data in the same namespace)

+40
May 15 '11 at 14:00
source share

An important difference between Clojure and Common Lisp is that Clojure is more about functional programming. Clojure philosophy, idioms and, to some extent, language / libraries strongly encourage and sometimes insist that you program functionally (no side effects, no volatile state).

Generic Lisp definitely supports functional programming, but also allows state-changing and imperative programming.

Of course, there are a number of advantages for functional programming in the field of concurrency and otherwise. But ceteris paribus it is also good to have a choice of which approach you want to use for each situation. Clojure does not completely prohibit imperative programming, but it is less suited to this style than Common Lisp.

+20
May 15 '11 at 12:23
source share

Keep in mind that Clojure is a language and implementation (usually in the JVM). Common Lisp is a language with over ten different implementations. So, we have a category mismatch right here. For example, you can compare Clojure with SBCL.

Generally:

  • version of Common Lisp runs on JVM: ABCL

  • most other common lisp implementations don't

  • most CL implementations have multitasking capabilities, the library provides a common interface

  • Generic Lisp has syntax for arrays. The syntax for other data types can be written by the user and provided by various libraries.

  • Common Lisp do not support tail call optimization or continuation. Implementations provide TCOs and libraries that provide some form of continuation.

+16
May 15 '11 at 15:25
source share

Here's a good video comparing the circuitry (mainly Racket) and Clojure .

To be fair, Racket has syntactic sugar (extra reading material) for data types too (#hash, #, square brackets, etc.)

Plus, Clojure's only way to make the right tail call is to use recur , which is a drawback to compiling in the JVM.

Note that recur is the only non-stack loop construct in Clojure. No tail optimization and using self-start to loop unknown boundaries is not recommended. recur and its use in the tail position is checked by the compiler. ( Special forms ).

+9
May 15 '11 at 14:28
source share



All Articles