Clojure: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
No edit summary
Tags: Mobile edit Mobile web edit
GreenC bot (talk | contribs)
Reformat 1 URL (Wayback Medic 2.5)
(54 intermediate revisions by 24 users not shown)
Line 1: Line 1:
{{short description|Dialect of the Lisp programming language on the Java platform}}
{{Short description|Dialect of the Lisp programming language on the Java platform}}
{{for|similar-sounding names|Closure (disambiguation){{!}}closure}}

{{Infobox programming language
{{Infobox programming language
| name = Clojure
| name = Clojure
| logo = Clojure logo.svg
| logo = Clojure logo.svg
| logo size = 120px
| logo size = 120px
| paradigm = [[multi-paradigm programming language|multi-paradigm]]:
| paradigm = [[Multi-paradigm programming language|multi-paradigm]]:
{{flatlist|
{{flatlist|
* [[agent-oriented programming|agent-oriented]]<ref name="reference/agents">{{cite web |url=https://clojure.org/reference/agents |website=Clojure.org |title=Agents and Asynchronous Actions |access-date=2019-07-07}}</ref>
* [[agent-oriented programming|agent-oriented]]<ref name="reference/agents">{{cite web |url=https://clojure.org/reference/agents |title=Agents and Asynchronous Actions |website=Clojure.org |access-date=2019-07-07}}</ref>
* [[concurrent programming|concurrent]]<ref>{{cite web |url=https://clojure.org/about/concurrent_programming |website=Clojure.org |title=Concurrent Programming |access-date=2019-07-07}}</ref><ref>{{cite web |url=https://github.com/clojure/core.async |website=GitHub.com |title=core.async |last1=Hickey |first1=Rich |author2=((contributors)) |access-date=2019-07-07}}</ref>
* [[Concurrent programming|concurrent]]<ref>{{cite web |url=https://clojure.org/about/concurrent_programming |title=Concurrent Programming |website=Clojure.org |access-date=2019-07-07}}</ref><ref>{{cite web |url=https://github.com/clojure/core.async |title=core.async |last1=Hickey |first1=Rich |author2=((contributors)) |website=[[GitHub]] |access-date=2019-07-07}}</ref>
* [[functional programming|functional]]<ref>{{cite web |url=https://clojure.org/about/functional_programming |website=Clojure.org |title=Functional Programming |access-date=2019-07-07}}</ref>
* [[Functional programming|functional]]<ref>{{cite web |url=https://clojure.org/about/functional_programming |title=Functional Programming |website=Clojure.org |access-date=2019-07-07}}</ref>
* [[logic programming|logic]]<ref>{{cite web |url=https://github.com/clojure/core.logic/ |website=GitHub.com |title=core.logic |last1=Nolen |first1=David |last2=Hickey |first2=Rich |access-date=2019-07-07}}</ref>
* [[Logic programming|logic]]<ref>{{cite web |url=https://github.com/clojure/core.logic/ |title=core.logic |last1=Nolen |first1=David |last2=Hickey |first2=Rich |website=GitHub |access-date=2019-07-07}}</ref>
* [[macro (computer science)|macro]]<ref name="reference/macros">{{cite web |url=https://clojure.org/reference/macros |website=Clojure.org |title=Macros |access-date=2019-07-07}}</ref>
* [[Macro (computer science)|macro]]<ref name="reference/macros">{{cite web |url=https://clojure.org/reference/macros |title=Macros |website=Clojure.org |access-date=2019-07-07}}</ref>
* [[pipeline (software)|pipeline]]<ref>{{cite web |url=https://clojure.org/guides/threading_macros |website=Clojure.org |title=Threading Macros Guide |last=Esterhazy |first=Paulus |access-date=2019-07-07}}</ref>
* [[Pipeline (software)|pipeline]]<ref>{{cite web |url=https://clojure.org/guides/threading_macros |title=Threading Macros Guide |last=Esterhazy |first=Paulus |website=Clojure.org |access-date=2019-07-07}}</ref>
}}
}}
| family = [[Lisp (programming language)|Lisp]]
| family = [[Lisp (programming language)|Lisp]]
| designer = [[Rich Hickey]]
| released = {{Start date and age|2007}}
| released = {{Start date and age|2007}}
| latest release version = 1.11.2<ref name="release/clojure1-11-2"/>
| designer = [[Rich Hickey]]
| latest release version = 1.11.1<ref name="release/clojure1-11-0" />
| latest release date = {{start date and age|2024|03|08|df=yes}}
| latest release date = {{start date and age|2022|04|05|df=yes}}
| typing = {{flatlist|
| typing = {{flatlist|
* [[dynamic typing|dynamic]]
* [[Dynamic typing|dynamic]]
* [[strong typing|strong]]
* [[Strong and weak typing|strong]]
}}
}}
| memory management = [[Garbage collection (computer science)|Garbage collection]] via a host ([[Java Virtual Machine|JVM]], [[Common Language Runtime|CLR]], a [[JavaScript]] runtime such as [[V8 (JavaScript engine)|V8]] in case of ClojureScript or [[BEAM (Erlang virtual machine)|BEAM]] (see [[#Alternative platforms|below]])
| implementations =
| dialects =
| dialects = ClojureScript, ClojureDart
| influenced by = {{flatlist|
| influenced by = {{flatlist|
* [[C Sharp (programming language)|C#]]
* [[C Sharp (programming language)|C#]]
* [[C++]]<ref>{{cite web |url=http://www.codequarterly.com/2011/rich-hickey/ |website=CodeQuarterly.com |title=Rich Hickey Q&A |last=Fogus |first=Michael |year=2011 |archive-url=https://web.archive.org/web/20170111184835/http://www.codequarterly.com/2011/rich-hickey/ |archive-date=2017-01-11}}</ref>
* [[C++]]<ref>{{cite web |url=http://www.codequarterly.com/2011/rich-hickey/ |title=Rich Hickey Q&A |last=Fogus |first=Michael |year=2011 |website=CodeQuarterly.com |archive-url=https://web.archive.org/web/20170111184835/http://www.codequarterly.com/2011/rich-hickey/ |archive-date=2017-01-11}}</ref>
* [[Common Lisp]]
* [[Common Lisp]]
* [[Erlang (programming language)|Erlang]]
* [[Erlang (programming language)|Erlang]]
* [[Haskell]]<ref>{{cite web |url=https://youtube.com/watch?v=LKtk3HCgTa8 |title=Simple Made Easy |last=Hickey |first=Rich |year=2011 |website=YouTube |note=In one of the slides, Hickey compares Clojure protocols to Haskell typeclasses. Mirror URL: https://youtube.com/watch?v=SxdOUGdseq4 }}</ref>
* [[Haskell (programming language)|Haskell]]
* [[Java (programming language)|Java]]
* [[Java (programming language)|Java]]
* [[ML (programming language)|ML]]
* [[ML (programming language)|ML]]
* [[Prolog]]
* [[Prolog]]
* [[Racket (programming language)|Racket]]<ref>{{cite thesis |last=Bonnaire-Sergeant |first=Ambrose |title=A Practical Optional Type System for Clojure |publisher=The University of Western Australia |year=2012}}</ref>
* [[Racket (programming language)|Racket]]<ref>{{cite thesis |last=Bonnaire-Sergeant |first=Ambrose |title=A Practical Optional Type System for Clojure |publisher=The University of Western Australia |year=2012}}</ref>
* [[Ruby (programming language)|Ruby]]<ref>{{cite web |url=http://cdn.oreilly.com/oreilly/booksamplers/9781449394707_sampler.pdf |website=OReilly.com |title=Clojure Programming |access-date=2013-04-30}}</ref>
* [[Ruby (programming language)|Ruby]]<ref>{{cite web |url=http://cdn.oreilly.com/oreilly/booksamplers/9781449394707_sampler.pdf |title=Clojure Programming |website=OReilly.com |access-date=2013-04-30}}</ref>
* [[Scheme (programming language)|Scheme]]
* [[Scheme (programming language)|Scheme]]
* [[Wolfram Language]]<ref>{{cite web |url=https://www.amazon.com/gp/richpub/listmania/fullview/R3LG3ZBZS4GCTH |website=Amazon.com |title=Clojure Bookshelf |last=Hickey |first=Rich |archive-url=https://web.archive.org/web/20171003001051/https://www.amazon.com/gp/richpub/listmania/fullview/R3LG3ZBZS4GCTH |archive-date=2017-10-03 |access-date=2019-07-07}}</ref>
* [[Wolfram Language]]<ref>{{cite web |url=https://www.amazon.com/gp/richpub/listmania/fullview/R3LG3ZBZS4GCTH |title=Clojure Bookshelf |website=Amazon.com |last=Hickey |first=Rich |archive-url=https://web.archive.org/web/20171003001051/https://www.amazon.com/gp/richpub/listmania/fullview/R3LG3ZBZS4GCTH |archive-date=2017-10-03 |access-date=2019-07-07}}</ref>
}}
}}
| influenced = {{flatlist|
| influenced = {{flatlist|
* [[Elixir (programming language)|Elixir]]
* [[Elixir (programming language)|Elixir]]
* [[Hy]]
* [[Hy]]
* Janet<ref>{{cite web|url=https://janet-lang.org/ |website=Janet-Lang.org |title=Janet Language |last=Rose |first=Calvin |author2=((contributors)) |access-date=2023-02-18}}</ref>
* Janet<ref>{{cite web |url=https://janet-lang.org/ |title=Janet Language |last1=Rose |first1=Calvin |author2=((contributors)) |website=Janet-Lang.org |access-date=2023-02-18}}</ref>
* [[LFE (programming language)|LFE]]
* [[LFE (programming language)|LFE]]
* Pixie<ref>{{cite web |url=https://www.pixielang.org/ |website=PixieLang.org |title=Pixie |last=Baldridge |first=Timothy |access-date=2019-07-07}}</ref>
* Pixie<ref>{{cite web |url=https://www.pixielang.org/ |title=Pixie |last=Baldridge |first=Timothy |website=PixieLang.org |access-date=2019-07-07}}</ref>
* Rhine<ref>{{cite web |url=https://github.com/artagnon/rhine-ml |website=GitHub.org |title=Rhine |last=Ramachandra |first=Ramkumar |access-date=2019-07-07}}</ref>
* Rhine<ref>{{cite web |url=https://github.com/artagnon/rhine-ml |title=Rhine |last=Ramachandra |first=Ramkumar |website=[[GitHub]] |access-date=2019-07-07}}</ref>
}}
}}
| platform = {{flatlist|
| platform = {{flatlist|
Line 53: Line 51:
* [[.NET]]
* [[.NET]]
}}
}}
| license = [[Eclipse Public License]]
| license = [[Eclipse Public License|Eclipse Public]]
| website = {{URL|https://clojure.org}}
| website = {{URL|https://clojure.org}}
| file ext = {{flatlist|
| file ext = {{flatlist|
* .clj
* .clj
* .cljs
* .cljs
* .cljr
* .cljc
* .cljc
* .cljd
* .edn
* .edn
}}
}}
Line 64: Line 64:
}}
}}


'''Clojure''' ({{IPAc-en|ˈ|k|l|oʊ|ʒ|ər}}, like ''closure'')<ref name="interview/a-z">{{cite web |url=https://www.computerworld.com.au/article/313989/a-z_programming_languages_clojure/ |website=Computerworld.com.au |title=The A-Z of Programming Languages: Clojure |last=Edwards |first=Kathryn |date=2009-08-10 |archive-url=https://web.archive.org/web/20190826190240/https://www.computerworld.com.au/article/313989/a-z_programming_languages_clojure/ |archive-date=2019-08-26}}</ref><ref name="clojure-meaning-pronunciation">{{cite web |url=https://groups.google.com/d/msg/clojure/4uDxeOS8pwY/UHiYp7p1a3YJ |website=Google.com |title=meaning and pronunciation of Clojure |last=Hickey |first=Rich |date=2009-01-05}}</ref> is a [[dynamic programming language|dynamic]] and [[functional programming|functional]] [[dialect (computing)|dialect]] of the [[Lisp (programming language)|Lisp programming language]] on the [[Java (software platform)|Java]] platform.<ref name="platform/android">{{cite web |url=https://www.infoworld.com/article/2619641/clojure-inventor-hickey-now-aims-for-android.html |website=InfoWorld.com |title=Clojure inventor Hickey now aims for Android |last=Krill |first=Paul |date=2012-03-22}}</ref><ref name="clojure.org">{{cite web |url=https://clojure.org/ |title=Clojure |website=Clojure.org |access-date=2019-07-07}}</ref>
'''Clojure''' ({{IPAc-en|ˈ|k|l|oʊ|ʒ|ər}}, like ''closure'')<ref name="interview/a-z">{{cite web |url=https://www.computerworld.com.au/article/313989/a-z_programming_languages_clojure/ |title=The A-Z of Programming Languages: Clojure |last=Edwards |first=Kathryn |date=2009-08-10 |website=Computerworld.com.au |archive-url=https://web.archive.org/web/20190826190240/https://www.computerworld.com.au/article/313989/a-z_programming_languages_clojure/ |archive-date=2019-08-26}}</ref><ref name="clojure-meaning-pronunciation">{{cite web |url=https://groups.google.com/d/msg/clojure/4uDxeOS8pwY/UHiYp7p1a3YJ |title=meaning and pronunciation of Clojure |last=Hickey |first=Rich |date=2009-01-05 |website=Google.com}}</ref> is a [[dynamic programming language|dynamic]] and [[functional programming|functional]] [[dialect (computing)|dialect]] of the [[Lisp (programming language)|Lisp programming language]] on the [[Java (software platform)|Java]] platform.<ref name="platform/android">{{cite web |url=https://www.infoworld.com/article/2619641/clojure-inventor-hickey-now-aims-for-android.html |title=Clojure inventor Hickey now aims for Android |last=Krill |first=Paul |date=2012-03-22 |website=InfoWorld.com}}</ref><ref name="clojure.org">{{cite web |url=https://clojure.org/ |title=Clojure |website=Clojure.org |access-date=2019-07-07}}</ref>


Like most other Lisps, Clojure's syntax is built on [[S-expression]]s that are first parsed into data structures by a reader before being compiled.<ref name="reference/reader">{{cite web |url=https://clojure.org/reference/reader |title=The Reader |website=Clojure.org |access-date=2019-07-07}}</ref><ref name="interview/a-z"/> Clojure's [[Lisp reader|reader]] supports literal syntax for [[hash table|maps]], sets and [[Array data structure|vectors]] along with lists, and these are compiled to the mentioned structures directly.<ref name="reference/reader"/> Clojure treats [[Homoiconicity|code as data]] and has a [[Lisp macro]] system.<ref name="reference/lisps">{{cite web |url=https://clojure.org/reference/lisps |title=Differences with other Lisps |website=Clojure.org |access-date=2019-07-07}}</ref> 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.<ref name="reference/lisps"/>
==History and development process==

Clojure advocates [[immutable object|immutability]] and [[persistent data structure|immutable data structures]] and encourages programmers to be explicit about managing identity and its states.<ref name="about/state">{{cite web |url=https://clojure.org/about/state |title=Values and Change: Clojure's approach to Identity and State |website=Clojure.org |access-date=2019-07-07}}</ref> This focus on programming with immutable values and explicit progression-of-time constructs is intended to facilitate developing more robust, especially [[concurrent programming|concurrent]], programs that are simple and fast.<ref name="about/rationale">{{cite web |url=https://clojure.org/about/rationale |title=Rationale |last=Hickey |first=Rich |website=Clojure.org |access-date=2019-07-07}}</ref><ref name="msdn/inside-clojure">{{cite web |url=https://channel9.msdn.com/shows/Going+Deep/Expert-to-Expert-Rich-Hickey-and-Brian-Beckman-Inside-Clojure/ |title=Expert to Expert: Rich Hickey and Brian Beckman – Inside Clojure |last=Torre |first=Charles |date=2009-10-06 |website=MSDN.com}}</ref><ref name="interview/a-z"/> While its type system is entirely [[Type system|dynamic]], recent efforts have also sought the implementation of a [[Dependent type|dependent type system]].<ref>{{Cite web |url=https://github.com/clojure/spec.alpha |title=clojure/spec.alpha |date=2017-04-26 |website=[[GitHub]]}}</ref>

The language was created by [[Rich Hickey]] in the mid-2000s, originally for the Java platform; the language has since been ported to other platforms, such as the [[Common Language Runtime]] (.NET). Hickey continues to lead development of the language as its [[benevolent dictator for life]].

== History ==
[[File:Rich Hickey.jpg|thumb|Rich Hickey, creator of Clojure]]
[[File:Rich Hickey.jpg|thumb|Rich Hickey, creator of Clojure]]
[[Rich Hickey]] is the creator of the Clojure language.<ref name="platform/android" /> Before Clojure, he developed dotLisp, a similar project based on the [[Common Language Infrastructure|.NET]] platform,<ref>{{cite web |url=https://groups.google.com/forum/#!topic/comp.lang.scheme/ibf6CC6V66o |website=Google.com |title=[ANN] dotLisp – a Lisp dialect for .Net |last=Hickey |first=Rich |date=2002-10-16}}</ref> and three earlier attempts to provide interoperability between Lisp and [[Java (programming language)|Java]]: a ''Java foreign language interface for [[Common Lisp]]'' (jfli),<ref>{{cite web |url=https://sourceforge.net/projects/jfli/ |website=SourceForge.net |title=jfli |last=Hickey |first=Rich |date=2013-04-15}}</ref> A ''Foreign Object Interface for Lisp'' (FOIL),<ref>{{cite web |url=https://sourceforge.net/projects/foil/ |website=SourceForge.net |title=foil - Foreign Object Interface for Lisp |last=Hickey |first=Rich |date=2013-04-03}}</ref> and a ''Lisp-friendly interface to Java Servlets'' (Lisplets).<ref>{{cite web |url=https://sourceforge.net/projects/lisplets/ |website=SourceForge.net |title=Lisplets |last=Hickey |first=Rich |date=2013-03-07}}</ref>


[[Rich Hickey]] is the creator of the Clojure language.<ref name="platform/android"/> Before Clojure, he developed <code>dotLisp</code>, a similar project based on the [[.NET]] platform,<ref>{{cite web |url=https://groups.google.com/forum/#!topic/comp.lang.scheme/ibf6CC6V66o |title=[ANN] dotLisp: A Lisp dialect for .Net |last=Hickey |first=Rich |date=2002-10-16 |website=Google.com}}</ref> and three earlier attempts to provide interoperability between Lisp and [[Java (programming language)|Java]]: a ''Java foreign language interface for [[Common Lisp]]'' (<code>jfli</code>),<ref>{{cite web |url=https://sourceforge.net/projects/jfli/ |title=jfli |last=Hickey |first=Rich |date=2013-04-15 |website=SourceForge.net}}</ref> A ''Foreign Object Interface for Lisp'' (FOIL),<ref>{{cite web |url=https://sourceforge.net/projects/foil/ |title=foil: Foreign Object Interface for Lisp |last=Hickey |first=Rich |date=2013-04-03 |website=SourceForge.net}}</ref> and a ''Lisp-friendly interface to Java Servlets'' (Lisplets).<ref>{{cite web |url=https://sourceforge.net/projects/lisplets/ |title=Lisplets |last=Hickey |first=Rich |date=2013-03-07 |website=SourceForge.net}}</ref>
Hickey spent about two and a half years working on Clojure before releasing it publicly in October 2007,<ref name="clojure history">{{cite journal |last1=Hickey |first1=Rich |date=2020-06-12 |title=A history of Clojure |url=https://dl.acm.org/doi/10.1145/3386321 |journal=Proceedings of the ACM on Programming Languages |volume=4 |issue=HOPL |pages=1–46 |doi=10.1145/3386321 |s2cid=219603760 |access-date=2022-05-07}}</ref> 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.


Hickey spent about two and a half years working on Clojure before releasing it publicly in October 2007,<ref name="clojure history">{{cite journal |last1=Hickey |first1=Rich |date=2020-06-12 |title=A history of Clojure |journal=Proceedings of the ACM on Programming Languages |volume=4 |issue=HOPL |pages=1–46 |doi=10.1145/3386321 |s2cid=219603760 |doi-access=free }}</ref> 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<ref name="dev/dev" /> and is managed at the Clojure [[Jira (software)|JIRA]] project page.<ref>{{cite web |url=https://clojure.atlassian.net/projects/CLJ |website=Atlassian.net |title=Clojure |access-date=2019-07-07}}</ref> General development discussion occurs at the Clojure Google Group.<ref>{{cite web |url=https://groups.google.com/forum/#!forum/clojure |website=Google.com |title=Clojure |access-date=2019-07-07}}</ref> Anyone can ask questions or submit issues and ideas at ask.clojure.org,<ref>{{cite web |url=https://clojure.org/news/2019/07/25/clojure-forum |website=clojure.org |title=Clojure Forum |access-date=2020-03-20}}</ref> but to contribute patches, one must sign the Clojure Contributor agreement.<ref>{{cite web |url=https://clojure.org/dev/contributor_agreement |website=Clojure.org |title=Contributor Agreement |access-date=2019-07-07}}</ref> JIRA issues are processed by a team of screeners and finally approved by Rich Hickey as the [[benevolent dictator for life]] (BDFL).<ref>{{cite web |url=https://gist.github.com/richhickey/1563cddea1002958f96e7ba9519972d9 |website=GitHub.com |title=Open Source is Not About You |last=Hickey |first=Rich |date=2018-11-26}}</ref><ref>{{cite web |url=https://clojure.org/dev/workflow |website=Clojure.org |title=Workflow |access-date=2019-07-07}}</ref>


Clojure's name, according to Hickey, is a [[word play]] on the programming concept "[[Closure (computer programming)|closure]]" incorporating the letters C, L, and J for [[C Sharp (programming language)|C#]], [[Lisp (programming language)|Lisp]], and [[Java (programming language)|Java]] respectively—three languages which had a major influence on Clojure's design.<ref name="clojure-meaning-pronunciation" />
Clojure's name, according to Hickey, is a [[word play]] on the programming concept "[[Closure (computer programming)|closure]]" incorporating the letters C, L, and J for [[C Sharp (programming language)|C#]], [[Lisp (programming language)|Lisp]], and [[Java (programming language)|Java]] respectively—three languages which had a major influence on Clojure's design.<ref name="clojure-meaning-pronunciation"/>


==Design philosophy==
== Design ==
Rich Hickey developed Clojure because he wanted a modern [[Lisp (programming language)|Lisp]] for [[functional programming]], symbiotic with the established [[Java (software platform)|Java]] platform, and designed for [[Concurrency (computer science)|concurrency]].<ref name="about/rationale" /><ref name="msdn/inside-clojure" /><ref>{{cite web |url=https://www.linuxjournal.com/article/10708 |website=LinuxJournal.com |title=Economy Size Geek – Interview with Rich Hickey, Creator of Clojure |last=Elmendorf |first=Dirk |date=2010-04-01}}</ref><ref name="interview/a-z" />


Rich Hickey developed Clojure because he wanted a modern [[Lisp (programming language)|Lisp]] for [[functional programming]], symbiotic with the established [[Java (software platform)|Java]] platform, and designed for [[Concurrency (computer science)|concurrency]].<ref name="about/rationale"/><ref name="msdn/inside-clojure"/><ref>{{cite web |url=https://www.linuxjournal.com/article/10708 |website=LinuxJournal.com |title=Economy Size Geek – Interview with Rich Hickey, Creator of Clojure |last=Elmendorf |first=Dirk |date=2010-04-01}}</ref><ref name="interview/a-z"/> He has also stressed the importance of simplicity in programming language design and software architecture, advocating for [[loose coupling]], [[Polymorphism (computer science)|polymorphism]] via [[Type class|protocols and type classes]] instead of [[Inheritance (object-oriented programming)|inheritance]], [[Pure function|stateless functions]] that are [[Namespace|namespaced]] instead of [[Method (computer programming)|methods]] or [[Data-driven programming|replacing syntax with data]].<ref>{{Cite web |title=Simple Made Easy |url=https://www.infoq.com/presentations/Simple-Made-Easy/ |access-date=2024-05-02 |website=InfoQ |language=en}}</ref><ref>{{Cite web |title=(iterate think thoughts): Advantages of Data Oriented Programming |url=https://yogthos.net/posts/2020-04-08-advantages-of-data-oriented-programming.html |access-date=2024-05-02 |website=yogthos.net}}</ref><ref>{{Cite web |title=talk-transcripts/Hickey_Rich/EffectivePrograms.md at master · matthiasn/talk-transcripts |url=https://github.com/matthiasn/talk-transcripts/blob/master/Hickey_Rich/EffectivePrograms.md |access-date=2024-05-02 |website=GitHub |language=en}}</ref>
Clojure's approach to [[State (computer science)|state]] is characterized by the concept of identities,<ref name="about/state" /> 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 type]]s, each having well-defined semantics for the transition between states.<ref name="about/state" />

Clojure's approach to [[State (computer science)|state]] is characterized by the concept of identities,<ref name="about/state"/> 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 type]]s, each having well-defined semantics for the transition between states.<ref name="about/state"/>

Clojure runs on the [[Java (software platform)|Java]] platform and as a result, integrates with [[Java (programming language)|Java]] and fully supports calling Java code from Clojure,<ref name="about/jvm_hosted">{{cite web |url=https://clojure.org/about/jvm_hosted |website=Clojure.org |title=Hosted on the JVM |access-date=2019-07-07}}</ref><ref name="interview/a-z"/> and Clojure code can be called from Java, too.<ref>{{cite web |url=https://clojure.org/reference/java_interop#_calling_clojure_from_java |title=Java Interop |website=Clojure.org |access-date=2019-07-07}}</ref> The community uses tools such as Clojure [[command-line interface]] (CLI)<ref name="guides/deps_and_cli"/> or [[Leiningen (software)|Leiningen]] for project automation, providing support for [[Apache Maven|Maven]] integration. These tools handle project package management and dependencies and are configured using Clojure syntax.

As a Lisp dialect, Clojure supports [[Function (programming)|functions]] as [[first-class function|first-class objects]], a [[read–eval–print loop]] (REPL), and a macro system.<ref name="reference/macros"/> Clojure's [[Lisp macro]] system is very similar to that of [[Common Lisp]] with the exception that Clojure's version of the [[Grave accent#Use in programming|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.<ref>{{cite web |url=https://github.com/edn-format/edn |website=GitHub |title=edn |last=Hickey |first=Rich |access-date=2019-07-07}}</ref> Clojure supports [[Multiple dispatch|multimethods]]<ref>{{cite web |url=https://clojure.org/reference/multimethods |website=Clojure.org |title=Multimethods and Hierarchies |access-date=2019-07-07}}</ref> and for [[Software Interface|interface]]-like abstractions has a [[Protocol (object-oriented programming)|protocol]]<ref>{{cite web |url=https://clojure.org/reference/protocols |website=Clojure.org |title=Protocols |access-date=2019-07-07}}</ref> based polymorphism and data type system using [[Record (computer science)|records]],<ref>{{cite web |url=https://clojure.org/reference/datatypes |website=Clojure.org |title=Datatypes: deftype, defrecord and reify |access-date=2019-07-07}}</ref> providing high-performance and dynamic polymorphism designed to avoid the [[expression problem]].

Clojure has support for [[lazy evaluation|lazy sequences]] and encourages the principle of [[immutable object|immutability]] and [[persistent data structure]]s. As a [[Functional programming|functional language]], emphasis is placed on [[recursion]] and [[higher-order function]]s instead of side-effect-based looping. Automatic [[tail call]] optimization is not supported as the JVM does not support it natively;<ref>{{cite web |url=https://www.youtube.com/watch?v=2y5Pv4yN0b0&t=1h02m18s |title=Stewardship: the Sobering Parts |website=YouTube.com |last=Goetz |first=Brian |date=2014-11-20}}</ref><ref>{{cite web |url=https://blogs.oracle.com/jrose/tail-calls-in-the-vm |website=Oracle.com |title=tail calls in the VM |last=Rose |first=John |date=2007-07-12}}</ref><ref>{{cite web |url=https://bugs.openjdk.java.net/browse/JDK-6804517 |website=Java.net |title=Some languages need to be able to perform tail calls |last=Rose |first=John |date=2009-02-11}}</ref> it is possible to do so explicitly by using the <code>recur</code> keyword.<ref>{{cite web |url=https://clojure.org/reference/special_forms#recur |website=Clojure.org |title=Special Forms |access-date=2019-07-07}}</ref> For [[Parallel computing|parallel]] and [[Concurrent computing|concurrent]] programming Clojure provides [[software transactional memory]],<ref>{{cite web |url=https://clojure.org/refs |website=Clojure.org |title=Refs and Transactions |access-date=2019-07-07}}</ref> a reactive [[Agent-based model|agent system]],<ref name="reference/agents"/> and [[Communicating sequential processes|channel]]-based concurrent programming.<ref>{{cite web |url=https://clojure.org/news/2013/06/28/clojure-clore-async-channels |website=Clojure.org |title=Clojure core.async Channels |last=Hickey |first=Rich |date=2013-06-28}}</ref>

Clojure 1.7 introduced reader conditionals by allowing the embedding of Clojure, ClojureScript and ClojureCLR code in the same namespace.<ref name="release/clojure-17"/><ref name="reference/reader"/> Transducers were added as a method for composing transformations. Transducers enable higher-order functions such as [[Map (higher-order function)|map]] and [[Fold (higher-order function)|fold]] to generalize over any source of input data. While traditionally these functions operate on [[List (abstract data type)|sequences]], transducers allow them to work on channels and let the user define their own models for transduction.<ref>{{cite web |url=https://www.youtube.com/watch?v=6mTbuzafcII |website=YouTube.com |title=Transducers |last=Hickey |first=Rich |date=2014-09-17}}</ref><ref>{{cite web |url=https://blog.cognitect.com/blog/2014/8/6/transducers-are-coming |website=Cognitect.com |title=Transducers are Coming |last=Hickey |first=Rich |date=2014-08-06}}</ref><ref>{{cite web |url=https://www.youtube.com/watch?v=4KqUvG8HPYo |website=YouTube.com |title=Inside Transducers |last=Hickey |first=Rich |date=2014-11-20}}</ref>

== Extensible Data Notation ==

'''Extensible Data Notation''', or '''edn''',<ref>{{cite web |url=http://edn-format.org |website=edn-format.org |title=Official EDN Spec |date=2022-04-27}}</ref> is a subset of the Clojure language intended as a data transfer format. It can be used to serialize and deserialize Clojure data structures, and Clojure itself uses a superset of edn to represent programs.

edn is used in a similar way to [[JSON]] or [[XML]], but has a relatively large list of built-in elements, shown here with examples:

* booleans: <code>true</code>, <code>false</code>
* strings: <code>"foo bar"</code>
* characters: <code>\c</code>, <code>\tab</code>
* symbols: <code>name</code>
* keywords: <code>:key</code>
* integers: <code>123</code>
* floating point numbers: <code>3.14</code>
* lists: <code>(a b 42)</code>
* vectors: <code>[a b 42]</code>
* maps: <code>{:a 1, "foo" :bar, [1 2 3] four}</code>
* sets: <code>#{a b [1 2 3]}</code>
* nil: <code>nil</code> (a [[Nullable type|null-like]] value)

In addition to those elements, it supports extensibility through the use of ''tags'', which consist of the character <code>#</code> followed by a symbol. When encountering a tag, the reader passes the value of the next element to the corresponding handler, which returns a data value. For example, this could be a tagged element: <code>#myapp/Person {:first "Fred" :last "Mertz"}</code>, whose interpretation will depend on the appropriate handler of the reader.

This definition of extension elements in terms of the others avoids relying on either convention or context to convey elements not included in the base set.

== Alternative platforms ==

The primary platform of Clojure is [[Java (software platform)|Java]],<ref name="clojure.org"/><ref name="about/jvm_hosted"/> but other target implementations exist. The most notable of these is ClojureScript,<ref>{{cite web |url=https://clojurescript.org |website=ClojureScript.org |title=ClojureScript |access-date=2019-07-06}}</ref> which compiles to [[ECMAScript]] 3,<ref>{{cite web |url=https://clojurescript.org/guides/faq-js#does-clojurescript-work-in-old-browsers |website=ClojureScript.org |title=ClojureScript – FAQ (for JavaScript developers) |access-date=2018-02-04}}</ref> and ClojureCLR,<ref>{{cite web |url=https://github.com/clojure/clojure-clr |title=ClojureCLR |website=GitHub |access-date=2012-06-28}}</ref> a full port on the [[.NET]] platform, interoperable with its ecosystem.

Other implementations of Clojure on different platforms include:

* Babashka,<ref>{{cite web |url=https://babashka.org |title=Babashka |last=Borkent |first=Michiel |website=Babashka.org |access-date=2019-08-19}}</ref> Native Clojure scripting language leveraging [[GraalVM]] native image and Small Clojure Interpreter
* CljPerl,<ref>{{cite web |url=https://metacpan.org/pod/CljPerl |title=A Lisp on Perl |last=Hu |first=Wei |website=MetaCPAN.org |access-date=2019-07-06}}</ref> Clojure on [[Perl (programming language)|Perl]]
* ClojureDart,<ref>{{Citation |title=What is ClojureDart? |date=2022-12-16 |url=https://github.com/Tensegritics/ClojureDart |website=GitHub |publisher=Tensegritics |access-date=2022-12-16}}</ref> Extend Clojure's reach to mobile & desktop apps by porting Clojure to Dart and Flutter
* Clojerl,<ref>{{cite web |url=https://github.com/clojerl/clojerl |website=GitHub |title=Clojerl |last= Facorro |first=Juan |access-date=2019-07-06}}</ref> Clojure on [[BEAM (Erlang virtual machine)|BEAM]], the [[Erlang (programming language)|Erlang]] virtual machine
* basilisp,<ref>{{cite web |url=https://github.com/basilisp-lang/basilisp |website=GitHub |title=basilisp |access-date=2024-05-13}}</ref> A Clojure-compatible(-ish) Lisp dialect targeting Python 3.8+
* ClojureRS,<ref>{{cite web |url=https://github.com/clojure-rs/ClojureRS |title=ClojureRS |website=GitHub |access-date=2022-03-17}}</ref> Clojure on [[Rust (programming language)|Rust]]
* Ferret,<ref>{{cite web |url=https://ferret-lang.org/ |title=Ferret |last=Akkaya |first=Nurullah |website=Ferret-Lang.org |access-date=2019-07-06}}</ref> compiles to self-contained C++11 that can run on microcontrollers
* jank,<ref>{{cite web |url=https://jank-lang.org/ |title=jank |last=Wilkerson |first=Jeaye |website=Jank-Lang.org |access-date=2022-08-17}}</ref> Native Clojure hosted in C++ on an LLVM-based JIT
* Joker,<ref>{{cite web |url=https://joker-lang.org/ |title=Joker |last=Bataev |first=Roman |website=Joker-Lang.org |access-date=2019-07-06}}</ref> an interpreter and [[lint (software)|linter]] written in [[Go (programming language)|Go]]
* Las3r,<ref>{{cite web |url=https://github.com/aemoncannon/las3r |title=Laz3r |last=Cannon |first=Aemon |website=GitHub |access-date=2019-07-06}}</ref> a subset of Clojure that runs on the [[ActionScript]] Virtual Machine (the Adobe Flash Player platform)
* Pixie,<ref>{{cite web |url=http://www.pixielang.org/ |title=Pixie |last=Baldridge |first=Timothy |website=PixieLang.org |access-date=2019-07-06}}</ref> Clojure-inspired Lisp dialect written in [[PyPy#RPython|RPython]]
* Rouge,<ref>{{cite web |url=https://github.com/ecmendenhall/rouge |title=Rouge |last=Connor |first=Ashe |website=GitHub |access-date=2019-07-06}}</ref> Clojure on YARV in [[Ruby (programming language)|Ruby]]

== Tools ==

Tooling for Clojure development has seen significant improvement over the years. The following is a list of some popular [[Integrated development environment|IDE]]s and [[text editor]]s with plug-ins that add support for programming in Clojure:<ref>{{cite web |url=https://www.clojure.org/news/2019/02/04/state-of-clojure-2019 |website=Clojure.org |title="State of Clojure 2019" Results |last=Miller |first=Alex |date=2019-02-04}}</ref>
* [[Emacs]], with CIDER<ref>{{cite web |url=https://cider.mx/ |website=CIDER.mx |title=CIDER: The Clojure Interactive Development Environment that Rocks |last=Batsov |first=Bozhidar |author2=((contributors)) |access-date=2019-07-05}}</ref>
* [[IntelliJ IDEA]], with Cursive<ref>{{cite web |url=https://plugins.jetbrains.com/plugin/8090-cursive |website=JetBrains.com |title=Cursive: Provides full Clojure and ClojureScript language support |last=Fleming |first=Colin |access-date=2019-07-05}}</ref> (a free license is available for [[non-commercial]] use)
* [[Sublime Text]], with Clojure Sublimed,<ref>{{cite web |url=https://packagecontrol.io/packages/Clojure%20Sublimed |website=PackageControl.io |title=Clojure Sublimed |last=Prokopov |first=Nikita |access-date=2023-02-18}}</ref> or Tutkain,<ref>{{cite web |url=https://tutkain.flowthing.me/ |website=FlowThing.me |title=Tutkain |last=Helenius |first=Eero |access-date=2023-02-18}}</ref>
* [[Vim (text editor)|Vim]], with fireplace.vim,<ref>{{cite web |url=https://www.vim.org/scripts/script.php?script_id=4978 |website=VIM.org |title=fireplace.vim: Clojure REPL Support |last=Pope |first=Tim |access-date=2019-07-05}}</ref><ref>{{cite web |url=https://juxt.pro/blog/posts/vim-1.html |website=JUXT.pro |title=Clojure and Vim: An overview – It's very possible |last=Monroe |first=Dominic |date=2016-12-13}}</ref> vim-elin,<ref>{{cite web |last=Masashi |first=Iizuka |date=2024-04-29 |title=vim-elin: A Clojure development environment for Vim/Neovim, primarily written in Babashka. |url=https://github.com/liquidz/vim-elin |url-status=live |archive-url=https://web.archive.org/web/20240502002453/https://github.com/liquidz/vim-elin |archive-date=2024-05-02 |access-date=2024-05-02 |website=GitHub}}</ref> or Conjure (Neovim only)<ref>{{cite web |url=https://github.com/Olical/conjure |website=GitHub |title=Neovim Clojure(Script) tooling over prepl |last=Caldwell |first=Oliver |access-date=2019-11-09}}</ref><ref>{{cite web |url=https://oli.me.uk/getting-started-with-clojure-neovim-and-conjure-in-minutes/ |website=oli.me.uk |title=Getting started with Clojure, Neovim and Conjure in minutes |last=Caldwell |first=Oliver |date=2019-11-06}}</ref>
* [[Visual Studio Code]], with Calva<ref>{{cite web |url=https://marketplace.visualstudio.com/items?itemName=betterthantomorrow.calva |website=VisualStudio.com |title=Calva: Clojure & ClojureScript Interactive Programming |last=Strömberg |first=Peter |access-date=2019-07-05}}</ref> or Clover<ref>{{cite web |url=https://marketplace.visualstudio.com/items?itemName=mauricioszabo.clover |title=Clover |last=Szabo |first=Maurício |website=VisualStudio.com |access-date=2021-01-28}}</ref>
* IDE-agnostic (using the [[Language Server Protocol]] for [[static analysis]] and/or [[Lint (software)|linting]]): clj-kondo<ref>{{Citation |title=clj-kondo/clj-kondo |date=2024-04-30 |url=https://github.com/clj-kondo/clj-kondo |access-date=2024-05-02 |publisher=clj-kondo}}</ref> or clojure-lsp<ref>{{Cite web |title=Overview - Clojure LSP |url=https://clojure-lsp.io/ |access-date=2024-05-02 |website=clojure-lsp.io}}</ref>

In addition to the tools provided by the community, the official Clojure [[command-line interface]] (CLI) tools<ref name="guides/deps_and_cli">{{cite web |url=https://clojure.org/guides/deps_and_cli |title=Deps and CLI Guide |last=Miller |first=Alex |website=Clojure.org |access-date=2019-07-08}}</ref> have also become available on [[Linux]], [[macOS]], and [[Windows]] since Clojure 1.9.<ref>{{cite web |url=http://blog.cognitect.com/blog/clojure19 |title=Clojure 1.9 |last=Miller |first=Alex |website=Cognitect.com |date=2017-12-08}}</ref>

== Development ==

The development process is restricted to the Clojure core team, though issues are publicly visible at the Clojure [[Jira (software)|JIRA]] project page.<ref>{{cite web |url=https://clojure.atlassian.net/projects/CLJ |website=Atlassian.net |title=Clojure |access-date=2019-07-07}}</ref> Anyone can ask questions or submit issues and ideas at ask.clojure.org.<ref>{{cite web |url=https://clojure.org/news/2019/07/25/clojure-forum |title=Clojure Forum |access-date=2020-03-20 |website=clojure.org}}</ref> If it's determined that a new issue warrants a JIRA ticket, a core team member will triage it and add it. JIRA issues are processed by a team of screeners and finally approved by Rich Hickey.<ref>{{cite web |url=https://gist.github.com/richhickey/1563cddea1002958f96e7ba9519972d9 |title=Open Source is Not About You |last=Hickey |first=Rich |date=2018-11-26 |website=GitHub}}</ref><ref>{{cite web |url=https://clojure.org/dev/workflow |title=Workflow |website=Clojure.org |access-date=2019-07-07}}</ref>

== Impact ==

With continued interest in functional programming, Clojure's adoption by software developers using the Java platform has continued to increase. The language has also been recommended by software developers such as Brian Goetz,<ref>{{cite web |url=https://www.twitch.tv/nipafx/clip/BloodyUglySharkFailFish |website=Twitch.tv |title=Brian Goetz' favorite non-Java JVM language (Part 1 of 3) |last=Goetz |first=Brian |date=2020-05-24}}</ref><ref>{{cite web |url=https://www.twitch.tv/nipafx/clip/GrotesqueWonderfulPigeonEleGiggle |website=Twitch.tv |title=Brian Goetz' favorite non-Java JVM language (Part 2 of 3) |last=Goetz |first=Brian |date=2020-05-24}}</ref><ref>{{cite web |url=https://www.twitch.tv/nipafx/clip/EphemeralAdorableWalletGingerPower |website=Twitch.tv |title=Brian Goetz' favorite non-Java JVM language (Part 3 of 3) |last=Goetz |first=Brian |date=2020-05-24}}</ref> Eric Evans,<ref>{{cite web |url=https://www.youtube.com/watch?v=T29WzvaPNc8&t=926 |website=YouTube.com |title=Modelling Time: Eric Evans: Domain-Driven Design Europe 2018 |last=Evans |first=Eric |date=2018-08-14}}</ref><ref>{{cite web |url=https://twitter.com/ericevans0/status/535742147098853376 |website=Twitter.com |title=Eric Evans on Twitter |last=Evans |first=Eric |date=2014-11-21}}</ref> [[James Gosling]],<ref>{{cite web |url=https://www.youtube.com/watch?v=-ktUXFxkSkI&t=24m14s |website=YouTube.com |title=James Gosling meetup with London Java Community |date=2016-10-11}}</ref> [[Paul Graham (programmer)|Paul Graham]],<ref>{{cite web |url=https://twitter.com/paulg/status/728831131534024704 |website=Twitter.com |title=Paul Graham on Twitter |last=Graham |first=Paul |date=2016-05-06}}</ref> and [[Robert C. Martin]].<ref>{{cite web |url=http://blog.cleancoder.com/uncle-bob/2019/08/22/WhyClojure.html |website=CleanCoder.com |title=Why Clojure? |last=Martin |first=Robert |date=2019-08-22}}</ref><ref>{{cite web |url=https://twitter.com/unclebobmartin/status/1068205421737857024 |website=Twitter.com |title=Unble Bob Martin on Twitter |last=Martin |first=Robert |date=2018-11-29}}</ref><ref>{{cite web |url=https://cleancoders.com/video-details/clean-code-episode-53 |website=CleanCoders.com |title=Introduction To Functional Programming |last=Martin |first=Robert |date=2018-08-01}}</ref><ref>{{cite web |url=https://blog.cleancoder.com/uncle-bob/2017/07/11/PragmaticFunctionalProgramming.html |website=CleanCoder.com |title=Pragmatic Functional Programming |last=Martin |first=Robert |date=2017-07-11}}</ref> [[ThoughtWorks]], while assessing functional programming languages for their Technology Radar,<ref>{{cite web |url=https://www.thoughtworks.com/radar/faq |title=Technology Radar: Frequently Asked Questions |website=ThoughtWorks.com |access-date=2019-02-10}}</ref> described Clojure as "a simple, elegant implementation of Lisp on the JVM" in 2010 and promoted its status to "ADOPT" in 2012.<ref>{{cite web |url=https://www.thoughtworks.com/radar/languages-and-frameworks/clojure |title=Technology Radar: Clojure |website=ThoughtWorks.com |access-date=2019-02-10}}</ref>


In the "JVM Ecosystem Report 2018" (which was claimed to be "the largest survey ever of Java developers"), that was prepared in collaboration by Snyk and Java Magazine, ranked Clojure as the 2nd most used programming language on the JVM for "main applications".<ref>{{cite web |url=https://snyk.io/blog/jvm-ecosystem-report-2018/ |website=Snyk.io |title=JVM Ecosystem Report 2018 |last1=Maple |first1=Simon |last2=Binstock |first2=Andrew |date=2018-10-17}}</ref> Clojure is used in industry by firms<ref>{{cite web |url=https://clojure.org/community/success_stories |website=Clojure.org |title=Success Stories |access-date=2018-10-27}}</ref> such as [[Apple Inc.|Apple]],<ref>{{cite web |url=https://twitter.com/roman01la/status/942469177444569089 |website=Twitter.com |title=Roman Liutikov on Twitter |last=Liutikov |first=Roman |date=2017-12-17}}</ref><ref>{{cite web |url=https://jobs.apple.com/en-us/search?sort=relevance&search=clojure |website=Apple.com |title=Jobs at Apple |access-date=2019-07-06}}</ref> [[Atlassian]],<ref>{{cite web |url=https://www.youtube.com/watch?v=3QR8meTrh5g |website=YouTube.com |title=Realtime Collaboration with Clojure |last=Borges |first=Leonardo |date=2015-07-07}}</ref> [[Funding Circle]],<ref>{{cite web |url=https://juxt.pro/blog/posts/clojure-in-fundingcircle.html |website=JUXT.pro |title=Clojure in London: Funding Circle – Lending some Clojure |last=Pither |first=Jon |date=2016-10-04}}</ref> [[Netflix]],<ref>{{cite web |url=https://thenewstack.io/the-new-stack-makers-adrian-cockcroft-on-sun-netflix-clojure-go-docker-and-more/ |website=TheNewStack.io |title=The New Stack Makers: Adrian Cockcroft on Sun, Netflix, Clojure, Go, Docker and More |last=Williams |first=Alex |date=2014-08-03}}</ref> [[Nubank]],<ref>{{cite web |url=https://valorinveste.globo.com/mercados/renda-variavel/empresas/noticia/2020/07/23/nubank-adquire-empresa-norte-americana-de-tecnologia-cognitect.ghtml |title=Nubank adquire empresa norte-americana de tecnologia Cognitect|date=23 July 2020 }}</ref> [[Puppet (company)|Puppet]],<ref>{{cite web |url=https://puppet.com/blog/a-new-era-of-application-services-at-puppet-labs/ |website=Puppet.com |title=A New Era of Application Services at Puppet Labs |last=Price |first=Chris |date=2014-04-11 |access-date=2020-08-06 }}</ref> and [[Walmart]]<ref>{{cite web |url=https://blog.cognitect.com/blog/2015/6/30/walmart-runs-clojure-at-scale |website=Cognitect.com |title=Walmart Runs Clojure at Scale |last=Phillips |first=Marc |date=2015-07-14}}</ref> as well as government agencies such as [[NASA]].<ref>{{cite web |url=https://github.com/nasa/Common-Metadata-Repository |website=GitHub |title=Common-Metadata-Repository |access-date=2019-07-06}}</ref> It has also been used for creative computing, including visual art, music, games, and poetry.<ref>{{cite web |url=http://radar.oreilly.com/2015/05/creative-computing-with-clojure.html |website=OReilly.com |title=Creative computing with Clojure |last=Meier |first=Carin |date=2015-05-06}}</ref>

In the 2023 edition of [[Stack Overflow]] Developer Survey, Clojure was the fourth most ''admired'' in the category of programming and scripting languages, with 68.51% of the respondents who have worked with it last year saying they would like to continue using it. In the ''desired'' category, however it was marked as such by only 2.2% of the surveyed, whereas the highest scoring [[JavaScript]] was ''desired'' by 40.15% of the developers participating in the survey.<ref>{{Cite web |title=Stack Overflow Developer Survey 2023 |url=https://survey.stackoverflow.co/2023/?utm_source=social-share&utm_medium=social&utm_campaign=dev-survey-2023 |access-date=2024-05-02 |website=Stack Overflow |language=en}}</ref> It could possibly be attributed to limited professional opportunities for Clojure developers with just over 50 search results for "Clojure developer" at the [[U.S.]] section of [[Indeed]], as of May 2024.<ref>{{Cite web |date=2024-05-02 |title="Clojure developer" search results at Indeed.com [Archived due to the mutability of the source] |url=https://archive.today/20240502010543/https://www.indeed.com/jobs?q=Clojure+developer&l=&from=searchOnHP&sameL=1&vjk=00b06c77b630fc2f |access-date=2024-05-02 |website=Archive.is}}</ref>

== Release history ==


==Language overview==
{| class="wikitable"
{| class="wikitable"
! Version
! Version
! Release date
! Release date
! Major features/improvements
! Major features, improvements
|-
|-
|
|
| {{start date|2007|10|17}}<ref name="clojure history" />
| {{start date|2007|10|17}}<ref name="clojure history"/>
| Initial public release
| Initial public release
|-
|-
Line 155: Line 237:
| New syntax for keyword argument invocation, new <code>clojure.math</code> namespace, namespace aliasing without loading, and new helper functions added to <code>clojure.core</code>
| New syntax for keyword argument invocation, new <code>clojure.math</code> namespace, namespace aliasing without loading, and new helper functions added to <code>clojure.core</code>
|-
|-
| {{Version |c |1.11.1}}
| 1.11.1
| {{start date|2022|04|05}}<ref name="release/clojure1-11-1">{{cite web |url=https://clojure.org/news/2022/04/05/clojure-1-11-1 |website=Clojure.org |title=Clojure 1.11.1 release |last=Miller |first=Alex |date=2022-04-05}}</ref>
| {{start date|2022|04|05}}<ref name="release/clojure1-11-1">{{cite web |url=https://clojure.org/news/2022/04/05/clojure-1-11-1 |website=Clojure.org |title=Clojure 1.11.1 release |last=Miller |first=Alex |date=2022-04-05}}</ref>
| Rolling back unintended change in binary serialisation of objects of types <code>clojure.lang.Keyword</code> and <code>clojure.lang.ArraySeq</code>.
| Rolling back unintended change in binary serialisation of objects of types <code>clojure.lang.Keyword</code> and <code>clojure.lang.ArraySeq</code>.
|-
| {{Version |c |1.11.2}}
| {{start date|2024|03|08}}<ref name="release/clojure1-11-2">{{cite web |url=https://clojure.org/news/2024/03/08/clojure-1-11-2 |website=Clojure.org |title=Clojure 1.11.2 release |last=Miller |first=Alex |date=2024-03-08}}</ref>
| Fix for [https://nvd.nist.gov/vuln/detail/CVE-2024-22871 CVE-2024-22871] [[Denial of Service]] vulnerability
|-
|-
| colspan=3 | {{Version|l|show=000100}}
| colspan=3 | {{Version|l|show=000100}}
|}
|}
Clojure runs on the [[Java (software platform)|Java]] platform and as a result, integrates with [[Java (programming language)|Java]] and fully supports calling Java code from Clojure,<ref name="about/jvm_hosted">{{cite web |url=https://clojure.org/about/jvm_hosted |website=Clojure.org |title=Hosted on the JVM |access-date=2019-07-07}}</ref><ref name="interview/a-z" /> and Clojure code can be called from Java, too.<ref>{{cite web |url=https://clojure.org/reference/java_interop#_calling_clojure_from_java |title=Java Interop |website=Clojure.org |access-date=2019-07-07}}</ref> The community uses tools such as Clojure [[Command-line interface|CLI]] tools<ref name="guides/deps_and_cli"></ref> or [[Leiningen (software)|Leiningen]] for project automation, providing support for [[Apache Maven|Maven]] integration. These tools handle project package management and dependencies and is configured using Clojure syntax.<ref>{{cite web |url=https://leiningen.org/ |website=Leiningen.org |title=Leiningen |last=Hagelberg |first=Phil |author2=((contributors)) |access-date=2019-07-07}}</ref>

Like most other Lisps, Clojure's syntax is built on [[S-expression]]s that are first parsed into data structures by a reader before being compiled.<ref name="reference/reader">{{cite web |url=https://clojure.org/reference/reader |website=Clojure.org |title=The Reader |access-date=2019-07-07}}</ref><ref name="interview/a-z" /> Clojure's [[Lisp reader|reader]] supports literal syntax for [[hash table|maps]], sets and [[Array data structure|vectors]] in addition to lists, and these are compiled to the mentioned structures directly.<ref name="reference/reader" /> 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.<ref name="reference/lisps" />

As a Lisp dialect, Clojure supports [[Function (programming)|functions]] as [[First-class function|first-class objects]], a [[read–eval–print loop]] (REPL), and a macro system.<ref name="reference/macros" /> Clojure's [[Lisp macro]] system is very similar to that of [[Common Lisp]] with the exception that Clojure's version of the [[Grave accent#Use in programming|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.<ref>{{cite web |url=https://github.com/edn-format/edn |website=GitHub.com |title=edn |last=Hickey |first=Rich |access-date=2019-07-07}}</ref> Clojure supports [[Multiple dispatch|multimethods]]<ref>{{cite web |url=https://clojure.org/reference/multimethods |website=Clojure.org |title=Multimethods and Hierarchies |access-date=2019-07-07}}</ref> and for [[Software Interface|interface]]-like abstractions has a [[Protocol (object-oriented programming)|protocol]]<ref>{{cite web |url=https://clojure.org/reference/protocols |website=Clojure.org |title=Protocols |access-date=2019-07-07}}</ref> based polymorphism and data type system using [[Record (computer science)|records]],<ref>{{cite web |url=https://clojure.org/reference/datatypes |website=Clojure.org |title=Datatypes: deftype, defrecord and reify |access-date=2019-07-07}}</ref> providing high-performance and dynamic polymorphism designed to avoid the [[expression problem]].

Clojure has support for [[Lazy evaluation|lazy sequences]] and encourages the principle of [[Immutable object|immutability]] and [[persistent data structure]]s. As a [[Functional programming|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;<ref>{{cite web |url=https://www.youtube.com/watch?v=2y5Pv4yN0b0&t=1h02m18s |title=Stewardship: the Sobering Parts |website=YouTube.com |last=Goetz |first=Brian |date=2014-11-20}}</ref><ref>{{cite web |url=https://blogs.oracle.com/jrose/tail-calls-in-the-vm |website=Oracle.com |title=tail calls in the VM |last=Rose |first=John |date=2007-07-12}}</ref><ref>{{cite web |url=https://bugs.openjdk.java.net/browse/JDK-6804517 |website=Java.net |title=Some languages need to be able to perform tail calls |last=Rose |first=John |date=2009-02-11}}</ref> it is possible to do so explicitly by using the <code>recur</code> keyword.<ref>{{cite web |url=https://clojure.org/reference/special_forms#recur |website=Clojure.org |title=Special Forms |access-date=2019-07-07}}</ref> For [[Parallel computing|parallel]] and [[Concurrent computing|concurrent]] programming Clojure provides [[software transactional memory]],<ref>{{cite web |url=https://clojure.org/refs |website=Clojure.org |title=Refs and Transactions |access-date=2019-07-07}}</ref> a reactive [[Agent-based model|agent system]],<ref name="reference/agents" /> and [[Communicating sequential processes|channel]]-based concurrent programming.<ref>{{cite web |url=https://clojure.org/news/2013/06/28/clojure-clore-async-channels |website=Clojure.org |title=Clojure core.async Channels |last=Hickey |first=Rich |date=2013-06-28}}</ref>

Clojure 1.7 introduced reader conditionals by allowing the embedding of Clojure and ClojureScript code in the same namespace.<ref name="release/clojure-17" /><ref name="reference/reader" /> Transducers were added as a method for composing transformations. Transducers enable higher-order functions such as [[Map (higher-order function)|map]] and [[Fold (higher-order function)|fold]] to generalize over any source of input data. While traditionally these functions operate on [[List (abstract data type)|sequences]], transducers allow them to work on channels and let the user define their own models for transduction.<ref>{{cite web |url=https://www.youtube.com/watch?v=6mTbuzafcII |website=YouTube.com |title=Transducers |last=Hickey |first=Rich |date=2014-09-17}}</ref><ref>{{cite web |url=https://blog.cognitect.com/blog/2014/8/6/transducers-are-coming |website=Cognitect.com |title=Transducers are Coming |last=Hickey |first=Rich |date=2014-08-06}}</ref><ref>{{cite web |url=https://www.youtube.com/watch?v=4KqUvG8HPYo |website=YouTube.com |title=Inside Transducers |last=Hickey |first=Rich |date=2014-11-20}}</ref>

==Extensible Data Notation==

'''Extensible Data Notation''', or '''edn''',<ref>{{cite web |url=http://edn-format.org |website=edn-format.org |title=Official EDN Spec |date=2022-04-27}}</ref> is a subset of the Clojure language intended as a data transfer format. It can be used to serialize and deserialize Clojure data structures, and Clojure itself uses a superset of edn to represent programs.

edn is used in a similar way to [[JSON]] or [[XML]], but has a relatively large list of built-in elements, shown here with examples:

* booleans: <code>true</code>, <code>false</code>
* strings: <code>"foo bar"</code>
* characters: <code>\c</code>, <code>\tab</code>
* symbols: <code>name</code>
* keywords: <code>:key</code>
* integers: <code>123</code>
* floating point numbers: <code>3.14</code>
* lists: <code>(a b 42)</code>
* vectors: <code>[a b 42]</code>
* maps: <code>{:a 1, "foo" :bar, [1 2 3] four}</code>
* sets: <code>#{a b [1 2 3]}</code>
* nil: <code>nil</code> (a [[Nullable type|null-like]] value)

In addition to those elements, it supports extensibility through the use of ''tags'', which consist of the character <code>#</code> followed by a symbol. When encountering a tag, the reader passes the value of the next element to the corresponding handler, which returns a data value. For example, this could be a tagged element: <code>#myapp/Person {:first "Fred" :last "Mertz"}</code>, whose interpretation will depend on the appropriate handler of the reader.

This definition of extension elements in terms of the others avoids relying on either convention or context to convey elements not included in the base set.

==Alternative platforms==
<!-- [[Compojure]] redirects here -->The primary platform of Clojure is [[Java (software platform)|Java]],<ref name="clojure.org" /><ref name="about/jvm_hosted" /> but other target implementations exist. The most notable of these is ClojureScript,<ref>{{cite web |url=https://clojurescript.org |website=ClojureScript.org |title=ClojureScript |access-date=2019-07-06}}</ref> which compiles to [[ECMAScript]] 3,<ref>{{cite web |url=https://clojurescript.org/guides/faq-js#does-clojurescript-work-in-old-browsers |website=ClojureScript.org |title=ClojureScript – FAQ (for JavaScript developers) |access-date=2018-02-04}}</ref> and ClojureCLR,<ref>{{cite web |url=https://github.com/clojure/clojure-clr |website=GitHub.com |title=ClojureCLR |access-date=2012-06-28}}</ref> a full port on the [[Common Language Infrastructure|.NET]] platform, interoperable with its ecosystem. A survey of the Clojure community with 1,060 respondents conducted in 2013<ref>{{cite web |url=https://cemerick.com/2013/11/18/results-of-the-2013-state-of-clojure-clojurescript-survey/ |website=CEmerick.com |title=Results of the 2013 State of Clojure & ClojureScript survey |last=Emerick |first=Chas |date=2013-11-18 |access-date=2019-07-06 |archive-date=2018-10-29 |archive-url=https://web.archive.org/web/20181029191758/https://cemerick.com/2013/11/18/results-of-the-2013-state-of-clojure-clojurescript-survey/ |url-status=dead }}</ref> found that 47% of respondents used both Clojure and ClojureScript when working with Clojure. In 2014 this number had increased to 55%,<ref>{{cite web |url=https://cognitect.wufoo.com/reports/state-of-clojure-2014-results/ |website=WuFoo.com |title=State of Clojure 2014 Survey Results |access-date=2015-09-17}}</ref> in 2015, based on 2,445 respondents, to 66%.<ref>{{cite web |url=https://blog.cognitect.com/blog/2016/1/28/state-of-clojure-2015-survey-results |website=Cognitect.com |title=State of Clojure 2015 Survey Results |last=Gehtland |first=Justin |date=2016-01-28}}</ref> Popular ClojureScript projects include implementations of the [[React (JavaScript library)|React]] library such as Reagent,<ref>{{cite web |url=https://reagent-project.github.io/ |website=GitHub.io |title=Reagent |access-date=2019-07-06}}</ref> re-frame,<ref>{{cite web |url=https://github.com/Day8/re-frame |website=GitHub.com |title=re-frame |access-date=2019-07-06}}</ref> Rum,<ref>{{cite web |url=https://github.com/tonsky/rum |website=GitHub.com |title=Rum |last=Prokopov |first=Nikita |access-date=2019-07-06}}</ref> and Om.<ref>{{cite web |url=https://github.com/omcljs/om |website=GitHub.com |title=Om |last=Nolen |first=David |access-date=2019-07-06}}</ref><ref>{{cite web |url=https://www.infoq.com/news/2014/01/om-react/ |website=InfoQ.com |title=Om: Enhancing Facebook's React with Immutability |last=Coupland |first=Tom |date=2014-01-17}}</ref>

===Other Implementations===
Other implementations of Clojure on different platforms include:

* Babashka, <ref>{{cite web |url=https://babashka.org |website=babashka.org |title=Babashka |last=Borkent |first=Michiel |access-date=2019-08-19}}</ref> Native Clojure scripting language leveraging [[GraalVM|GraalVM native image]] and [https://github.com/babashka/sci Small Clojure Interpreter]
* CljPerl, <ref>{{cite web |url=https://metacpan.org/pod/CljPerl |website=MetaCPAN.org |title=A Lisp on Perl |last=Hu |first=Wei |access-date=2019-07-06}}</ref> Clojure atop [[Perl (programming language)|Perl]]
* ClojureCLR, <ref>{{Cite web |title=Clojure - Clojure CLR |url=https://clojure.org/about/clojureclr |access-date=2022-05-06 |website=clojure.org}}</ref> Clojure on [[Common Language Runtime|CLR]], the [[.NET|.Net]] virtual machine.
* ClojureDart, <ref>{{Citation |title=What is ClojureDart? |date=2022-12-16 |url=https://github.com/Tensegritics/ClojureDart |publisher=Tensegritics |access-date=2022-12-16}}</ref> [https://github.com/Tensegritics/ClojureDart Extend Clojure's reach] to mobile & desktop apps by [https://github.com/Tensegritics/ClojureDart porting Clojure to Dart and Flutter]
* Clojerl, <ref>{{cite web |url=https://github.com/clojerl/clojerl |website=GitHub.com |title=Clojerl |last= Facorro |first=Juan |access-date=2019-07-06}}</ref> Clojure on [[BEAM (Erlang virtual machine)|BEAM]], the [[Erlang (programming language)|Erlang]] virtual machine
* clojure-py, <ref>{{cite web |url=https://github.com/drewr/clojure-py |website=GitHub.com |title=clojure-py |last=Baldridge |first=Timothy |access-date=2019-07-06}}</ref> Clojure in pure [[Python (programming language)|Python]]
* ClojureRS, <ref>{{cite web |url=https://github.com/clojure-rs/ClojureRS |website=GitHub.com |title=ClojureRS |access-date=2022-03-17}}</ref> Clojure on [[Rust (programming language)|Rust]]
* ClojureScript, <ref>{{Citation |title=clojure/clojurescript |date=2022-12-16 |url=https://github.com/clojure/clojurescript |publisher=Clojure |access-date=2022-12-16}}</ref> Compiler for [https://clojurescript.org/ Clojure that targets JavaScript]. It emits [https://github.com/google/closure-compiler JavaScript code compatible with the advanced compilation] mode of the [https://developers.google.com/closure/compiler/docs/compilation_levels Google Closure optimizing compiler]
* Ferret, <ref>{{cite web |url=https://ferret-lang.org/ |website=Ferret-Lang.org |title=Ferret |last=Akkaya |first=Nurullah |access-date=2019-07-06}}</ref> compiles to self-contained C++11 that can run on microcontrollers
* jank, <ref>{{cite web |url=https://jank-lang.org/ |website=Jank-Lang.org |title=jank |last=Wilkerson |first=Jeaye |access-date=2022-08-17}}</ref> Clojure compatible language with gradual typing that is hosted in C++ on top of an LLVM-based JIT
* Joker, <ref>{{cite web |url=https://joker-lang.org/ |website=Joker-Lang.org |title=Joker |last=Bataev |first=Roman |access-date=2019-07-06}}</ref> an interpreter and [[lint (software)|linter]] written in [[Go (programming language)|Go]]
* Las3r, <ref>{{cite web |url=https://github.com/aemoncannon/las3r |website=GitHub.com |title=Laz3r |last=Cannon |first=Aemon |access-date=2019-07-06}}</ref> a subset of Clojure that runs on the [[ActionScript]] Virtual Machine (the Adobe Flash Player platform)
* Pixie, <ref>{{cite web |url=http://www.pixielang.org/ |website=PixieLang.org |title=Pixie |last=Baldridge |first=Timothy |access-date=2019-07-06}}</ref> Clojure-inspired Lisp dialect written in [[PyPy#RPython|RPython]]
* Rouge, <ref>{{cite web |url=https://github.com/ecmendenhall/rouge |website=GitHub.com |title=Rouge |last=Connor |first=Ashe |access-date=2019-07-06}}</ref> Clojure atop YARV in [[Ruby (programming language)|Ruby]]

==Popularity==
With continued interest in functional programming, Clojure's adoption by software developers using the Java platform has continued to increase. The language has also been recommended by software developers such as Brian Goetz,<ref>{{cite web |url=https://www.twitch.tv/nipafx/clip/BloodyUglySharkFailFish |website=Twitch.tv |title=Brian Goetz' favorite non-Java JVM language (Part 1 of 3) |last=Goetz |first=Brian |date=2020-05-24}}</ref><ref>{{cite web |url=https://www.twitch.tv/nipafx/clip/GrotesqueWonderfulPigeonEleGiggle |website=Twitch.tv |title=Brian Goetz' favorite non-Java JVM language (Part 2 of 3) |last=Goetz |first=Brian |date=2020-05-24}}</ref><ref>{{cite web |url=https://www.twitch.tv/nipafx/clip/EphemeralAdorableWalletGingerPower |website=Twitch.tv |title=Brian Goetz' favorite non-Java JVM language (Part 3 of 3) |last=Goetz |first=Brian |date=2020-05-24}}</ref> Eric Evans,<ref>{{cite web |url=https://www.youtube.com/watch?v=T29WzvaPNc8&t=926 |website=YouTube.com |title=Modelling Time - Eric Evans - Domain-Driven Design Europe 2018 |last=Evans |first=Eric |date=2018-08-14}}</ref><ref>{{cite web |url=https://twitter.com/ericevans0/status/535742147098853376 |website=Twitter.com |title=Eric Evans on Twitter |last=Evans |first=Eric |date=2014-11-21}}</ref> [[James Gosling]],<ref>{{cite web |url=https://www.youtube.com/watch?v=-ktUXFxkSkI&t=24m14s |website=YouTube.com |title=James Gosling meetup with London Java Community |date=2016-10-11}}</ref> [[Paul Graham (programmer)|Paul Graham]],<ref>{{cite web |url=https://twitter.com/paulg/status/728831131534024704 |website=Twitter.com |title=Paul Graham on Twitter |last=Graham |first=Paul |date=2016-05-06}}</ref> and [[Robert C. Martin]].<ref>{{cite web |url=http://blog.cleancoder.com/uncle-bob/2019/08/22/WhyClojure.html |website=CleanCoder.com |title=Why Clojure? |last=Martin |first=Robert |date=2019-08-22}}</ref><ref>{{cite web |url=https://twitter.com/unclebobmartin/status/1068205421737857024 |website=Twitter.com |title=Unble Bob Martin on Twitter |last=Martin |first=Robert |date=2018-11-29}}</ref><ref>{{cite web |url=https://cleancoders.com/video-details/clean-code-episode-53 |website=CleanCoders.com |title=Introduction To Functional Programming |last=Martin |first=Robert |date=2018-08-01}}</ref><ref>{{cite web |url=https://blog.cleancoder.com/uncle-bob/2017/07/11/PragmaticFunctionalProgramming.html |website=CleanCoder.com |title=Pragmatic Functional Programming |last=Martin |first=Robert |date=2017-07-11}}</ref> [[ThoughtWorks]], while assessing functional programming languages for their Technology Radar,<ref>{{cite web |url=https://www.thoughtworks.com/radar/faq |website=ThoughtWorks.com |title=Frequently Asked Questions - Technology Radar - ThoughtWorks |access-date=2019-02-10}}</ref> described Clojure as "a simple, elegant implementation of Lisp on the JVM" in 2010 and promoted its status to "ADOPT" in 2012.<ref>{{cite web |url=https://www.thoughtworks.com/radar/languages-and-frameworks/clojure |website=ThoughtWorks.com |title=Clojure - Technology Radar - ThoughtWorks |access-date=2019-02-10}}</ref>

In the "JVM Ecosystem Report 2018" (which was claimed to be "the largest survey ever of Java developers"), that was prepared in collaboration by Snyk and Java Magazine, ranked Clojure as the 2nd most used programming language on the JVM for "main applications".<ref>{{cite web |url=https://snyk.io/blog/jvm-ecosystem-report-2018/ |website=Snyk.io |title=JVM Ecosystem Report 2018 |last1=Maple |first1=Simon |last2=Binstock |first2=Andrew |date=2018-10-17}}</ref> Clojure is used in industry by firms<ref>{{cite web |url=https://clojure.org/community/success_stories |website=Clojure.org |title=Success Stories |access-date=2018-10-27}}</ref> such as [[Apple Inc.|Apple]],<ref>{{cite web |url=https://twitter.com/roman01la/status/942469177444569089 |website=Twitter.com |title=Roman Liutikov on Twitter |last=Liutikov |first=Roman |date=2017-12-17}}</ref><ref>{{cite web |url=https://jobs.apple.com/en-us/search?sort=relevance&search=clojure |website=Apple.com |title=Jobs at Apple |access-date=2019-07-06}}</ref> [[Atlassian]],<ref>{{cite web |url=https://www.youtube.com/watch?v=3QR8meTrh5g |website=YouTube.com |title=Realtime Collaboration with Clojure |last=Borges |first=Leonardo |date=2015-07-07}}</ref> [[Funding Circle]],<ref>{{cite web |url=https://juxt.pro/blog/posts/clojure-in-fundingcircle.html |website=JUXT.pro |title=Clojure in London: Funding Circle – Lending some Clojure |last=Pither |first=Jon |date=2016-10-04}}</ref> [[Netflix]],<ref>{{cite web |url=https://thenewstack.io/the-new-stack-makers-adrian-cockcroft-on-sun-netflix-clojure-go-docker-and-more/ |website=TheNewStack.io |title=The New Stack Makers: Adrian Cockcroft on Sun, Netflix, Clojure, Go, Docker and More |last=Williams |first=Alex |date=2014-08-03}}</ref> [[Nubank]],<ref>{{cite web |url=https://valorinveste.globo.com/mercados/renda-variavel/empresas/noticia/2020/07/23/nubank-adquire-empresa-norte-americana-de-tecnologia-cognitect.ghtml |title=Nubank adquire empresa norte-americana de tecnologia Cognitect}}</ref> [[Puppet (company)|Puppet]],<ref>{{cite web |url=https://puppet.com/blog/a-new-era-of-application-services-at-puppet-labs/ |website=Puppet.com |title=A New Era of Application Services at Puppet Labs |last=Price |first=Chris |date=2014-04-11 |access-date=2020-08-06 }}</ref> and [[Walmart]]<ref>{{cite web |url=https://blog.cognitect.com/blog/2015/6/30/walmart-runs-clojure-at-scale |website=Cognitect.com |title=Walmart Runs Clojure at Scale |last=Phillips |first=Marc |date=2015-07-14}}</ref> as well as government agencies such as [[NASA]].<ref>{{cite web |url=https://github.com/nasa/Common-Metadata-Repository |website=GitHub.com |title=Common-Metadata-Repository |access-date=2019-07-06}}</ref> It has also been used for creative computing, including visual art, music, games, and poetry.<ref>{{cite web |url=http://radar.oreilly.com/2015/05/creative-computing-with-clojure.html |website=OReilly.com |title=Creative computing with Clojure |last=Meier |first=Carin |date=2015-05-06}}</ref>

==Tools==
Tooling for Clojure development has seen significant improvement over the years. The following is a list of some popular [[Integrated development environment|IDE]]s and [[text editor]]s with plug-ins that add support for programming in Clojure:<ref>{{cite web |url=https://www.clojure.org/news/2019/02/04/state-of-clojure-2019 |website=Clojure.org |title="State of Clojure 2019" Results |last=Miller |first=Alex |date=2019-02-04}}</ref>
* [[Emacs]], with CIDER<ref>{{cite web |url=https://cider.mx/ |website=CIDER.mx |title=CIDER: The Clojure Interactive Development Environment that Rocks |last=Batsov |first=Bozhidar |author2=((contributors)) |access-date=2019-07-05}}</ref>
* [[IntelliJ IDEA]], with Clojure-Kit<ref>{{cite web |url=https://plugins.jetbrains.com/plugin/8636-clojure-kit |website=JetBrains.com |title=Clojure-Kit: Clojure and ClojureScript plugin for IntelliJ-based tools |last=Shrago |first=Greg |access-date=2019-07-05}}</ref> or Cursive<ref>{{cite web |url=https://plugins.jetbrains.com/plugin/8090-cursive |website=JetBrains.com |title=Cursive: Provides full Clojure and ClojureScript language support |last=Fleming |first=Colin |access-date=2019-07-05}}</ref> (a free license is available for [[non-commercial]] use)
* [[Sublime Text]], with Clojure Sublimed,<ref>{{cite web |url=https://packagecontrol.io/packages/Clojure%20Sublimed |website=PackageControl.io |title=Clojure Sublimed |last=Prokopov |first=Nikita |access-date=2023-02-18}}</ref> or Tutkain,<ref>{{cite web |url=https://tutkain.flowthing.me/ |website=FlowThing.me |title=Tutkain |last=Helenius |first=Eero |access-date=2023-02-18}}</ref>
* [[Vim (text editor)|Vim]], with fireplace.vim,<ref>{{cite web |url=https://www.vim.org/scripts/script.php?script_id=4978 |website=VIM.org |title=fireplace.vim: Clojure REPL Support |last=Pope |first=Tim |access-date=2019-07-05}}</ref><ref>{{cite web |url=https://juxt.pro/blog/posts/vim-1.html |website=JUXT.pro |title=Clojure and Vim: An overview – It's very possible |last=Monroe |first=Dominic |date=2016-12-13}}</ref> vim-iced,<ref>{{cite web |url=https://liquidz.github.io/vim-iced/ |website=GitHub.com |title=vim-iced: Clojure Interactive Development Environment for Vim8/Neovim |last=Masashi |first=Iizuka |access-date=2020-03-13}}</ref> or Conjure (Neovim only)<ref>{{cite web |url=https://github.com/Olical/conjure |website=GitHub.com |title=Neovim Clojure(Script) tooling over prepl |last=Caldwell |first=Oliver |access-date=2019-11-09}}</ref><ref>{{cite web |url=https://oli.me.uk/getting-started-with-clojure-neovim-and-conjure-in-minutes/ |website=oli.me.uk |title=Getting started with Clojure, Neovim and Conjure in minutes |last=Caldwell |first=Oliver |date=2019-11-06}}</ref>
* [[Visual Studio Code]], with Calva<ref>{{cite web |url=https://marketplace.visualstudio.com/items?itemName=betterthantomorrow.calva |website=VisualStudio.com |title=Calva: Clojure & ClojureScript Interactive Programming |last=Strömberg |first=Peter |access-date=2019-07-05}}</ref> or Clover<ref>{{cite web |url=https://marketplace.visualstudio.com/items?itemName=mauricioszabo.clover |website=VisualStudio.com |title=Clover |last=Szabo |first=Maurício |access-date=2021-01-28}}</ref>

In addition to the tools provided by the community, the official Clojure [[Command-line interface|CLI]] tools<ref name="guides/deps_and_cli">{{cite web |url=https://clojure.org/guides/deps_and_cli |website=Clojure.org |title=Deps and CLI Guide |last=Miller |first=Alex |access-date=2019-07-08}}</ref> have also become available on [[Linux]], [[macOS]], and [[Windows]] since Clojure 1.9.<ref>{{cite web |url=http://blog.cognitect.com/blog/clojure19 |website=Cognitect.com |title=Clojure 1.9 |last=Miller |first=Alex |date=2017-12-08}}</ref>

==Features by example==
The following examples can be run in a Clojure REPL such as one started with the Clojure CLI tools<ref name="guides/deps_and_cli" /> or an online REPL such as one available on REPL.it.<ref>{{cite web |url=https://repl.it/l/clojure |website=REPL.it |title=Online Clojure REPL |access-date=2019-07-08}}</ref>

===Simplicity===
Because of its strong emphasis on simplicity, Clojure programs typically consist of mostly functions and simple data structures (i.e., lists, vectors, maps, and sets):
<syntaxhighlight lang="clojure">
;; A typical entry point of a Clojure program:
;; `-main` function
(defn -main ; name
[& args] ; (variable) parameters
(println "Hello, World!")) ; body
</syntaxhighlight>

===Programming at the REPL===
Like other [[Lisp (programming language)|Lisps]], one of Clojure's iconic features is interactive programming at the [[REPL]].<ref>{{cite web |url=https://clojure.org/guides/repl/introduction |website=Clojure.org |title=Programming at the REPL: Introduction |access-date=2018-12-04}}</ref> Note that, in the following examples, <code>;</code> starts a line comment and <code>;; =></code> indicates the expected output:

<syntaxhighlight lang="clojure">
; 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)
;; =>
-------------------------
clojure.core/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)))
</syntaxhighlight>

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

<syntaxhighlight lang="clojure">
; 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
;; => #'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]}
</syntaxhighlight>

===Code as data (homoiconicity)===
Similar to other [[Lisp (programming language)|Lisps]], Clojure is [[Homoiconicity|homoiconic]] (also known as "code as data"). In the example below, we can see how to write code that modifies code itself:

<syntaxhighlight lang="clojure">
; 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)
</syntaxhighlight>

===Expressive operators for data transformation===
The threading macros (<code>-></code>, <code>->></code>, and friends) can syntactically express the abstraction of piping a collection of data through a series of transformations:

<syntaxhighlight lang="clojure">
(->> (range 10)
(map inc)
(filter even?))
;; => (2 4 6 8 10)
</syntaxhighlight>

This can also be achieved more efficiently using transducers:

<syntaxhighlight lang="clojure">
(sequence (comp (map inc)
(filter even?))
(range 10))
;; => (2 4 6 8 10)
</syntaxhighlight>

===Thread-safe management of identity and state===
A [[thread-safe]] generator of unique serial numbers (though, like many other Lisp dialects, Clojure has a built-in <code>gensym</code> function that it uses internally):

<syntaxhighlight lang="clojure">
(def i (atom 0))

(defn generate-unique-id
"Returns a distinct numeric ID for each call."
[]
(swap! i inc))
</syntaxhighlight>

===Macros===
An anonymous subclass of <code lang="java">java.io.Writer</code> that doesn't write to anything, and a macro using it to silence all prints within it:

<syntaxhighlight lang="clojure">
(def bit-bucket-writer
(proxy [java.io.Writer] []
(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]
~@forms))

(noprint
(println "Hello, nobody!"))
;; => nil
</syntaxhighlight>

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

<syntaxhighlight lang="clojure">
; 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
(javax.swing.JOptionPane/showMessageDialog
nil
"Hello, World!")
;; => nil
</syntaxhighlight>

===Software transactional memory===
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:

<syntaxhighlight lang="clojure">
(defn run
[nvecs nitems nthreads niters]
(let [vec-refs
(->> (* nvecs nitems)
(range)
(into [] (comp (partition-all nitems)
(map vec)
(map ref))))

swap
#(let [v1 (rand-int nvecs)
v2 (rand-int nvecs)
i1 (rand-int nitems)
i2 (rand-int nitems)]
(dosync
(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))))

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

(report)

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

(report)))

(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
nil
</syntaxhighlight>


==See also==
==See also==
Line 514: Line 259:
==Further reading==
==Further reading==
{{Refbegin}}
{{Refbegin}}
* {{cite book |first1=Dmitri |last1=Sotnikov |year=2020 |title=Web Development with Clojure |publisher=[[Pragmatic Bookshelf]] |edition=3rd |isbn=978-1-68050-682-2 |url=https://pragprog.com/titles/dswdcloj3/}}

* {{cite book |first1=Russ |last1=Olsen |year=2018 |title=Getting Clojure |publisher=[[Pragmatic Bookshelf]] |isbn=978-1-68050-300-5 |url=https://pragprog.com/titles/roclojure/}}
* {{citation
* {{cite book |first1=Alex |last1=Miller |first2=Stuart |last2=Halloway |first3=Aaron |last3=Bedra |year=2018 |title=Programming Clojure |publisher=[[Pragmatic Bookshelf]] |edition=3rd |isbn=978-1-68050-246-6 |url=https://pragprog.com/titles/shcloj3/}}
| first1 = Dmitri
* {{cite book |first1=Carin |last1=Meier |year=2015 |title=Living Clojure: An introduction and training plan for developers |publisher=[[O'Reilly Media]] |edition=1st |isbn=978-1-491-90904-1 |url=https://www.oreilly.com/library/view/living-clojure/9781491909270/}}
| last1 = Sotnikov
* {{cite book |first1=Amit |last1=Rathore |first2=Francis |last2=Avila |year=2015 |title=Clojure in Action |publisher=[[Manning Publications]] |edition=2nd |isbn=978-1-61729-152-4}}
| year = 2020
* {{cite book |first1=Daniel |last1=Higginbotham |year=2015 |title=Clojure for the Brave and True |publisher=[[No Starch Press]] |isbn=978-1-59327-591-4 |url=https://www.braveclojure.com/clojure-for-the-brave-and-true/}}
| title = Web Development with Clojure
* {{cite book |first1=Julian |last1=Gamble |year=2015 |title=Clojure Recipes |publisher=[[Pearson Publishing]] |isbn=978-0-32192-773-6 |url=http://www.informit.com/store/clojure-recipes-9780321927736}}
| publisher = [[Pragmatic Bookshelf]]
* {{cite book |first1=Ben |last1=Vandgrift |first2=Alex |last2=Miller |year=2015 |title=Clojure Applied |publisher=[[Pragmatic Bookshelf]] |isbn=978-1-68050-074-5 |url=https://pragprog.com/titles/vmclojeco/}}
| edition = 3rd
* {{cite book |first1=Eric |last1=Rochester |year=2015 |title=Clojure Data Analysis Cookbook |publisher=[[Packt Publishing]] |edition=2nd |isbn=978-1-78439-029-7 |url=https://www.packtpub.com/application-development/clojure-data-analysis-cookbook-second-edition}}
| isbn = 978-1-68050-682-2
* {{cite book |first1=Michael |last1=Fogus |first2=Chris |last2=Houser |year=2014 |title=The Joy of Clojure |publisher=[[Manning Publications]] |edition=2nd |isbn=978-1-617291-41-8 |url=http://www.joyofclojure.com/ |access-date=2018-11-05 |archive-date=2018-10-23 |archive-url=https://web.archive.org/web/20181023083354/http://www.joyofclojure.com/ |url-status=dead}}
| url = https://pragprog.com/titles/dswdcloj3/
* {{cite book |first1=Ryan |last1=Kelker |year=2013 |title=Clojure for Domain-specific Languages |publisher=[[Packt Publishing]] |isbn=978-1-78216-650-4 |url=https://www.packtpub.com/application-development/clojure-domain-specific-languages}}
}}
* {{cite book |first1=Eric |last1=Rochester |year=2014 |title=Mastering Clojure Data Analysis |publisher=[[Packt Publishing]] |isbn=978-1-78328-413-9 |url=https://www.packtpub.com/big-data-and-business-intelligence/mastering-clojure-data-analysis}}
* {{citation
* {{cite book |first1=Chas |last1=Emerick |first2=Brian |last2=Carper |first3=Christophe |last3=Grand |date=April 19, 2012 |title=Clojure Programming |publisher=[[O'Reilly Media]] |isbn=978-1-4493-9470-7 |url=http://www.clojurebook.com/}}
| first1 = Russ
* {{cite book |first1=Luke |last1=VanderHart |first2=Stuart |last2=Sierra |date=June 7, 2010 |title=Practical Clojure |publisher=[[Apress]] |isbn=978-1-4302-7231-1 |url=https://www.apress.com/us/book/9781430272311}}
| last1 = Olsen
| year = 2018
| title = Getting Clojure
| publisher = [[Pragmatic Bookshelf]]
| isbn = 978-1-68050-300-5
| url = https://pragprog.com/titles/roclojure/
}}
* {{citation
| first1 = Alex
| last1 = Miller
| first2 = Stuart
| last2 = Halloway
| first3 = Aaron
| last3 = Bedra
| year = 2018
| title = Programming Clojure
| publisher = [[Pragmatic Bookshelf]]
| edition = 3rd
| isbn = 978-1-68050-246-6
| url = https://pragprog.com/titles/shcloj3/
}}
* {{citation
| first1 = Amit
| last1 = Rathore
| first2 = Francis
| last2 = Avila
| year = 2015
| title = Clojure in Action
| publisher = [[Manning Publications|Manning]]
| edition = 2nd
| isbn = 978-1-61729-152-4
}}
* {{citation
| first1 = Daniel
| last1 = Higginbotham
| year = 2015
| title = Clojure for the Brave and True
| publisher = [[No Starch Press]]
| isbn = 978-1-59327-591-4
| url = https://www.braveclojure.com/clojure-for-the-brave-and-true/
}}
* {{citation
| first1 = Julian
| last1 = Gamble
| year = 2015
| title = Clojure Recipes
| publisher = [[Pearson Publishing]]
| isbn = 978-0-32192-773-6
| url = http://www.informit.com/store/clojure-recipes-9780321927736
}}
* {{citation
| first1 = Ben
| last1 = Vandgrift
| first2 = Alex
| last2 = Miller
| year = 2015
| title = Clojure Applied
| publisher = [[Pragmatic Bookshelf]]
| isbn = 978-1-68050-074-5
| url = https://pragprog.com/titles/vmclojeco/
}}
* {{citation
| first1 = Eric
| last1 = Rochester
| year = 2015
| title = Clojure Data Analysis Cookbook
| publisher = [[Packt Publishing]]
| edition = 2nd
| isbn = 978-1-78439-029-7
| url = https://www.packtpub.com/application-development/clojure-data-analysis-cookbook-second-edition
}}
* {{citation
| first1 = Michael
| last1 = Fogus
| first2 = Chris
| last2 = Houser
| year = 2014
| title = The Joy of Clojure
| publisher = [[Manning Publications|Manning]]
| edition = 2nd
| isbn = 978-1-617291-41-8
| url = http://www.joyofclojure.com/
}}
* {{citation
| first1 = Ryan
| last1 = Kelker
| year = 2013
| title = Clojure for Domain-specific Languages
| publisher = [[Packt Publishing]]
| isbn = 978-1-78216-650-4
| url = https://www.packtpub.com/application-development/clojure-domain-specific-languages
}}
* {{citation
| first1 = Eric
| last1 = Rochester
| year = 2014
| title = Mastering Clojure Data Analysis
| publisher = [[Packt Publishing]]
| isbn = 978-1-78328-413-9
| url = https://www.packtpub.com/big-data-and-business-intelligence/mastering-clojure-data-analysis
}}
* {{citation
| first1 = Chas
| last1 = Emerick
| first2 = Brian
| last2 = Carper
| first3 = Christophe
| last3 = Grand
| date = April 19, 2012
| title = Clojure Programming
| publisher = [[O'Reilly Media]]
| isbn = 978-1-4493-9470-7
| url = http://www.clojurebook.com/
}}
* {{citation
| first1 = Luke
| last1 = VanderHart
| first2 = Stuart
| last2 = Sierra
| date = June 7, 2010
| title = Practical Clojure
| publisher = [[Apress]]
| isbn = 978-1-4302-7231-1
| url = https://www.apress.com/us/book/9781430272311
}}
{{Refend}}
{{Refend}}


Line 658: Line 279:


{{Lisp programming language}}
{{Lisp programming language}}

{{Lisp}}
{{Lisp}}
{{Java (Sun)}}
{{Java (software platform)}}


{{Authority control}}
{{Authority control}}

Revision as of 17:55, 15 May 2024

Clojure
Paradigmmulti-paradigm:
FamilyLisp
Designed byRich Hickey
First appeared2007; 17 years ago (2007)
Stable release
1.11.2[8] / 8 March 2024; 2 months ago (2024-03-08)
Typing discipline
Memory managementGarbage collection via a host (JVM, CLR, a JavaScript runtime such as V8 in case of ClojureScript or BEAM (see below)
Platform
LicenseEclipse Public
Filename extensions
  • .clj
  • .cljs
  • .cljr
  • .cljc
  • .cljd
  • .edn
Websiteclojure.org
Dialects
ClojureScript, ClojureDart
Influenced by
Influenced

Clojure (/ˈklʒər/, like closure)[17][18] is a dynamic and functional dialect of the Lisp programming language on the Java platform.[19][20]

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.[21][17] Clojure's reader supports literal syntax for maps, sets and vectors along with lists, and these are compiled to the mentioned structures directly.[21] Clojure treats code as data and has a Lisp macro system.[22] 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.[22]

Clojure advocates immutability and immutable data structures and encourages programmers to be explicit about managing identity and its states.[23] This focus on programming with immutable values and explicit progression-of-time constructs is intended to facilitate developing more robust, especially concurrent, programs that are simple and fast.[24][25][17] While its type system is entirely dynamic, recent efforts have also sought the implementation of a dependent type system.[26]

The language was created by Rich Hickey in the mid-2000s, originally for the Java platform; the language has since been ported to other platforms, such as the Common Language Runtime (.NET). Hickey continues to lead development of the language as its benevolent dictator for life.

History

Rich Hickey, creator of Clojure

Rich Hickey is the creator of the Clojure language.[19] 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 two and a half years working on Clojure before releasing it publicly in October 2007,[31] 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.

Clojure's name, according to Hickey, is a word play on the programming concept "closure" incorporating the letters C, L, and J for C#, Lisp, and Java respectively—three languages which had a major influence on Clojure's design.[18]

Design

Rich Hickey developed Clojure because he wanted a modern Lisp for functional programming, symbiotic with the established Java platform, and designed for concurrency.[24][25][32][17] He has also stressed the importance of simplicity in programming language design and software architecture, advocating for loose coupling, polymorphism via protocols and type classes instead of inheritance, stateless functions that are namespaced instead of methods or replacing syntax with data.[33][34][35]

Clojure's approach to state is characterized by the concept of identities,[23] 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.[23]

Clojure runs on the Java platform and as a result, integrates with Java and fully supports calling Java code from Clojure,[36][17] and Clojure code can be called from Java, too.[37] The community uses tools such as Clojure command-line interface (CLI)[38] or Leiningen for project automation, providing support for Maven integration. These tools handle project package management and dependencies and are configured using Clojure syntax.

As a Lisp dialect, Clojure supports functions as first-class objects, a read–eval–print loop (REPL), and a macro system.[6] Clojure's Lisp macro system is very similar to that of 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.[39] Clojure supports multimethods[40] and for interface-like abstractions has a protocol[41] based polymorphism and data type system using records,[42] 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;[43][44][45] it is possible to do so explicitly by using the recur keyword.[46] For parallel and concurrent programming Clojure provides software transactional memory,[47] a reactive agent system,[1] and channel-based concurrent programming.[48]

Clojure 1.7 introduced reader conditionals by allowing the embedding of Clojure, ClojureScript and ClojureCLR code in the same namespace.[49][21] 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.[50][51][52]

Extensible Data Notation

Extensible Data Notation, or edn,[53] is a subset of the Clojure language intended as a data transfer format. It can be used to serialize and deserialize Clojure data structures, and Clojure itself uses a superset of edn to represent programs.

edn is used in a similar way to JSON or XML, but has a relatively large list of built-in elements, shown here with examples:

  • booleans: true, false
  • strings: "foo bar"
  • characters: \c, \tab
  • symbols: name
  • keywords: :key
  • integers: 123
  • floating point numbers: 3.14
  • lists: (a b 42)
  • vectors: [a b 42]
  • maps: {:a 1, "foo" :bar, [1 2 3] four}
  • sets: #{a b [1 2 3]}
  • nil: nil (a null-like value)

In addition to those elements, it supports extensibility through the use of tags, which consist of the character # followed by a symbol. When encountering a tag, the reader passes the value of the next element to the corresponding handler, which returns a data value. For example, this could be a tagged element: #myapp/Person {:first "Fred" :last "Mertz"}, whose interpretation will depend on the appropriate handler of the reader.

This definition of extension elements in terms of the others avoids relying on either convention or context to convey elements not included in the base set.

Alternative platforms

The primary platform of Clojure is Java,[20][36] but other target implementations exist. The most notable of these is ClojureScript,[54] which compiles to ECMAScript 3,[55] and ClojureCLR,[56] a full port on the .NET platform, interoperable with its ecosystem.

Other implementations of Clojure on different platforms include:

  • Babashka,[57] Native Clojure scripting language leveraging GraalVM native image and Small Clojure Interpreter
  • CljPerl,[58] Clojure on Perl
  • ClojureDart,[59] Extend Clojure's reach to mobile & desktop apps by porting Clojure to Dart and Flutter
  • Clojerl,[60] Clojure on BEAM, the Erlang virtual machine
  • basilisp,[61] A Clojure-compatible(-ish) Lisp dialect targeting Python 3.8+
  • ClojureRS,[62] Clojure on Rust
  • Ferret,[63] compiles to self-contained C++11 that can run on microcontrollers
  • jank,[64] Native Clojure hosted in C++ on an LLVM-based JIT
  • Joker,[65] an interpreter and linter written in Go
  • Las3r,[66] a subset of Clojure that runs on the ActionScript Virtual Machine (the Adobe Flash Player platform)
  • Pixie,[67] Clojure-inspired Lisp dialect written in RPython
  • Rouge,[68] Clojure on YARV in Ruby

Tools

Tooling for Clojure development has seen significant improvement over the years. The following is a list of some popular IDEs and text editors with plug-ins that add support for programming in Clojure:[69]

In addition to the tools provided by the community, the official Clojure command-line interface (CLI) tools[38] have also become available on Linux, macOS, and Windows since Clojure 1.9.[83]

Development

The development process is restricted to the Clojure core team, though issues are publicly visible at the Clojure JIRA project page.[84] Anyone can ask questions or submit issues and ideas at ask.clojure.org.[85] If it's determined that a new issue warrants a JIRA ticket, a core team member will triage it and add it. JIRA issues are processed by a team of screeners and finally approved by Rich Hickey.[86][87]

Impact

With continued interest in functional programming, Clojure's adoption by software developers using the Java platform has continued to increase. The language has also been recommended by software developers such as Brian Goetz,[88][89][90] Eric Evans,[91][92] James Gosling,[93] Paul Graham,[94] and Robert C. Martin.[95][96][97][98] ThoughtWorks, while assessing functional programming languages for their Technology Radar,[99] described Clojure as "a simple, elegant implementation of Lisp on the JVM" in 2010 and promoted its status to "ADOPT" in 2012.[100]


In the "JVM Ecosystem Report 2018" (which was claimed to be "the largest survey ever of Java developers"), that was prepared in collaboration by Snyk and Java Magazine, ranked Clojure as the 2nd most used programming language on the JVM for "main applications".[101] Clojure is used in industry by firms[102] such as Apple,[103][104] Atlassian,[105] Funding Circle,[106] Netflix,[107] Nubank,[108] Puppet,[109] and Walmart[110] as well as government agencies such as NASA.[111] It has also been used for creative computing, including visual art, music, games, and poetry.[112]

In the 2023 edition of Stack Overflow Developer Survey, Clojure was the fourth most admired in the category of programming and scripting languages, with 68.51% of the respondents who have worked with it last year saying they would like to continue using it. In the desired category, however it was marked as such by only 2.2% of the surveyed, whereas the highest scoring JavaScript was desired by 40.15% of the developers participating in the survey.[113] It could possibly be attributed to limited professional opportunities for Clojure developers with just over 50 search results for "Clojure developer" at the U.S. section of Indeed, as of May 2024.[114]

Release history

Version Release date Major features, improvements
October 17, 2007 (2007-10-17)[31] Initial public release
1.0 May 4, 2009 (2009-05-04)[115] First stable release
1.1 December 31, 2009 (2009-12-31)[116] Futures
1.2 August 19, 2010 (2010-08-19)[117] Protocols
1.3 September 23, 2011 (2011-09-23)[118] Enhanced primitive support
1.4 April 15, 2012 (2012-04-15)[119] Reader literals
1.5 March 1, 2013 (2013-03-01)[120] Reducers
1.5.1 March 10, 2013 (2013-03-10)[121] Fixing a memory leak
1.6 March 25, 2014 (2014-03-25)[122] Java API, improved hashing algorithms
1.7 June 30, 2015 (2015-06-30)[49] Transducers, reader conditionals
1.8 January 19, 2016 (2016-01-19)[123] Additional string functions, direct linking, socket server
1.9 December 8, 2017 (2017-12-08)[124] Integration with spec, command-line tools
1.10 December 17, 2018 (2018-12-17)[125] Improved error reporting, Java compatibility
1.10.1 June 6, 2019 (2019-06-06)[126] Working around a Java performance regression and improving error reporting from clojure.main
1.10.2 January 26, 2021 (2021-01-26)[127] Java interoperability/compatibility improvements and other important language fixes
1.10.3 March 4, 2021 (2021-03-04)[128] prepl support for reader conditionals
1.11.0 March 22, 2022 (2022-03-22)[129] New syntax for keyword argument invocation, new clojure.math namespace, namespace aliasing without loading, and new helper functions added to clojure.core
1.11.1 April 5, 2022 (2022-04-05)[130] Rolling back unintended change in binary serialisation of objects of types clojure.lang.Keyword and clojure.lang.ArraySeq.
Current stable version: 1.11.2 March 8, 2024 (2024-03-08)[8] Fix for CVE-2024-22871 Denial of Service vulnerability
Legend:
Old version
Older version, still maintained
Latest version
Latest preview version
Future release

See also

References

  1. ^ a b "Agents and Asynchronous Actions". Clojure.org. Retrieved 2019-07-07.
  2. ^ "Concurrent Programming". Clojure.org. Retrieved 2019-07-07.
  3. ^ Hickey, Rich; contributors. "core.async". GitHub. Retrieved 2019-07-07.
  4. ^ "Functional Programming". Clojure.org. Retrieved 2019-07-07.
  5. ^ Nolen, David; Hickey, Rich. "core.logic". GitHub. Retrieved 2019-07-07.
  6. ^ a b "Macros". Clojure.org. Retrieved 2019-07-07.
  7. ^ Esterhazy, Paulus. "Threading Macros Guide". Clojure.org. Retrieved 2019-07-07.
  8. ^ a b Miller, Alex (2024-03-08). "Clojure 1.11.2 release". Clojure.org.
  9. ^ Fogus, Michael (2011). "Rich Hickey Q&A". CodeQuarterly.com. Archived from the original on 2017-01-11.
  10. ^ Hickey, Rich (2011). "Simple Made Easy". YouTube. {{cite web}}: Unknown parameter |note= ignored (help)
  11. ^ Bonnaire-Sergeant, Ambrose (2012). A Practical Optional Type System for Clojure (Thesis). The University of Western Australia.
  12. ^ "Clojure Programming" (PDF). OReilly.com. Retrieved 2013-04-30.
  13. ^ Hickey, Rich. "Clojure Bookshelf". Amazon.com. Archived from the original on 2017-10-03. Retrieved 2019-07-07.
  14. ^ Rose, Calvin; contributors. "Janet Language". Janet-Lang.org. Retrieved 2023-02-18.
  15. ^ Baldridge, Timothy. "Pixie". PixieLang.org. Retrieved 2019-07-07.
  16. ^ Ramachandra, Ramkumar. "Rhine". GitHub. Retrieved 2019-07-07.
  17. ^ a b c d e Edwards, Kathryn (2009-08-10). "The A-Z of Programming Languages: Clojure". Computerworld.com.au. Archived from the original on 2019-08-26.
  18. ^ a b Hickey, Rich (2009-01-05). "meaning and pronunciation of Clojure". Google.com.
  19. ^ a b Krill, Paul (2012-03-22). "Clojure inventor Hickey now aims for Android". InfoWorld.com.
  20. ^ a b "Clojure". Clojure.org. Retrieved 2019-07-07.
  21. ^ a b c "The Reader". Clojure.org. Retrieved 2019-07-07.
  22. ^ a b "Differences with other Lisps". Clojure.org. Retrieved 2019-07-07.
  23. ^ a b c "Values and Change: Clojure's approach to Identity and State". Clojure.org. Retrieved 2019-07-07.
  24. ^ a b Hickey, Rich. "Rationale". Clojure.org. Retrieved 2019-07-07.
  25. ^ a b Torre, Charles (2009-10-06). "Expert to Expert: Rich Hickey and Brian Beckman – Inside Clojure". MSDN.com.
  26. ^ "clojure/spec.alpha". GitHub. 2017-04-26.
  27. ^ Hickey, Rich (2002-10-16). "[ANN] dotLisp: A Lisp dialect for .Net". Google.com.
  28. ^ Hickey, Rich (2013-04-15). "jfli". SourceForge.net.
  29. ^ Hickey, Rich (2013-04-03). "foil: Foreign Object Interface for Lisp". SourceForge.net.
  30. ^ Hickey, Rich (2013-03-07). "Lisplets". SourceForge.net.
  31. ^ a b Hickey, Rich (2020-06-12). "A history of Clojure". Proceedings of the ACM on Programming Languages. 4 (HOPL): 1–46. doi:10.1145/3386321. S2CID 219603760.
  32. ^ Elmendorf, Dirk (2010-04-01). "Economy Size Geek – Interview with Rich Hickey, Creator of Clojure". LinuxJournal.com.
  33. ^ "Simple Made Easy". InfoQ. Retrieved 2024-05-02.
  34. ^ "(iterate think thoughts): Advantages of Data Oriented Programming". yogthos.net. Retrieved 2024-05-02.
  35. ^ "talk-transcripts/Hickey_Rich/EffectivePrograms.md at master · matthiasn/talk-transcripts". GitHub. Retrieved 2024-05-02.
  36. ^ a b "Hosted on the JVM". Clojure.org. Retrieved 2019-07-07.
  37. ^ "Java Interop". Clojure.org. Retrieved 2019-07-07.
  38. ^ a b Miller, Alex. "Deps and CLI Guide". Clojure.org. Retrieved 2019-07-08.
  39. ^ Hickey, Rich. "edn". GitHub. Retrieved 2019-07-07.
  40. ^ "Multimethods and Hierarchies". Clojure.org. Retrieved 2019-07-07.
  41. ^ "Protocols". Clojure.org. Retrieved 2019-07-07.
  42. ^ "Datatypes: deftype, defrecord and reify". Clojure.org. Retrieved 2019-07-07.
  43. ^ Goetz, Brian (2014-11-20). "Stewardship: the Sobering Parts". YouTube.com.
  44. ^ Rose, John (2007-07-12). "tail calls in the VM". Oracle.com.
  45. ^ Rose, John (2009-02-11). "Some languages need to be able to perform tail calls". Java.net.
  46. ^ "Special Forms". Clojure.org. Retrieved 2019-07-07.
  47. ^ "Refs and Transactions". Clojure.org. Retrieved 2019-07-07.
  48. ^ Hickey, Rich (2013-06-28). "Clojure core.async Channels". Clojure.org.
  49. ^ a b Miller, Alex (2015-06-30). "Clojure 1.7 is now available". Clojure.org.
  50. ^ Hickey, Rich (2014-09-17). "Transducers". YouTube.com.
  51. ^ Hickey, Rich (2014-08-06). "Transducers are Coming". Cognitect.com.
  52. ^ Hickey, Rich (2014-11-20). "Inside Transducers". YouTube.com.
  53. ^ "Official EDN Spec". edn-format.org. 2022-04-27.
  54. ^ "ClojureScript". ClojureScript.org. Retrieved 2019-07-06.
  55. ^ "ClojureScript – FAQ (for JavaScript developers)". ClojureScript.org. Retrieved 2018-02-04.
  56. ^ "ClojureCLR". GitHub. Retrieved 2012-06-28.
  57. ^ Borkent, Michiel. "Babashka". Babashka.org. Retrieved 2019-08-19.
  58. ^ Hu, Wei. "A Lisp on Perl". MetaCPAN.org. Retrieved 2019-07-06.
  59. ^ "What is ClojureDart?", GitHub, Tensegritics, 2022-12-16, retrieved 2022-12-16
  60. ^ Facorro, Juan. "Clojerl". GitHub. Retrieved 2019-07-06.
  61. ^ "basilisp". GitHub. Retrieved 2024-05-13.
  62. ^ "ClojureRS". GitHub. Retrieved 2022-03-17.
  63. ^ Akkaya, Nurullah. "Ferret". Ferret-Lang.org. Retrieved 2019-07-06.
  64. ^ Wilkerson, Jeaye. "jank". Jank-Lang.org. Retrieved 2022-08-17.
  65. ^ Bataev, Roman. "Joker". Joker-Lang.org. Retrieved 2019-07-06.
  66. ^ Cannon, Aemon. "Laz3r". GitHub. Retrieved 2019-07-06.
  67. ^ Baldridge, Timothy. "Pixie". PixieLang.org. Retrieved 2019-07-06.
  68. ^ Connor, Ashe. "Rouge". GitHub. Retrieved 2019-07-06.
  69. ^ Miller, Alex (2019-02-04). ""State of Clojure 2019" Results". Clojure.org.
  70. ^ Batsov, Bozhidar; contributors. "CIDER: The Clojure Interactive Development Environment that Rocks". CIDER.mx. Retrieved 2019-07-05.
  71. ^ Fleming, Colin. "Cursive: Provides full Clojure and ClojureScript language support". JetBrains.com. Retrieved 2019-07-05.
  72. ^ Prokopov, Nikita. "Clojure Sublimed". PackageControl.io. Retrieved 2023-02-18.
  73. ^ Helenius, Eero. "Tutkain". FlowThing.me. Retrieved 2023-02-18.
  74. ^ Pope, Tim. "fireplace.vim: Clojure REPL Support". VIM.org. Retrieved 2019-07-05.
  75. ^ Monroe, Dominic (2016-12-13). "Clojure and Vim: An overview – It's very possible". JUXT.pro.
  76. ^ Masashi, Iizuka (2024-04-29). "vim-elin: A Clojure development environment for Vim/Neovim, primarily written in Babashka". GitHub. Archived from the original on 2024-05-02. Retrieved 2024-05-02.
  77. ^ Caldwell, Oliver. "Neovim Clojure(Script) tooling over prepl". GitHub. Retrieved 2019-11-09.
  78. ^ Caldwell, Oliver (2019-11-06). "Getting started with Clojure, Neovim and Conjure in minutes". oli.me.uk.
  79. ^ Strömberg, Peter. "Calva: Clojure & ClojureScript Interactive Programming". VisualStudio.com. Retrieved 2019-07-05.
  80. ^ Szabo, Maurício. "Clover". VisualStudio.com. Retrieved 2021-01-28.
  81. ^ clj-kondo/clj-kondo, clj-kondo, 2024-04-30, retrieved 2024-05-02
  82. ^ "Overview - Clojure LSP". clojure-lsp.io. Retrieved 2024-05-02.
  83. ^ Miller, Alex (2017-12-08). "Clojure 1.9". Cognitect.com.
  84. ^ "Clojure". Atlassian.net. Retrieved 2019-07-07.
  85. ^ "Clojure Forum". clojure.org. Retrieved 2020-03-20.
  86. ^ Hickey, Rich (2018-11-26). "Open Source is Not About You". GitHub.
  87. ^ "Workflow". Clojure.org. Retrieved 2019-07-07.
  88. ^ Goetz, Brian (2020-05-24). "Brian Goetz' favorite non-Java JVM language (Part 1 of 3)". Twitch.tv.
  89. ^ Goetz, Brian (2020-05-24). "Brian Goetz' favorite non-Java JVM language (Part 2 of 3)". Twitch.tv.
  90. ^ Goetz, Brian (2020-05-24). "Brian Goetz' favorite non-Java JVM language (Part 3 of 3)". Twitch.tv.
  91. ^ Evans, Eric (2018-08-14). "Modelling Time: Eric Evans: Domain-Driven Design Europe 2018". YouTube.com.
  92. ^ Evans, Eric (2014-11-21). "Eric Evans on Twitter". Twitter.com.
  93. ^ "James Gosling meetup with London Java Community". YouTube.com. 2016-10-11.
  94. ^ Graham, Paul (2016-05-06). "Paul Graham on Twitter". Twitter.com.
  95. ^ Martin, Robert (2019-08-22). "Why Clojure?". CleanCoder.com.
  96. ^ Martin, Robert (2018-11-29). "Unble Bob Martin on Twitter". Twitter.com.
  97. ^ Martin, Robert (2018-08-01). "Introduction To Functional Programming". CleanCoders.com.
  98. ^ Martin, Robert (2017-07-11). "Pragmatic Functional Programming". CleanCoder.com.
  99. ^ "Technology Radar: Frequently Asked Questions". ThoughtWorks.com. Retrieved 2019-02-10.
  100. ^ "Technology Radar: Clojure". ThoughtWorks.com. Retrieved 2019-02-10.
  101. ^ Maple, Simon; Binstock, Andrew (2018-10-17). "JVM Ecosystem Report 2018". Snyk.io.
  102. ^ "Success Stories". Clojure.org. Retrieved 2018-10-27.
  103. ^ Liutikov, Roman (2017-12-17). "Roman Liutikov on Twitter". Twitter.com.
  104. ^ "Jobs at Apple". Apple.com. Retrieved 2019-07-06.
  105. ^ Borges, Leonardo (2015-07-07). "Realtime Collaboration with Clojure". YouTube.com.
  106. ^ Pither, Jon (2016-10-04). "Clojure in London: Funding Circle – Lending some Clojure". JUXT.pro.
  107. ^ Williams, Alex (2014-08-03). "The New Stack Makers: Adrian Cockcroft on Sun, Netflix, Clojure, Go, Docker and More". TheNewStack.io.
  108. ^ "Nubank adquire empresa norte-americana de tecnologia Cognitect". 23 July 2020.
  109. ^ Price, Chris (2014-04-11). "A New Era of Application Services at Puppet Labs". Puppet.com. Retrieved 2020-08-06.
  110. ^ Phillips, Marc (2015-07-14). "Walmart Runs Clojure at Scale". Cognitect.com.
  111. ^ "Common-Metadata-Repository". GitHub. Retrieved 2019-07-06.
  112. ^ Meier, Carin (2015-05-06). "Creative computing with Clojure". OReilly.com.
  113. ^ "Stack Overflow Developer Survey 2023". Stack Overflow. Retrieved 2024-05-02.
  114. ^ ""Clojure developer" search results at Indeed.com [Archived due to the mutability of the source]". Archive.is. 2024-05-02. Retrieved 2024-05-02.
  115. ^ Hickey, Rich (2009-05-04). "Clojure 1.0". BlogSpot.com.
  116. ^ Hickey, Rich (2009-12-31). "Clojure 1.1 Release". BlogSpot.com.
  117. ^ Hickey, Rich (2010-08-19). "Clojure 1.2 Release". Google.com.
  118. ^ Redinger, Christopher (2011-09-23). "[ANN] Clojure 1.3 Released". Google.com.
  119. ^ Dipert, Alan (2012-04-17). "[ANN] Clojure 1.4 Released". Google.com.
  120. ^ Halloway, Stuart (2013-03-01). "ANN: Clojure 1.5". Google.com.
  121. ^ Halloway, Stuart (2013-03-10). "Clojure 1.5.1". Google.com.
  122. ^ Miller, Alex (2014-03-25). "[ANN] Clojure 1.6". Google.com.
  123. ^ Miller, Alex (2016-01-19). "Clojure 1.8 is now available". Clojure.org.
  124. ^ Miller, Alex (2017-12-08). "Clojure 1.9 is now available". Clojure.org.
  125. ^ Miller, Alex (2018-12-17). "Clojure 1.10 release". Clojure.org.
  126. ^ Miller, Alex (2019-06-06). "Clojure 1.10.1 release". Clojure.org.
  127. ^ Miller, Alex (2021-01-26). "Clojure 1.10.2 release". Clojure.org.
  128. ^ Miller, Alex (2021-03-04). "Clojure 1.10.3 release". Clojure.org.
  129. ^ Miller, Alex (2022-03-22). "Clojure 1.11.0 release". Clojure.org.
  130. ^ Miller, Alex (2022-04-05). "Clojure 1.11.1 release". Clojure.org.

Further reading

External links

1958 1960 1965 1970 1975 1980 1985 1990 1995 2000 2005 2010 2015 2020
 LISP 1, 1.5, LISP 2(abandoned)
 Maclisp
 Interlisp
 MDL
 Lisp Machine Lisp
 Scheme  R5RS  R6RS  R7RS small
 NIL
 ZIL (Zork Implementation Language)
 Franz Lisp
 Common Lisp  ANSI standard
 Le Lisp
 MIT Scheme
 XLISP
 T
 Chez Scheme
 Emacs Lisp
 AutoLISP
 PicoLisp
 Gambit
 EuLisp
 ISLISP
 OpenLisp
 PLT Scheme  Racket
 newLISP
 GNU Guile
 Visual LISP
 Clojure
 Arc
 LFE
 Hy
 Chialisp