I recently found out that I can use any dialect of Lisp for the functional programming course at school, if it follows the Common Lisp standard. Does Clojure follow this standard? Is it too different?
-
5Wouldn't any language that follows the Common Lisp standard be Common Lisp by definition? Or in other words: isn't Common Lisp the only language that follows the common Lisp standard?sepp2k– sepp2k2012-11-18 09:28:45 +00:00Commented Nov 18, 2012 at 9:28
-
Well, that's what my professor told me. "It has to follow that standard" - I didn't made any research about what the standard is or if there are other dialects that follow the standard.Ilea Cristian– Ilea Cristian2012-11-18 09:36:55 +00:00Commented Nov 18, 2012 at 9:36
-
1@sepp2k I'm pretty sure he meant different Common Lisp implementations, which tend to have enough baggage on their own to be called dialects.Cubic– Cubic2012-11-18 10:23:23 +00:00Commented Nov 18, 2012 at 10:23
-
@Cubic: since the different Common Lisp implementations implement the ANSI standard, they are not really dialects. They are extended versions of Common Lisp, because of a large number of extensions. But there are several dialects of Common Lisp implemented, which often provide a subset of Common Lisp or which are based on Common Lisp. Often these dialects are implemented for certain applications as implementation or extension language. Examples are Interleaf Lisp, L, SubL, the second version of XLisp, ThinLisp, ...).Rainer Joswig– Rainer Joswig2012-11-18 15:36:50 +00:00Commented Nov 18, 2012 at 15:36
4 Answers
Clojure does not follow the Common Lisp standard - it is an entirely new Lisp.
That being said, it shares a lot of thing with Common Lisp so knowledge gained in one will be generally applicable to the other.
Many key things are the same:
- Function application by putting a function at the beginning of a list followed by its arguments:
(my-function arg1 arg2) - "Code is data" - code is expressed in homoiconic forms that are also Lisp data structures
- Both have a powerful macro system - you can write functions to generate arbitrary code
- They are dynamic languages,
- Both emphasise interactive development using a REPL
- They are both normally compiled
Some things that are different:
- Clojure has a stronger emphasis on functional programming - all the data structures are immutable and the core library is composed mainly of "pure" functions. Note: you can still use a functional style in Common Lisp, Clojure just puts it more at the forefront
- Clojure is a Lisp-1 (like Scheme functions and data share the same namespace) whereas Common Lisp is a Lisp-2 (functions and data have a different namespace)
- Clojure has new literals for maps
{}, vectors[]and sets#{}in addition to the traditional Lisp lists() - Common Lisp supports reader macros - which gives you greater ability to customise the syntax of the language
- Clojure has a novel approach to managing concurrency, identity and state via STM - see http://www.infoq.com/presentations/Value-Identity-State-Rich-Hickey
- Clojure is designed to "embrace the host platform" (usually the JVM, but also the CLR and recently there has been a lot of interest in targeting JavaScript via ClojureScript) - this is important from a practical perspective as it gives you access to a huge array of libraries / tools.
- There is no Clojure standard - its a BDFL driven language with one primary open source implementation. It helps enormously that Rich Hickey is the BDFL - the guy is a genius.
Subjective opinion: I'm biased but I think that for most modern usage Clojure is definitely the way to go if you are choosing a Lisp nowadays - it's a modern redesign of Lisp, has a very vibrant and innovative community, is a pragmatic choice for "getting things done".
2 Comments
You don't need to use a dialect of Common Lisp. There are lots of excellent implementations of Common Lisp - implementations which provide the full Common Lisp with lots of extensions.
For educational programming with Lisp I would recommend SBCL, which provides an excellent compiler. CCL (Clozure Common Lisp) is another good choice. Both run especially nicely on Linux and Mac OS X.
There are dialects of Common Lisp (like SubL which is used to develop Cyc, a large knowledge-based system) and languages which are related to Common Lisp (like Visual Lisp of AutoCAD , Emacs Lisp of GNU Emacs or ISLisp), but it does not make sense to use them in education. Standard Common Lisp implementations exist plenty and they are excellent.
Clojure is not even a dialect of Common Lisp, it's a different language.
Comments
Clojure is its own language - not an implementation of the Common Lisp language. So it does not follow the Common Lisp standard.
2 Comments
I think that what your professor meant is that some Common Lisp implementations add many extra features that are not part of the standard, and your professor doesn't want you to use those features. So pick any Common Lisp implementation you like, like SBCL or Clozure, etc, and only use actual Common Lisp functions, techniques, etc that are not unique to that particular implementation. In other words, the code you write should theoretically run on any Common Lisp implementation.
Clojure, Scheme, etc are other dialects of Lisp that have their own standards (when applicable, the word "standards" has various levels of strictness depending on your meaning) and are not the same as Common Lisp. That is to say, they certainly do not adhere to the Common Lisp standard.
Frankly, when speaking about Lisp languages, a "dialect" generally refers to an entirely different Lisp language, which would not have the same standard as another dialect. Therefore, to say "different dialects of Common Lisp" makes no sense. However, you can say, "different dialects of Lisp."