From Wikipedia, the free encyclopedia
  (Redirected from Rich Hickey)
Jump to navigation Jump to search
Clojure logo.svg
Designed byRich Hickey
First appeared2007; 12 years ago (2007)
Stable release
1.10[8] / December 17, 2018; 4 months ago (2018-12-17)
Typing discipline
LicenseEclipse Public License
Filename extensions
  • .clj
  • .cljs
  • .cljc
  • .edn
Influenced by

Clojure (/ˈklʒər/, like closure)[13] is a modern, dynamic, and functional dialect of the Lisp programming language on the Java platform.[14][15] Like other Lisps, Clojure treats code as data and has a Lisp macro system.[16] The current development process is community-driven,[17] overseen by Rich Hickey as its benevolent dictator for life (BDFL).[18]

Clojure advocates immutability and immutable data structures and encourages programmers to be explicit about managing identity and its states.[19] This focus on programming with immutable values and explicit progression-of-time constructs is intended to facilitate developing more robust programs, especially multithreaded ones.[20][21] While its type system is entirely dynamic, recent efforts have also sought the implementation of gradual typing.[22]

Commercial support for Clojure is provided by Cognitect.[23] Annual Clojure conferences are organised every year across the globe, the most famous of them being Clojure/conj (US east coast),[24] Clojure/West (US west coast),[25] and EuroClojure (Europe).[26]

History and development process[edit]

Rich Hickey, creator of Clojure

Rich Hickey is the creator of the Clojure language.[14] Before Clojure, he developed dotLisp, a similar project based on the .NET platform,[27] and three earlier attempts to provide interoperability between Lisp and Java: a Java foreign language interface for Common Lisp (jfli),[28] A Foreign Object Interface for Lisp (FOIL),[29] and a Lisp-friendly interface to Java Servlets (Lisplets).[30]

Hickey spent about 2½ years working on Clojure before releasing it publicly, much of that time working exclusively on Clojure with no outside funding. At the end of this time, Hickey sent an email announcing the language to some friends in the Common Lisp community.

The development process is community-driven[17] and is managed at the Clojure Community website.[31] The website contains planning documents and an issue tracker where bugs may be filed. General development discussion occurs at the Clojure Dev Google Group.[32] Anyone can submit bug reports and ideas, but to contribute patches, one must sign the Clojure Contributor agreement.[33] JIRA tickets are processed by a team of screeners and finally Rich Hickey approves the changes.[34]

Design philosophy[edit]

Rich Hickey developed Clojure because he wanted a modern Lisp for functional programming, symbiotic with the established Java platform, and designed for concurrency.[20][21][35]

Clojure's approach to state is characterized by the concept of identities,[36] which are represented as a series of immutable states over time. Since states are immutable values, any number of workers can operate on them in parallel, and concurrency becomes a question of managing changes from one state to another. For this purpose, Clojure provides several mutable reference types, each having well-defined semantics for the transition between states.[19][36]


Version Release date Major features/improvements
2007-10-16[37] Initial public release
1.0 2009-05-04[38] First stable release[39]
1.1 2009-12-31[38] Futures[40]
1.2 2010-08-19[38] Protocols[41]
1.3 2011-09-23[38] Enhanced primitive support[42]
1.4 2012-04-15[38] Reader literals
1.5 2013-03-01[38] Reducers
1.6 2014-03-25[43] Java API, improved hashing algorithms
1.7 2015-06-30[44] Transducers, reader conditionals
1.8 2016-01-19[45] Additional string functions, direct linking, socket server
1.9 2017-12-08[46] Integration with spec, command-line tools
Current stable version: 1.10 2018-12-17[47] Improved error reporting, Java compatibility
Old version
Older version, still supported
Latest version
Latest preview version
Future release

Clojure runs on the Java platform and as a result, integrates with Java and fully supports calling Java code from Clojure,[48] and Clojure code can be called from Java also.[49] The community uses Leiningen[50] for project automation, providing support for Maven integration. Leiningen handles project package management and dependencies and is configured using Clojure syntax.[50]

Like most other Lisps, Clojure's syntax is built on S-expressions that are first parsed into data structures by a reader before being compiled.[51] Clojure's reader supports literal syntax for maps, sets and vectors in addition to lists, and these are compiled to the mentioned structures directly.[51] Clojure is a Lisp-1 and is not intended to be code-compatible with other dialects of Lisp, since it uses its own set of data structures incompatible with other Lisps.[51][52]

As a Lisp dialect, Clojure supports functions as first-class objects, a read–eval–print loop (REPL), and a macro system.[53] Clojure's Lisp macro system is very similar to that in Common Lisp with the exception that Clojure's version of the backquote (termed "syntax quote") qualifies symbols with their namespace. This helps prevent unintended name capture, as binding to namespace-qualified names is forbidden. It is possible to force a capturing macro expansion, but it must be done explicitly. Clojure does not allow user-defined reader macros, but the reader supports a more constrained form of syntactic extension.[54] Clojure supports multimethods[55] and for interface-like abstractions has a protocol[56] based polymorphism and data type system using records,[57] providing high-performance and dynamic polymorphism designed to avoid the expression problem.

Clojure has support for lazy sequences and encourages the principle of immutability and persistent data structures. As a functional language, emphasis is placed on recursion and higher-order functions instead of side-effect-based looping. Automatic tail call optimization is not supported as the JVM does not support it natively;[58][59][60] it is possible to do so explicitly by using the recur keyword.[61] For parallel and concurrent programming Clojure provides software transactional memory,[62] a reactive agent system,[63] and channel-based concurrent programming.[64]

Clojure 1.7 introduced reader conditionals by allowing the embedding of Clojure and ClojureScript code in the same namespace.[44][65] Transducers were added as a method for composing transformations. Transducers enable higher-order functions such as map and fold to generalize over any source of input data. While traditionally these functions operate on sequences, transducers allow them to work on channels and let the user define their own models for transduction.[66][67][68]


The primary platform of Clojure is Java,[15][48] but other target implementations exist. The most notable of these are ClojureScript,[69] which compiles to ECMAScript 3,[70] and ClojureCLR,[71] a full port on the .NET platform, interoperable with its ecosystem. A survey of the Clojure community with 1,060 respondents conducted in 2013[72] found that 47% of respondents used both Clojure and ClojureScript when working with Clojure. In 2014 this number had increased to 55%,[73] in 2015, based on 2,445 respondents, to 66%.[74] Popular ClojureScript projects include implementations of the React library such as Reagent[75] and Om.[76][77]


With the continued interest in functional programming, Clojure's adoption by the software developers on the Java platform has kept increasing. The language has also been either preferred or recommended by renowned software development veterans such as James Gosling,[78] Paul Graham,[79] and Robert C. Martin (also known as “Uncle Bob”.)[80]

In the "JVM Ecsosystem Report 2018" (which was claimed to be "the largest survey ever of Java developers"), prepared in collaboration by Snyk and Java Magazine, Clojure was ranked the 2nd most used programming language (behind Java) for "main applications".[81]

Clojure is used in industry by firms[82] such as Apple,[83][84] Atlassian,[85] Funding Circle,[86] Netflix,[87] Puppet,[88] and Walmart[89] as well as government agencies such as NASA[90]. It has also been used for creative computing, including visual art, music, games, and poetry.[91]

ThoughtWorks, while assessing functional programming languages for their Technology Radar,[92] expressed their favor toward Clojure as "a simple, elegant implementation of Lisp on the JVM" in 2010 and promoted its status to "ADOPT" in 2012.[93]

A growing number of unofficial and experimental implementations for other platforms testify to the popularity of the language:

  • las3r,[94] a subset of Clojure that runs on the ActionScript Virtual Machine (the Adobe Flash Player platform)
  • clojure-py,[95] Clojure in pure Python
  • rouge,[96] Clojure atop YARV in Ruby
  • CljPerl,[97] Clojure atop Perl
  • Pixie, Clojure-inspired Lisp dialect written in RPython
  • Ferret,[98] compiles to self-contained C++11 that can run on microcontrollers
  • Joker,[99] an interpreter and linter written in Go
  • clojerl,[100] Clojure on the Erlang VM


Hello, World! program[edit]

(println "Hello, World!")

Programming at REPL[edit]

Like other Lisps, one of the iconic features of Clojure is interactive programming at the REPL.[101] Note that, in the following examples, ";;" starts a line comment and ";; =>" indicates output:

;; define a var
(def a 42)
;; => #'user/a

;; call a function named `+`
(+ a 8)
;; => 50

;; call a function named `even?`
(even? a)
;; => true

;; define a function that returns the remainder of `n` when divided by 10
(defn foo [n] (rem n 10))
;; => #'user/foo

;; call the function
(foo a)
;; => 2

;; print the docstring of `rem`
(doc rem)
;; =>
([num div])
 remainder of dividing numerator by denominator.

;; print the source of `rem`
(source rem)
;; =>
(defn rem
  "remainder of dividing numerator by denominator."
  {:added "1.0"
   :static true
   :inline (fn [x y] `(. clojure.lang.Numbers (remainder ~x ~y)))}
  [num div]
    (. clojure.lang.Numbers (remainder num div)))

Names at runtime[edit]

Unlike other runtime environments where names get compiled away, Clojure's runtime environment is easily introspectable using normal Clojure data structures:

;; define a var
(def a 42)
;; => #'user/a

;; get a map of all public vars interned in the `user` namespace
(ns-publics 'user)
;; => {a #'user/a}

;; reference the var via `#'` (reader macro) and
;; its associated, namespace-qualified symbol `user/a`
;; => #'user/a

;; de-reference (get the value of) the var
(deref #'user/a)
;; => 42

;; define a function (with a docstring) that
;; returns the remainder of `n` when divided by 10
(defn foo "returns `(rem n 10)`" [n] (rem n 10))
;; => #'user/foo

;; get the metadata of the var `#'user/foo`
(meta #'user/foo)
;; =>
{:arglists ([n]),
 :doc "returns `(rem n 10)`",
 :line 1,
 :column 1,
 :file "user.clj",
 :name foo,
 :ns #namespace[user]}

Code as data (homoiconicity)[edit]

Similar to other Lisps, Clojure is homoiconic (also known as code as data). In the example below, we can see how easy it is to write code that modifies code itself:

;; call a function (code)
(+ 1 1)
;; => 2

;; quote the function call
;; (turning code into data, which is a list of symbols)
(quote (+ 1 1))
;; => (+ 1 1)

;; get the first element on the list
;; (operating on code as data)
(first (quote (+ 1 1)))
;; => +

;; get the last element on the list
;; (operating on code as data)
(last (quote (+ 1 1)))
;; => 1

;; get a new list by replacing the symbols on the original list
;; (manipulating code as data)
(map (fn [form]
       (case form
         1 'one
         + 'plus))
     (quote (+ 1 1)))
;; => (plus one one)

Expressive operators for data transformation[edit]

The threading macros (->, ->>, and friends) can syntactically express the abstraction of piping a collection of data through a series of transformations:

(->> (range 10)
     (map inc)
     (filter even?))
;; => (2 4 6 8 10)

This can also be achieved more efficiently using transducers:

(sequence (comp (map inc)
                (filter even?))
          (range 10))
;; => (2 4 6 8 10)

Thread-safe management of identity and state[edit]

A thread-safe generator of unique serial numbers (though, like many other Lisp dialects, Clojure has a built-in gensym function that it uses internally):

(def i (atom 0))

(defn generate-unique-id
  "Returns a distinct numeric ID for each call."
  (swap! i inc))


An anonymous subclass of that doesn't write to anything, and a macro using it to silence all prints within it:

(def bit-bucket-writer
  (proxy [] []
    (write [buf] nil)
    (close []    nil)
    (flush []    nil)))

(defmacro noprint
  "Evaluates the given `forms` with all printing to `*out*` silenced."
  [& forms]
  `(binding [*out* bit-bucket-writer]

  (println "Hello, nobody!"))
;; => nil

Language interoperability with Java[edit]

Clojure was created from ground up to embrace its host platforms as one of its design goals thus provides excellent language interoperability with Java:

;; call an instance method
(.toUpperCase "apple")
;; => "APPLE"

;; call a static method
(System/getProperty "java.vm.version")
;; => "12+33"

;; create an instance of `java.util.HashMap` and
;; add some entries
(doto (java.util.HashMap.)
  (.put "apple" 1)
  (.put "banana" 2))
;; => {"banana" 2, "apple" 1}

;; create an instance of `java.util.ArrayList` and
;; increment its elements with `clojure.core/map`
(def al (doto (java.util.ArrayList.)
          (.add 1)
          (.add 2)
          (.add 3)))

(map inc al)
;; => (2 3 4)

;; show a message dialog using Java Swing
  "Hello, World!")
;; => nil

Software transactional memory[edit]

10 threads manipulating one shared data structure, which consists of 100 vectors each one containing 10 (initially sequential) unique numbers. Each thread then repeatedly selects two random positions in two random vectors and swaps them. All changes to the vectors occur in transactions by making use of Clojure's software transactional memory system:

(defn run
  [nvecs nitems nthreads niters]
  (let [vec-refs
        (->> (* nvecs nitems)
             (into [] (comp (partition-all nitems)
                            (map vec)
                            (map ref))))

        #(let [v1 (rand-int nvecs)
               v2 (rand-int nvecs)
               i1 (rand-int nitems)
               i2 (rand-int nitems)]
            (let [tmp (nth @(vec-refs v1) i1)]
              (alter (vec-refs v1) assoc i1 (nth @(vec-refs v2) i2))
              (alter (vec-refs v2) assoc i2 tmp))))

        #(->> vec-refs
              (into [] (comp (map deref)
                             (map (fn [v] (prn v) v))
              (println "Distinct:"))]


    (->> #(dotimes [_ niters] (swap))
         (repeat nthreads)
         (apply pcalls)


(run 100 10 10 100000)
;; =>
[0 1 2 3 4 5 6 7 8 9]
[10 11 12 13 14 15 16 17 18 19]
[990 991 992 993 994 995 996 997 998 999]
Distinct: 1000

[382 318 466 963 619 22 21 273 45 596]
[808 639 804 471 394 904 952 75 289 778]
[484 216 622 139 651 592 379 228 242 355]
Distinct: 1000


Tooling for Clojure development has seen significant improvement over the years. The following is a list of the most popular IDEs/editors with their plug-ins that combined provide excellent support for Clojure development:[102]

In addition to the tools provided by the community, the official CLI tools have also become available on GNU/Linux, macOS, and Windows since Clojure 1.9[108]

See also[edit]


  1. ^ Agents and Asynchronous Actions
  2. ^ Concurrent Programming
  3. ^ core.async
  4. ^ Functional Programming
  5. ^ core.logic
  6. ^ Macros
  7. ^ Threading Macros Guide
  8. ^ "Index of /maven2/org/clojure/clojure/1.10.0/". 2018-12-17. Retrieved 2018-12-17.
  9. ^ Fogus, Michael. "Rich Hickey Q&A". Retrieved 2017-01-11.
  10. ^ Hickey, Rich. "Clojure Bookshelf". Listmania!. Retrieved 2017-10-03.
  11. ^ Bonnaire-Sergeant, Ambrose (2012). A Practical Optional Type System for Clojure (Thesis). The University of Western Australia.
  12. ^ "Clojure Programming" (PDF). Retrieved 2013-04-30.
  13. ^ Hickey, Rich. "meaning and pronunciation of Clojure". Google Groups. Retrieved 2012-04-20.
  14. ^ a b Krill, Paul. "Clojure inventor Hickey now aims for Android". Retrieved 2018-11-08.
  15. ^ a b "Clojure – home". Retrieved 2015-09-15.
  16. ^ "Clojure – Lisp". Retrieved 2015-09-15.
  17. ^ a b "Contributing FAQ – Clojure Community – Clojure Development". Retrieved 2015-09-15.
  18. ^ "Clojure – funding". Retrieved 2015-09-15.
  19. ^ a b "Clojure – state". Retrieved 2015-09-15.
  20. ^ a b Hickey, Rich. "Rationale". Retrieved 2008-10-17.
  21. ^ a b Charles (2009-10-06). "Expert to Expert: Rich Hickey and Brian Beckman – Inside Clojure; Going Deep; Channel 9". Retrieved 2012-06-28.
  22. ^ "clojure/core.typed". GitHub. Retrieved 2015-09-15.
  23. ^ "Clojure Programming Language: Cognitect, Clojure Consulting, Clojure Support, Functional Programming, JVM". Retrieved 2015-09-15.
  24. ^ Clojure/conj
  25. ^ Clojure/West
  26. ^ EuroClojure
  27. ^ "[ANN] dotLisp – a Lisp dialect for .Net". Google Groups.
  28. ^ "jfli, a Java foreign language interface for Common Lisp".
  29. ^ "Foil – a Foreign Object Interface for Lisp".
  30. ^ "Lisplets – a Lisp-friendly interface to Java Servlets".
  31. ^ Clojure Community website
  32. ^ Clojure Dev Google Group
  33. ^ "Contributing FAQ – Clojure Community – Clojure Development". Retrieved 2015-09-16.
  34. ^ "JIRA workflow – Clojure Community – Clojure Development". Retrieved 2015-09-16.
  35. ^ "Economy Size Geek – Interview with Rich Hickey, Creator of Clojure". Linux Journal. Retrieved 2015-09-15.
  36. ^ a b Hickey, Rich. "On State and Identity". Retrieved 2010-03-01.
  37. ^ "Clojure: Clojure is Two!". Clojure Blog. Retrieved 2015-09-16.
  38. ^ a b c d e f Fingerhut, Andy. "Clojure version history". Retrieved 2015-09-16.
  39. ^ "Clojure: Clojure 1.0". Clojure Blog. Retrieved 2015-09-16.
  40. ^ "Clojure: Clojure 1.1 Release". Retrieved 2015-09-16.
  41. ^ "Clojure – protocols". Retrieved 2015-09-16.
  42. ^ "Clojure/clojure". GitHub. Retrieved 2015-09-16.
  43. ^ "Google Groups". Retrieved 2015-09-16.
  44. ^ a b "Clojure 1.9". Cognitect. Retrieved 2017-12-08.
  45. ^ "Google Groups". Retrieved 2016-01-25.
  46. ^ "Google Groups". Retrieved 2017-12-08.
  47. ^ "Clojure 1.10 release". Retrieved 2018-12-17.
  48. ^ a b "Clojure – jvm_hosted". Retrieved 2015-09-15.
  49. ^ "Clojure – java_interop". Retrieved 2015-09-15.
  50. ^ a b Hagelberg, Phil; contributors. "Leiningen". Retrieved 2015-09-15.
  51. ^ a b c "Clojure – reader". Retrieved 2015-09-15.
  52. ^ "Clojure – Lisps". Retrieved 2015-09-15.
  53. ^ "Clojure – macros". Retrieved 2015-09-15.
  54. ^ Hickey, Rich. "edn". GitHub. Retrieved 2014-05-24.
  55. ^ "Clojure – multimethods". Retrieved 2015-09-15.
  56. ^ "Clojure – protocols". Retrieved 2015-09-15.
  57. ^ "Clojure – datatypes". Retrieved 2015-09-15.
  58. ^ Goetz, Brian. "Brian Goetz – Stewardship: the Sobering Parts". YouTube: ClojureTV. Retrieved 2015-09-15.
  59. ^ Rose, John. "tail calls in the VM". Retrieved 2018-11-03.
  60. ^ Rose, John. "Some languages need to be able to perform tail calls". JDK Bug System. Retrieved 2018-11-03.
  61. ^ "Clojure – special_forms". Retrieved 2015-09-15.
  62. ^ "Clojure – Refs". Retrieved 2015-09-15.
  63. ^ "Clojure – Agents". Retrieved 2016-07-04.
  64. ^ "Clojure: Clojure core.async Channels". Retrieved 2015-09-15.
  65. ^ "Clojure – reader". Retrieved 2015-09-15.
  66. ^ "Transducers" by Rich Hickey. Retrieved on 2015-09-15.
  67. ^ "Transducers are Coming". Retrieved 2015-09-15.
  68. ^ "Rich Hickey – Inside Transducers". YouTube: Cognitect Inc. 2014-11-20. Retrieved 2015-09-15.
  69. ^ "Clojure/Clojurescript". GitHub. Retrieved 2015-09-15.
  70. ^ "ClojureScript – FAQ (for JavaScript developers)". Retrieved 2018-02-04.
  71. ^ "clojure/clojure-clr". GitHub. Retrieved 2012-06-28.
  72. ^ Emerick, Chas. "Results of the 2013 State of Clojure & ClojureScript survey". Cemerick. Retrieved 2015-09-17.
  73. ^ "State of Clojure 2014 Survey Results". Cognitect Blog. Retrieved 2015-09-17.
  74. ^ "State of Clojure 2015 Survey Results". Cognitect Blog. Retrieved 2016-09-08.
  75. ^ "Reagent". GitHub.
  76. ^ "Om". GitHub.
  77. ^ "Om: Enhancing Facebook's React with Immutability". InfoQ. Retrieved 2015-09-17.
  78. ^ "James Gostling meetup with London Java Community". 2016-10-11. Retrieved 2019-02-10.
  79. ^ Graham, Paul (2016-05-06). "Paul Graham on Twitter". Retrieved 2019-02-10.
  80. ^ Martin, Robert (2018-11-29). "Unble Bob Martin on Twitter". Retrieved 2019-02-10.
  81. ^ Maple, Simon; Binstock, Andrew (2018-10-17). "JVM Ecosystem Report 2018 - Synk". Retrieved 2019-02-10.
  82. ^ "Clojure - Success Stories". Retrieved 2018-10-27.
  83. ^ "Roman Liutikov at Twitter". Twitter. Retrieved 2018-10-27.
  84. ^ "Jobs at Apple". Apple Inc. Retrieved 2018-10-27.
  85. ^ Borges, Leonardo (2015-07-07). "Realtime Collaboration with Clojure". Retrieved 2019-02-10.
  86. ^ "JUXT Blog: Clojure in London: Funding Circle". Retrieved 2017-02-01.
  87. ^ Williams, Alex (2014-08-03). "The New Stack Makers: Adrian Cockcroft on Sun, Netflix, Clojure, Go, Docker and More". Retrieved 2019-02-10.
  88. ^ "A New Era of Application Services at Puppet Labs". Puppet Labs. Retrieved 2015-09-15.
  89. ^ "Walmart Runs Clojure at Scale". Retrieved 2015-09-15.
  90. ^ "nasa/Common-Metadata-Repository". GitHub.
  91. ^ Meier, Carin. "Creative computing with Clojure". O'Reilly Radar. Retrieved 2015-09-17.
  92. ^ "Frequently Asked Questions - Technology Radar - ThoughtWorks". Retrieved 2019-02-10.
  93. ^ "Clojure - Technology Radar - ThoughtWorks". Retrieved 2019-02-10.
  94. ^ aemoncannon (2010-12-30). "Home: aemoncannon/las3r Wiki". GitHub. Retrieved 2012-06-28.
  95. ^ "drewr/clojure-py". GitHub. Retrieved 2017-01-10.
  96. ^ "rouge-lang/rouge". GitHub. Retrieved 2015-12-19.
  97. ^ "A Lisp on Perl". MetaCPAN. Retrieved 2014-05-25.
  98. ^ "Ferret". GitHub.
  99. ^ "Joker". GitHub.
  100. ^ "clojerl". GitHub.
  101. ^ "Programming at the REPL: Introduction". Retrieved 2018-12-04.
  102. ^ Miller, Alex. ""State of Clojure 2018" Results". Retrieved 2018-12-09.
  103. ^ "CIDER: The Clojure Interactive Development Environment that Rocks".
  104. ^ "Cursive: IntelliJ IDEA plug-in for Clojure(Script)".
  105. ^ "fireplace.vim: Clojure REPL Support".
  106. ^ "Calva: Clojure(Script) Interactive Programming".
  107. ^ "LightTable: The Next Generation Code Editor".
  108. ^ Clojure - Deps and CLI Guide

Further reading[edit]

External links[edit]

Official website Edit this at Wikidata