Web Analytics Made Easy -
StatCounter
Main Glossary Clojure

Clojure

Clojure

What is Clojure?

Clojure is designed to be a general-purpose language, combining the approachability and interactive development of a scripting language with an efficient and robust infrastructure for multithreaded programming. Clojure is a compiled language - it compiles directly to JVM bytecode, yet remains completely dynamic. Clojure is a dialect of Lisp, and shares with Lisp the code-as-data philosophy and a powerful macro system.

Rationale

Customers and stakeholders have substantial investments in, and are comfortable with the performance, security and stability of, industry-standard platforms like the JVM. While Java developers may envy the succinctness, flexibility and productivity of dynamic languages, they have concerns about running on customer-approved infrastructure, access to their existing code base and libraries, and performance. In addition, they face ongoing problems dealing with concurrency using native threads and locking. Clojure is an effort in pragmatic dynamic language design in this context. It endeavors to be a general-purpose language suitable in those areas where Java is suitable. It reflects the reality that, for the concurrent programming future, pervasive, unmoderated mutation simply has to Go.

Clojure meets its goals by: embracing an industry-standard, open platform - the JVM; modernizing a venerable language - Lisp; fostering functional programming with immutable persistent data structures; and providing built-in concurrency support via software transactional memory and asynchronous agents. The result is robust, practical, and fast.

Clojure has a distinctive approach to state and identity.

Lisp is a good thing

  • Often emulated/pillaged, still not duplicated
  • Lambda calculus yields an extremely small core
  • Almost no syntax
  • Core advantage still code-as-data and syntactic abstraction
  • What about the standard Lisps (Common Lisp and Scheme)?
    • Slow/no innovation post standardization
    • Core data structures mutable, not extensible
    • No concurrency in specs
    • Good implementations already exist for JVM (ABCL, Kawa, SISC et al)
    • Standard Lisps are their own platforms
  • Clojure is a Lisp not constrained by backwards compatibility
    • Extends the code-as-data paradigm to maps and vectors
    • Defaults to immutability
    • Core data structures are extensible abstractions
    • Embraces a platform (JVM)

Functional programming is a good thing

  • Immutable data + first-class functions
  • Could always be done in Lisp, by discipline/convention
    • But if a data structure can be mutated, dangerous to presume it won’t be
    • In traditional Lisp, only the list data structure is structurally recursive
  • Pure functional languages tend to strongly static types
    • Not for everyone, or every task
  • Clojure is a functional language with a dynamic emphasis
    • All data structures immutable & persistent, supporting recursion
    • Heterogeneous collections, return types
    • Dynamic polymorphism

The Clojure Programming Language

Clojure is a dynamic, general-purpose programming language, combining the approachability and interactive development of a scripting language with an efficient and robust infrastructure for multithreaded programming. Clojure is a compiled language, yet remains completely dynamic – every feature supported by Clojure is supported at runtime. Clojure provides easy access to the Java frameworks, with optional type hints and type inference, to ensure that calls to Java can avoid reflection.

Clojure is a dialect of Lisp, and shares with Lisp the code-as-data philosophy and a powerful macro system. Clojure is predominantly a functional programming language, and features a rich set of immutable, persistent data structures. When mutable state is needed, Clojure offers a software transactional memory system and reactive Agent system that ensure clean, correct, multithreaded designs.

I hope you find Clojure's combination of facilities elegant, powerful, practical and fun to use.

Rich Hickey
author of Clojure and CTO Cognitect

official clojure.org
src stackshare.io/clojure