Clojure is a Lisp dialect for the Java Virtual Machine (with versions for the CLR and JavaScript).
Clojure is a modern Lisp dialect with an emphasis on functional programming (lazy/impure), running on the JVM with transparent access to all Java libraries, an interactive REPL development environment, dynamic runtime polymorphism, Lisp-style macro meta-programming and concurrent programming capabilities supported by software transactional memory.
###Key features:
- Lisp heritage - Clojure is a fully homoiconic language with support for macro-based metaprogramming. The full features of the language are available at compile time, and it is possible to manipulate "code as data". These mechanisms are frequently used to extend the language itself or create new domain-specific languages.
- Functional programming - Clojure is primarily a functional language. It features immutable data structures and lazy sequences. Like many other Lisps, it is eagerly evaluated (although lazy sequences, macros and closures can be introduced to obtain lazy behavior) and impure.
- Concurrent programming, supported by software transactional memory, and designed for multi-core environments.
- Dynamic - Clojure is a dynamic language. However it should be noted that it is still fully compiled, exploits primitive operations on the JVM where needed for performance and can also support (optional) static type hints.
- Hosted on the JVM, allowing for easy and transparent access to the wide ecosystem of Java libraries.
- Open source - Clojure is run as a collaborative open source project (hosted on GitHub) and there is a rapidly growing ecosystem of open source libraries for Clojure, in addition to all the open source tools already available for Java
- Portable - Clojure can run on any platform that supports the JVM, and Clojure versions are also available for the CLR (ClojureCLR) and JavaScript (ClojureScript)
###Code Samples:
Hello world is simple....
(println "Hello World!")
The "infamous" Lisp parentheses are used to apply a function, which is always the first item in the list:
(+ 1 2 3 4)
=> 10
Functions can easily be defined and passed to higher order functions like map
:
(defn triple [x]
(+ x x x))
(map triple [1 2 3 4 5 10])
=> (3 6 9 12 15 30)
Infinite lazy sequences are fully supported:
(take 7 (iterate (partial str "a") "b"))
=> ("b" "ab" "aab" "aaab" "aaaab" "aaaaab" "aaaaaab")
You can even do powerful computations on infinite sequences, such as defining the complete Fibonacci series:
(def fibonaccis
(lazy-cat [0 1] (map + fibonaccis (rest fibonaccis))))
(take 10 fibonaccis)
=> (0 1 1 2 3 5 8 13 21 34)
###Resources:
- The Getting Started wiki (including instructions on IDE / Emacs / Vim setup and build tools)
- The Clojure Google group archives
- Clojure quick reference
- ClojureDocs -- "Community powered Clojure Documentation and Examples"
- Disclojure -- daily summary of Clojure intertweets
- Planet Clojure -- the Clojure blog aggregator
- 4Clojure, Clojure Koans -- Interactive fill-in-the-blank Clojure problems
- Coderwall Clojure Network -- Tips from a network of Clojure developers
- Clojure Toolbox -- A categorised directory of libraries and tools for Clojure
Clojure Web Frameworks
##Clojure Video Tutorials
General Clojure
- Inside Clojure
- Sean Devlin's screencasts
- Intro to Clojure
- Clojure's basics
- Concurrent programming in Clojure
- Clojure 1.2 Protocols
- Rich Hickey on Protocols and Clojure 1.3
- Clojure's Solutions to the Expression Problem
- Clojure Concurrency On-Demand!
- Rich Hickey on Clojure's Features and Implementation
- Clojure
- Are We There Yet?
- Persistent Data Structures and Managed References
- Stuart Halloway on Clojure and Functional Programming
- Programming Clojure
- Clojure in the Field
- Clojure and Simplicty
- Clojure in Clojure
- Clojure: Functional Concurrency for the JVM
- Devoxx'09
- Asynchronous Events in Clojure
- Clojure for Schemers
- Introduction to Monads
- several video lectures
- Clojure - Up Close and Personal
- circumspec, inferior-lisp, clojure, and slime
- Compojure/Emacs Intro
- Functional Programming with Clojure
Clojure Web Development
ClojureScript