Skip to main content

Clojure

Pronunciation
KLOH-zher
Updated 2 min read

Share this page

Send the link, quote the definition with a link back, or show it as a card on your own site.

https://softwaredictionary.org/terms/clojure

In short

Clojure is a modern, dynamic dialect of Lisp that runs on the JVM, emphasizing immutable data, functional programming and interactive, REPL-driven development.

What is Clojure?

Clojure is a general-purpose programming language created by Rich Hickey and first released in 2007. It is a dialect of Lisp, one of the oldest families of programming languages, and it runs on the Java Virtual Machine, so Clojure code can call any Java library. ClojureScript is a sister implementation that compiles to JavaScript for browsers and Node.js.

Like all Lisps, Clojure writes code as nested lists in parentheses with the function first: (+ 1 2) instead of 1 + 2. Because code is written in the language's own data structures, a property called homoiconicity, macros can transform code before it runs and let developers extend the language itself. Clojure is dynamically typed and functional, and its core collections (lists, vectors, maps and sets) are immutable and persistent, meaning updates return new versions that efficiently share memory with the old ones. For state that must change, it provides controlled tools such as atoms, which update a value safely across threads.

Clojure is used for backend services, data processing and financial systems, and ClojureScript is used for web front ends. Developers typically work in a REPL connected to their running program, evaluating and redefining one function at a time, which feels more like a conversation with the application than an edit-compile-run cycle.

Clojure is often compared with other Lisps and with other JVM languages. Compared with older Lisps such as Common Lisp and Scheme, it adds literal syntax for vectors and maps, immutable data by default and tight integration with its host platform. Compared with Scala and Kotlin, which also run on the JVM, Clojure is dynamically typed and far more minimal in syntax, trading compile-time type checks for flexibility and interactive development.

Key takeaways

  • Clojure is a Lisp dialect that runs on the JVM and can use Java libraries.
  • Its core data structures are immutable and persistent.
  • Code is written as data, so macros can extend the language.
  • REPL-driven development lets you change a running program interactively.
  • ClojureScript brings the same language to JavaScript environments.

Example

Immutable maps and threading in Clojureclojure
;; Maps are immutable: assoc returns a new map
(def user {:name "Ada" :langs ["clojure" "java"]})
(def updated (assoc user :role "admin"))

(println (:role user))     ;; nil (original unchanged)
(println (:role updated))  ;; admin

;; The ->> macro threads a value through a series of functions
(->> [1 2 3 4 5 6]
     (filter even?)
     (map #(* % %))
     (reduce +)
     (println))            ;; 56

Readers ask

Why does Clojure have so many parentheses?

Clojure, like all Lisps, writes code as nested lists with the function name first inside each pair of parentheses. The uniform structure keeps the syntax very small and lets macros treat code as data, and editors balance the parentheses automatically.

Is Clojure a functional language?

Yes. Clojure encourages pure functions and immutable data and treats functions as values, but it is pragmatic: it allows side effects and offers managed ways to change state, such as atoms.

What is the difference between Clojure and ClojureScript?

They are the same language targeting different platforms. Clojure runs on the JVM and uses Java libraries, while ClojureScript compiles to JavaScript and runs in browsers or Node.js.

See also

Spotted a mistake or something missing on this page?Suggest an edit

Read a random page
Open today's review
Switch to the dark theme
Read this page in Türkçe

More

Settings