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?
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".