Clojure Programming
Clojure is a dynamic programming language for the JVM.
Introduction
[edit | edit source]People come to Clojure from a variety of backgrounds. The purpose of this book is to help everyone get the most out of the Clojure language. It is not meant as a replacement for the documentation, found at the Clojure site. Please do not copy material from there to here!
Feel free to post your own code, written in the Clojure language, here. However, please do not post excerpts, patches or other modifications or derivations of the Clojure source itself, as the license of this Wiki is incompatible with the Clojure license. Instead, post such things to the Clojure discussion group.
Implementations
[edit | edit source]There are a number of different implementations of the Clojure language:
- Clojure (the original Java-based implementation)
- ClojureScript (compiles to JavaScript)
- ClojureCLR (for Microsoft's .NET framework)
- clojure-py (Python-based)
- clojure-scheme (compiles to Scheme)
- ClojureC (compiles to C)
FAQ
[edit | edit source]Some answers to Frequently Asked Questions.
The Getting started section covers obtaining and installing Clojure as well as basic setup of editors such as Emacs or Vim.
Other "Getting Started" guides and documentation:
The Concepts section covers Clojure language basics, such as supported datatypes, "mutability" or state in Clojure, functional programming and the concurrency features. Also see the book Learning Clojure.
By Example is an introductory look at Clojure that is heavy on examples to introduce the look and meaning of various constructs.
The Tutorials and Tips section covers differences with other languages and miscellaneous tutorials.
Learning Clojure gives an examination of Clojure's features.
The labrepl is an interactive environment for learning Clojure.
4clojure presents a series of small programming problems to help you learn Clojure (web based, no install required)
clojure-koans is great way for beginners to learn the basic syntax and built in functions of Clojure
Talking to machines clojure script tutorial for beginners with online repl.
Brave Clojure overviews Clojure's main features.
Refer to the curated and categorized listing of External Articles for links to informative Clojure-related articles and blog posts.
This section is a cookbook with various Clojure examples, including
- Using JDBC
- Norvig's Spelling Corrector
- Simple REPL on a Socket
- Simple GUI : Temperature Converter
- Lazy Fibonacci
- Talking to Excel
- genclass and finalize
- Invoking Java method through method name as a String
- Creating an Applet
This section is for examples using the Clojure API
A Cookbook of favorite Clojure code examples.
Links to further Examples
[edit | edit source]Graphics and Image Processing
[edit | edit source]- Context Free Art clone [1]
- ImageJ and Clojure (via Fiji) [2]
- OpenGL Tetrahedron ported from Wikipedia JOGL example [3]
- Simple SparkLine Generator in Clojure [4]
Web Programming
[edit | edit source]- Sending Email [5]
- Webjure: Simple web framework.
- Compojure: Another web framework.
- The Joy of Clojure
- Noir Web Framework: Lightweight web framework (no longer maintained)
- Enlive: Templating library for HTML with xpath-style selectors.
- Hiccup: A fast library for rendering HTML in Clojure.
- Using Google Charts from Clojure [6]
- Clojure in Action, Second Edition
A library stack for web programming would consist of
[edit | edit source]- Ring: Ring provides a standard interface to talk to web servers, and a set of libraries for handling things like sessions and file uploads.
- Framework: These provide a nice high-level interface that is suited for defining the routes and controller logic of a web application.
- HTML generator: dynamically generate HTML pages.
- Other libraries, that don't fit into any of the above categories
Miscellaneous
[edit | edit source]- "Practical: An MP3 Database" chapter from Practical Common Lisp translated to Clojure [7]
- Examples from Practical Common Lisp ported to Clojure [8]
- Socket Programming Walkthrough [9]
- Destructuring bind in def [10]
- Embedded REPL (Interactive production applications) [11]
- Generating the digits of PI in Clojure [12]
- A Quine in Clojure [13]
- Clojure Pong port [14]
- Palindromes in Clojure [15]