Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>They are both pretty much equivalent in terms of what you can do with them, i.e.:</p> <ul> <li>They execute at compile time</li> <li>They can perform arbitrary transformation and generation of code (exploiting the <a href="http://en.wikipedia.org/wiki/Homoiconicity" rel="noreferrer">homoiconicity</a> of Lisp code)</li> <li>They are suitable for "extending the language" with new language constructs or DSLs</li> <li>You feel very powerful, and can be very productive (in the <a href="http://www.paulgraham.com/avg.html" rel="noreferrer">beating the averages</a> way)</li> </ul> <p>And now for some differences:</p> <p>Common Lisp also allows <strong>reader macros</strong> which allow you to change the behaviour of the reader. This allows you to introduce completely new syntax (e.g. for data structure literals). This might be the reason that your friend describes Clojure's macro system as "weaker" since Clojure does not allow reader macros. In Clojure you are basically stuck with the syntax <code>(macro-name ....)</code> but apart from that you can do anything you want. Opinion is divided as to whether reader macros a good thing or not: my personal view is not, as it doesn't give you any extra "power" and has the potential to cause extreme confusion. </p> <p>Clojure has, in my view, a <strong>nicer implementation of namespaces</strong> that I think make Clojure's macro system easier to use. Every symbol in Clojure is namespace-qualified, so different libraries can define the same symbol different in their own namespace. So <code>+</code> can be defined separately as <code>clojure.core/+</code> <code>and my.vector.library/+</code> without any risk of conflicts. In your own namespace, you can <a href="http://clojuredocs.org/clojure_core/clojure.core/use" rel="noreferrer">use</a> definitions from another namespace, which will mean that you can choose to take <code>+</code> from either <code>clojure.core</code> or <code>my.vector.library</code> as needed. </p> <p>Clojure on the other hand has <strong>extra literals</strong> for maps <code>{}</code> and vectors <code>[]</code>. These give you a bit more expressivity (in the sense of concise readable syntax) than traditional Lisp s-expressions. In particular, the use of [] for binding forms is a convention in Clojure that I think works well both for macros and normal code - it makes them stand out clearly from the other parentheses.</p> <p>Clojure is also a <strong>Lisp-1</strong> (like Scheme) so it doesn't have a separate namespace for functions and data. Common Lisp is a <strong>Lisp-2</strong> which has separate function and data namesapces (so you can have both a function called foo and a data item called foo). I slightly prefer the Lisp-1 approach, since it is simpler and the division between code and data seems a bit arbitrary when you are writing in a functional langauge. This is probably a personal taste thing though.</p> <p>Overall, the differences are relatively minor. I think Clojure is a bit simpler and more elegant, whereas Common Lisp has some extra features (use at your own risk!). Both are extremely capable, so you can't go wrong choosing either.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload